Skip to content

Additional parameters are not passed through to tools #147

Description

@au-re

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#"
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Moderate issues affecting some users, edge cases, potentially valuable featurebugSomething isn't workingfix proposedBot has a verified fix diff in the commentready for workEnough information for someone to start working on

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions