-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(cli): migrate exp mcp stdio server to official MCP Go SDK #28057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,6 +63,12 @@ func TestExpMcpServer(t *testing.T) { | |
| assert.NoError(t, err) | ||
| }() | ||
|
|
||
| // The SDK server enforces the MCP lifecycle, so complete the | ||
| // initialize handshake before listing tools. | ||
| stdin.WriteLine(`{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}`) | ||
| _ = stdout.ReadLine(ctx) | ||
| stdin.WriteLine(`{"jsonrpc":"2.0","method":"notifications/initialized"}`) | ||
|
|
||
| // When: we send a tools/list request | ||
| toolsPayload := `{"jsonrpc":"2.0","id":2,"method":"tools/list"}` | ||
| stdin.WriteLine(toolsPayload) | ||
|
|
@@ -140,7 +146,7 @@ func TestExpMcpServer(t *testing.T) { | |
| assert.NoError(t, err) | ||
| }() | ||
|
|
||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize"}` | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}` | ||
| stdin.WriteLine(payload) | ||
| output := stdout.ReadLine(ctx) | ||
| cancel() | ||
|
|
@@ -588,7 +594,7 @@ func TestExpMcpServerOptionalUserToken(t *testing.T) { | |
| }() | ||
|
|
||
| // Verify server starts by checking for a successful initialization | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize"}` | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}` | ||
| stdin.WriteLine(payload) | ||
| output := stdout.ReadLine(ctx) | ||
|
|
||
|
|
@@ -1005,7 +1011,7 @@ func TestExpMcpReporter(t *testing.T) { | |
| }() | ||
|
|
||
| // Initialize. | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize"}` | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The official SDK enforces the MCP initialization lifecycle, but both reporter test paths send Useful? React with 👍 / 👎. |
||
| stdin.WriteLine(payload) | ||
| _ = stdout.ReadLine(ctx) // ignore init response | ||
|
|
||
|
|
@@ -1112,7 +1118,7 @@ func TestExpMcpReporter(t *testing.T) { | |
| clitest.Start(t, inv) | ||
|
|
||
| // Initialize. | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize"}` | ||
| payload := `{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}` | ||
| stdin.WriteLine(payload) | ||
| _ = stdout.ReadLine(ctx) // ignore init response | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an MCP client omits the optional
argumentsfield while calling a zero-input tool such ascoder_get_authenticated_userorcoder_list_templates,RegisterSDKToolforwards the resulting niljson.RawMessagetotoolsdk.Generic, whosejson.Unmarshalfails with an unexpected end of input. The previousmcpFromSDKadapter encoded the nil arguments map as JSONnull, which successfully decoded intoNoArgs; normalize missing arguments to{}ornullbefore invoking the shared handler.Useful? React with 👍 / 👎.