Skip to content
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

[server-google-maps][server-github] Does not work with 1.0.0 SDK #94

Closed
mbleigh opened this issue Nov 27, 2024 · 2 comments
Closed

[server-google-maps][server-github] Does not work with 1.0.0 SDK #94

mbleigh opened this issue Nov 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mbleigh
Copy link

mbleigh commented Nov 27, 2024

Describe the bug
Trying to call tools in the Google Maps server fail with Zod validation errors when using the MCP 1.0 SDK. It appears that the issue is that an older version of the protocol returned {toolResponse: {content: [...]}} instead of just {content: [...]}.

To Reproduce
Steps to reproduce the behavior:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";

const client = new Client(
  {
    name: "maps",
    version: "1.0.0",
  },
  { capabilities: { tools: {} } }
);

const transport = new StdioClientTransport({
  command: "npx",
  args: ["-y", "@modelcontextprotocol/server-google-maps"],
  env: {
    ...process.env,
    GOOGLE_MAPS_API_KEY: "A_VALID_KEY",
  },
});
await client.connect(transport);
const result = await client.callTool({
  name: "maps_search_places",
  arguments: { query: "bookstores near 94552" },
});

console.log(result);

Expected behavior
The tool is called successfully.

Logs

ZodError: [
  {
    "code": "invalid_type",
    "expected": "array",
    "received": "undefined",
    "path": [
      "content"
    ],
    "message": "Required"
  }
]
    at get error (file:///Users/bleigh/sandbox/mcp-bug/node_modules/zod/lib/index.mjs:587:31)
    at ZodObject.parse (file:///Users/bleigh/sandbox/mcp-bug/node_modules/zod/lib/index.mjs:692:22)
    at file:///Users/bleigh/sandbox/mcp-bug/node_modules/@modelcontextprotocol/sdk/dist/shared/protocol.js:212:49
    at Client._onresponse (file:///Users/bleigh/sandbox/mcp-bug/node_modules/@modelcontextprotocol/sdk/dist/shared/protocol.js:153:13)
    at _transport.onmessage (file:///Users/bleigh/sandbox/mcp-bug/node_modules/@modelcontextprotocol/sdk/dist/shared/protocol.js:45:22)
    at StdioClientTransport.processReadBuffer (file:///Users/bleigh/sandbox/mcp-bug/node_modules/@modelcontextprotocol/sdk/dist/client/stdio.js:117:79)
    at Socket.<anonymous> (file:///Users/bleigh/sandbox/mcp-bug/node_modules/@modelcontextprotocol/sdk/dist/client/stdio.js:92:22)
    at Socket.emit (node:events:519:28)
    at addChunk (node:internal/streams/readable:561:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3) {
  issues: [
    {
      code: 'invalid_type',
      expected: 'array',
      received: 'undefined',
      path: [ 'content' ],
      message: 'Required'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)],
  errors: [
    {
      code: 'invalid_type',
      expected: 'array',
      received: 'undefined',
      path: [ 'content' ],
      message: 'Required'
    }
  ]
}

Node.js v22.9.0

Additional context
Add any other context about the problem here.

@mbleigh mbleigh added the bug Something isn't working label Nov 27, 2024
@mbleigh mbleigh changed the title [server-google-maps] Does not work with 1.0.0 SDK [server-google-maps][server-github] Does not work with 1.0.0 SDK Nov 27, 2024
@dsp-ant
Copy link
Member

dsp-ant commented Nov 28, 2024

Thank you for spotting this!

I created #107 . Some servers depend on old versions of the SDK using an old version of the protocol before the initial release. There is a backwards compatibility layer , but it doesn't auto detect the protocol version, which it should.
The following code will work:

const result = await client.callTool({
  name: "maps_search_places",
  arguments: { query: "bookstores near 94552" },
},CompatibilityCallToolResultSchema );

against old versions.

@jspahrsummers
Copy link
Member

Resolved by #176.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants