Skip to content

Using an MCP client to call the @modelcontextprotocol/server-filesystem server, a parameter validation error occurs #3815

@applesline

Description

@applesline

Describe the bug
When using an MCP client to call the @modelcontextprotocol/server-filesystem server, a parameter validation error occurs. The server incorrectly expects a name field in the params object, but according to the MCP protocol, name should be at the top level of the call object.

To Reproduce
Steps to reproduce the behavior:

  1. Install required packages:
npm install @mcpilotx/sdk-core
  1. Create reproduction script reproduce-bug.js:
const { MCPClient, createMCPConfig } = require('@mcpilotx/sdk-core');

async function reproduceBug() {
  const config = createMCPConfig('stdio', {
    command: 'npx',
    args: ['@modelcontextprotocol/server-filesystem', '.'],
    autoConnect: false,
    timeout: 10000
  });
  
  const client = new MCPClient(config);
  await client.connect();
  
  try {
    const result = await client.callTool('read_text_file', {
      path: './package.json'
    });
    console.log('Success:', result);
  } catch (error) {
    console.log('Error message:', error.message);
    console.log('Full error:', error);
  }
  
  await client.disconnect();
}

reproduceBug();
  1. Run the script:
node reproduce-bug.js
  1. Observe the error output.

Expected behavior
According to the MCP protocol specification, the correct structure for a tool call request should be:

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "tools/call",
  "params": {
    "call": {
      "name": "read_text_file",
      "arguments": {
        "path": "./package.json"
      }
    }
  }
}

The name field should be in the params.call object, not directly in the params object.

Logs
Running the reproduction script produces the following error:

Error message: [
  {
    "expected": "string",
    "code": "invalid_type",
    "path": [
      "params",
      "name"
    ],
    "message": "Invalid input: expected string, received undefined"
  }
]

The error message shows that the server is validating params.name, which indicates the server expects the name field to be directly in the params object, not in params.call.

Additional context

  • MCP Protocol Reference: According to the Model Context Protocol specification, the params object of a tool call request should contain a call field, and the call field contains name and arguments
  • Impact Scope: This bug affects all tool calls to @modelcontextprotocol/server-filesystem using standard MCP clients
  • Workaround: Currently no workaround is available as this is a server-side validation logic issue
  • Test Environment:
    • Node.js version: v22.17.1
    • @modelcontextprotocol/server-filesystem version: Unknown (npx doesn't show version with --version flag)
    • Operating System: macOS
    • MCP Client: @mcpilotx/sdk-core 0.3.3
  • Note: The server successfully connects and lists 14 available tools, but all tool calls fail with the same validation error

Suggested Fix
Fix the server-side parameter validation logic to correctly parse MCP protocol request structure:

  1. Validate params.call.name instead of params.name
  2. Ensure compliance with MCP protocol specification

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions