Skip to content

Mcp integration#2833

Draft
afsalthaj wants to merge 40 commits intomainfrom
mcp_integration
Draft

Mcp integration#2833
afsalthaj wants to merge 40 commits intomainfrom
mcp_integration

Conversation

@afsalthaj
Copy link
Contributor

@afsalthaj afsalthaj commented Feb 24, 2026

Fixes #2792

Bootstrapping MCP server, the flattened version as documented. Need to do a few clean ups before making it ready for review.

I am not making CLI changes in this PR (it's a separate ticket) but whatever that's required for CLI from the server side is done (McpDeploymentClientLive).

However, I added a small to-be-removed snippet to see if this really works with a real AI. And it's confirmed the entire thing to be working with Open AI client: https://platform.openai.com/chat/edit?models=gpt-4.1-mini

Testing with Open AI

  • So golem new, built a new rust agent (see below)
  • golem deploy (but with 10 lines of temporary code in CLI to see if its working) --> MCP deployment
  • MCP server runs in golem
  • Connected with OpenAI, and added our server, and it succesfully connected and handshaked and listed tools
  • Later used it to invoke it
image

The name of the tool is a bit odd, bu I will be fixing it as part of cleaning things up. The above screenshot successfully handshaked with Golem and listed tools

User experience using MCP Server

The actual usage looks very reasonable. The fact that constructor parameters being part of the tool itself seems to be very reasonable as well as flexible.

For example see this specific situation. Here name is a constructor argument

image

Here I just prompted to increment by 10, but forgot to mention which counter (the value of the constructor param) and client tell us the user to give more details.

Statefulness

The statefulness is about being able to hit the same identity of the agent, that's it.

image

The agent that was used:

use golem_rust::{agent_definition, agent_implementation, endpoint};

#[agent_definition]
pub trait CounterAgent {
    fn new(name: String) -> Self;

    fn increment_by(&mut self, num: u32) -> u32;
}

struct CounterImpl {
    _name: String,
    count: u32,
}

#[agent_implementation]
impl CounterAgent for CounterImpl {
    fn increment_by(&mut self, num: u32) -> u32 {
        self.count += 1;
        self.count
    }
}

Input Schema and Output Schema and different AI behaviours.

Note that in OpenAI, I couldn't see it really considering output-schema. It did care about input-schema, and I could actually see the final response (json value). This questions whether our output schema works. This may or may not be our problem, and the only way to test this manually doing a handshaking following MCP protocol and see if the response schema is detailed. And for us it works.

See this #2833 (comment)

environment_id UUID NOT NULL,
deployment_revision_id BIGINT NOT NULL,
domain TEXT NOT NULL,
agent_type_implementers TEXT NOT NULL,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change this.

@afsalthaj
Copy link
Contributor Author

The way we are going to write integration test is as follows:
We acting as a client and we following the MCP protocol

Initialization

curl -i -X POST https://restaurant-hamburg-sims-los.trycloudflare.com/mcp \
           -H "Content-Type: application/json, text/event-stream" \
           -H "Accept: application/json, text/event-stream" \
           -d '{
         "jsonrpc": "2.0",
         "id": 1,
         "method": "initialize",
         "params": {
           "protocolVersion": "2024-11-05",
           "capabilities": {},
           "clientInfo": {
             "name": "curl-client",
             "version": "1.0.0"
           }
         }
       }'
HTTP/2 200
date: Wed, 25 Feb 2026 03:51:51 GMT
content-type: text/event-stream
server: cloudflare
cf-ray: 9d343f1f3d78d87d-MEL
cf-cache-status: DYNAMIC
cache-control: no-cache
mcp-session-id: 20718598-6ac9-4503-a683-80e999db5044

data:
id: 0
retry: 3000

data: {"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"prompts":{},"resources":{},"tools":{}},"serverInfo":{"name":"rmcp","version":"0.16.0"},"instructions":"This server provides  tools related to agent in golem and prompts. Tools: increment, decrement, get_value, say_hello, echo, sum. Prompts: example_prompt (takes a message), counter_analysis (analyzes counter state with a goal)."}}

Inititalized Notification request

curl -i -X POST https://restaurant-hamburg-sims-los.trycloudflare.com/mcp \
           -H "Content-Type: application/json" \
           -H "Accept: application/json, text/event-stream" \
           -H "Mcp-Session-Id: 20718598-6ac9-4503-a683-80e999db5044" \
           -d '{
         "jsonrpc": "2.0",
         "method": "notifications/initialized",
         "params": {}
       }'
HTTP/2 202
date: Wed, 25 Feb 2026 03:52:59 GMT
content-length: 0
server: cloudflare
cf-ray: 9d3440c56bbef0ca-MEL
cf-cache-status: DYNAMIC

And finally, a simple tool/list call

curl -X POST http://restaurant-hamburg-sims-los.trycloudflare.com/mcp \
           -H "Content-Type: application/json" \
           -H "Accept: application/json, text/event-stream" \
           -H "Mcp-Session-Id: 20718598-6ac9-4503-a683-80e999db5044" \
           -d '{
         "jsonrpc": "2.0",
         "id": 2,
         "method": "tools/list",
         "params": {}
       }'

data: {"jsonrpc":"2.0","id":2,"result":{"_meta":{"tool_meta_key":"tool_meta_value"},"tools":[{"name":"CounterAgent-increment_by","description":"","inputSchema":{"properties":{"num":{"type":"integer"}},"type":"object"},"outputSchema":{"properties":{"return-value":{"type":"integer"}},"type":"object"}}]}}
id: 0/0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Server layer with Handshake protocol

1 participant