Skip to content

MCP full-mode tool schemas include body/upload on methods that don't support them #212

@shreyaskarnik

Description

@shreyaskarnik

Description

In full tool mode (--tool-mode full), every generated MCP tool includes body and upload properties in its inputSchema, regardless of whether the
underlying Google API method actually supports a request body or media upload.

This causes LLM clients to hallucinate values for these fields — most commonly sending "body": {} on GET-only methods (e.g., gmail_users_labels_list),
which causes Google APIs to return HTTP 400 ("Parse Error / malformed or illegal request").

Similarly, LLMs may send "upload": "" on methods that don't support media upload, triggering file-read errors.

Root Cause

In walk_resources() (src/mcp_server.rs), the tool schema is built with a static set of properties that always includes body and upload. However,
the Discovery Document already provides per-method metadata:

  • method.request — present only when the method accepts a request body
  • method.supports_media_upload — true only when the method supports media upload

This data is already surfaced by gws_discover (via the supportsMediaUpload field) but is not used to conditionally build tool schemas in full mode.

In compact mode, body and upload must remain in the schema since one tool covers all methods in a service. However, the execution layer
(execute_mcp_method) does not filter out empty/no-op values before forwarding them to the HTTP executor.

Impact

Steps to Reproduce

  1. Start MCP server: gws mcp -s gmail --tool-mode full
  2. Send a tools/call for gmail_users_labels_list with "body": {}
  3. Google API returns 400
{
  "method": "tools/call",
  "params": {
    "name": "gmail_users_labels_list",
    "arguments": {
      "params": { "userId": "me" },
      "body": {}
    }
  }
}

Proposed Fix

  1. Full mode schemas: Conditionally include body only when method.request.is_some() and upload only when method.supports_media_upload is true
  2. Execution layer (both modes): Filter out empty body objects ({}) and empty upload strings ("") in execute_mcp_method before forwarding to the HTTP
    executor

Branch with fix: https://github.com/shreyaskarnik/cli/tree/fix/mcp-tool-schema-body-upload

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions