modelcontextprotocol / modelcontextprotocol/typescript-sdk

Additional parameters are not passed through to tools

Open
#147 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug fix proposed P2 ready for work
Dominant language
TypeScript
Stars
13.4k
Forks
2.2k
Avg merge
3d 15h
Merged PRs (30d)
4

Description

Describe the bug
When you pass properties in the arguments of a tools/call message that are not defined in the schema, these are silently dropped from the args object.

To Reproduce

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { z } from "zod";

const echoServer = new McpServer({
  name: "Echo",
  version: "1.0.0",
});

const schema = {
  message: z.string().describe("the message to echo"),
};

echoServer.tool("echo", "Echos the input message back", schema, async (args) => {
  console.log({ args });
  return { content: [{ type: "text", text: `Echo: ${props.message}` }] };
});

Call the echo tool with e.g.

{
  "method": "tools/call",
  "params": {
    "name": "echo",
    "arguments": {
      "message": "bar"
      "other": "foo"
    },
    "_meta": {
      "progressToken": 0
    }
  }
}

args will be { message: "bar" }

Expected behavior
It should be possible to pass additional properties to the tool.
This is the JSON Schema generated on the server, by default additionalProperties is set to true.

{
  "tools": [
    {
      "name": "echo",
      "description": "Echos the input message back",
      "inputSchema": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "the message to echo"
          }
        },
        "required": [
          "message"
        ],
        "additionalProperties": true,
        "$schema": "http://json-schema.org/draft-07/schema#"
      }
    }
  ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript SDK path handling the tools/call request and inspect how the tool schema parses its arguments. Reproduce the example with message and other, then verify that the resulting args object preserves the additional property while schema validation still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.