• Uncategorised
  • 0

Understanding MCP Client-Server Communication in ColdFusion

In a modern AI-assisted development environment, the Model Context Protocol (MCP) facilitates interaction between tools like Cursor VSCode and a backend server written in ColdFusion. Let’s walk through how an MCP client initializes communication, what it expects from the server, and how the server should respond—using logs and real interactions as our guide.


🔁 1. Initialization Sequence

The MCP client begins by sending an initialize request. Here’s a typical log of this:

Method: initialize
ID: 0
Raw Body:
{
"method": "initialize",
"params": {
"protocolVersion": "2025-03-26",
"capabilities": {
"tools": true,
"prompts": false,
"resources": true,
"logging": false,
"roots": { "listChanged": false }
},
"clientInfo": {
"name": "cursor-vscode",
"version": "1.0.0"
}
},
"jsonrpc": "2.0",
"id": 0
}

✅ Expected Response:

The server should return supported capabilities and server info:

{
"jsonrpc": "2.0",
"id": 0,
"result": {
"capabilities": {
"tools": true,
"prompts": false,
"resources": true,
"logging": false,
"roots": { "listChanged": false }
},
"serverInfo": {
"name": "MyMCPServer",
"version": "1.0.0"
}
}
}

✅ 2. Notifications: notifications/initialized

Shortly after initialize, the client sends a non-blocking notification to indicate it’s ready.

Method: notifications/initialized

✅ Expected Response:

A simple empty success object suffices:

{ "jsonrpc": "2.0", "id": 1, "result": {} }

🧰 3. Tool Listing: tools/list

Once initialized, the client queries for available tools:

Method: tools/list
ID: 1

✅ Expected Response:

The server should respond with a list of tools, each with a valid schema:

{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"name": "echo",
"description": "Echoes input",
"inputSchema": {
"type": "object",
"properties": {
"message": { "type": "string" }
},
"required": ["message"]
}
}
]
}

🔧 4. tools/call: Invoking a Specific Tool

Once the MCP client fetches the list of tools via tools/list, it calls a tool using the tools/call method, not the tool’s name directly.

📨 Example Request

{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "echo",
"arguments": {
"message": "Hello from client"
}
}
}

🔁 Expected Server Behavior

The server should:

  1. Read params.name to identify the tool.
  2. Use params.arguments as the input.
  3. Call the appropriate handler.
  4. Return a result.

✅ Example Response

{
"jsonrpc": "2.0",
"id": 2,
"result": {
"message": "Hello from client"
}
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *