8000 Inconsistency in `types.py` schema for `RequestParams` · Issue #913 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content
Inconsistency in types.py schema for RequestParams #913
Open
@lucasng32

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 sche 58AE ma’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)

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

      0