https://promptfoo.dev/ logo
Problem with MCP call
# ❓|questions
m
Title: MCP Server Returns Invalid Tool Schema -
outputSchema.additionalProperties
Must Be Boolean Description: I'm encountering a validation error when connecting to an MCP server via Streamable HTTP transport. The connection succeeds and ping works, but the
listTools()
call fails with a schema validation error. Error Message:
Copy code
Failed to connect to MCP server web-search: [
  {
    "code": "invalid_type",
    "expected": "boolean",
    "received": "object",
    "path": [
      "tools",
      0,
      "outputSchema",
      "additionalProperties"
    ],
    "message": "Expected boolean, received object"
  }
]
Problem: The MCP server at
http://ipaddress:80/mcp
is returning tool definitions where
outputSchema.additionalProperties
is an object (e.g.,
{ type: "string" }
), but according to JSON Schema specification and the MCP SDK's validation,
additionalProperties
must be a boolean value (
true
or
false
). Relevant Code: The error occurs in the client connection flow: - File:
src/providers/mcp/client.ts
(or
.js
in dist) - Method:
MCPClient.connectToServer()
- Line: Around line 203 (based on stack trace) - Specific operation: After
await client.connect(transport, requestOptions)
succeeds and during
await client.listTools(undefined, requestOptions)
The validation happens within the MCP SDK's
listTools()
method before the response is returned to the client code. Question: Is this a server-side issue that needs to be fixed in the MCP server implementation, or should the client SDK be more lenient and automatically coerce object-type
additionalProperties
to boolean
true
? According to JSON Schema spec,
additionalProperties
as an object is valid (it defines a schema for additional properties), but the MCP SDK appears to only accept boolean values. Configuration:
Copy code
yaml
mcp:
  enabled: true
  debug: true
  verbose: true
  pingOnConnect: true
  timeout: 120000
  servers:
    - name: web-search
      type: "streamable-http"
      url: "http://ipaddress:80/mcp"
Expected Behavior: Either: 1. The MCP server should return
additionalProperties: true
(or
false
) instead of an object, OR 2. The MCP SDK should accept object-type
additionalProperties
and handle it appropriately Workaround Needed: Is there a way to intercept and sanitize the tool schemas before SDK validation, or does this need to be fixed at the server level?
u
Hey! Promptfoo should behave just like the official MCP sdk. Could you try inspecting your MCP server with the mcp-inspector, and see if the listTools call succeeds? If so, then we can change promptfoo's behaviour to match that; otherwise you'll need to change the schema I think. More info about mcp-inspector: https://modelcontextprotocol.io/docs/tools/inspector