Skip to content

Inconsistency in types.py schema for RequestParams #913

Closed as not planned
Closed as not planned

Description

@lucasng32

Describe the bug

Not sure if I'm missing something, but I found that I was unable to add extra fields to RequestParams in the MCP Python schema in types.py (e.g., I'm trying to pass auth tokens along for ListToolsRequest). The Python MCP schema ignores extra fields at the top level of RequestParams, but the TypeScript MCP schema does not.

To Reproduce

Try to create a RequestParams instance with an extra field at the top level (not inside meta), e.g.:

RequestParams(foo="bar", meta=None)

The additional field foo is ignored.

Expected behavior

Extra fields at the top level of RequestParams should be accepted, matching the TypeScript schema’s behavior.

Additional context

  • The TypeScript interface allows arbitrary extra fields at the top level of params via:
export interface Request {
  method: string;
  params?: {
    _meta?: {
      progressToken?: ProgressToken;
    };
    [key: string]: unknown;
  };
}
  • The Python class only allows extra fields inside the Meta class:
class RequestParams(BaseModel):
    class Meta(BaseModel):
        progressToken: ProgressToken | None = None
        model_config = ConfigDict(extra="allow")
    meta: Meta | None = Field(alias="_meta", default=None)

Activity

  1. pyrotank41 commented on Jun 22, 2025

    @pyrotank41

    this PR might help: #1003

  2. added
    needs confirmationNeeds confirmation that the PR is actually required or needed.
    enhancementRequest for a new feature that's not currently supported
    on Sep 26, 2025
  3. added
    ready for workEnough information for someone to start working on
    P3Nice to haves, rare edge cases
    improves sdk consistencyImproves consistency with other SDKs such as Tyepscript
    and removed
    needs confirmationNeeds confirmation that the PR is actually required or needed.
    on Oct 6, 2025
  4. Br1an67 commented on Mar 1, 2026

    @Br1an67

    I'd like to work on this. The fix adds model_config = ConfigDict(extra="allow") to RequestParams, matching the TypeScript SDK's [key: string]: unknown behavior.

    PR: #2188

  5. maxisbey commented on Mar 5, 2026

    @maxisbey
    Contributor

    Closing — this was based on the 2025-06-18 schema which did have an index signature on Request.params, but it was deliberately removed in the 2025-11-25 spec as an intentional breaking change (described by the spec author as fixing "a bug that allows usage of arbitrary params").

    For your use case (passing auth tokens with ListToolsRequest), _meta is the spec-sanctioned extension point — it already supports extra fields in this SDK via extra_items=Any.

    AI Disclaimer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedimproves sdk consistencyImproves consistency with other SDKs such as Tyepscriptready for workEnough information for someone to start working on

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions