Skip to content

Bug: request_meta is not available in server.request_context #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phact opened this issue Dec 17, 2024 · 0 comments
Closed

Bug: request_meta is not available in server.request_context #103

phact opened this issue Dec 17, 2024 · 0 comments

Comments

@phact
Copy link

phact commented Dec 17, 2024

Describe the bug
This makes it impossible to build a server with progress notifications

To Reproduce
Steps to reproduce the behavior:
do a tool_call for example:

{
"method": "tools/call",
"params": {
"name": "6a41a978-0a31-4eaf-9d0c-431a5f784bc9",
"arguments": {
"input_value": "3*2"
},
"_meta": {
"progressToken": 0
}
}
}

server.request_context.meta is None

Expected behavior
meta should include the progressToken

It's not getting assigned here https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/server/__init__.py#L447

phact added a commit to phact/python-sdk that referenced this issue Dec 17, 2024
Fixes modelcontextprotocol#103

Fix the issue where `server.request_context.meta` does not include the `progressToken`.

* **Extract `_meta` field**: Extract the `_meta` field from request parameters and assign it to `message.request_meta` in `src/mcp/server/__init__.py`.
* **Update `RequestContext`**: Update `RequestContext` instantiation to include `progressToken` in `src/mcp/server/__init__.py`.
* **Allow extra fields**: Update `RequestParams` instantiation to include `model_config = ConfigDict(extra="allow")` in `src/mcp/types.py`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/modelcontextprotocol/python-sdk/issues/103?shareId=XXXX-XXXX-XXXX-XXXX).
dsp-ant added a commit that referenced this issue Dec 21, 2024
Pydantic treats fields starting with underscore as private/hidden. To fix this,
we need to use Field with alias='_meta' to properly handle these fields while
keeping the external API unchanged. This fixes #103 where meta fields were not
being properly assigned in request contexts.
dsp-ant added a commit that referenced this issue Dec 21, 2024
Pydantic treats fields starting with underscore as private/hidden. To fix this,
we need to use Field with alias='_meta' to properly handle these fields while
keeping the external API unchanged. This fixes #103 where meta fields were not
being properly assigned in request contexts.
dsp-ant added a commit that referenced this issue Dec 21, 2024
Fix Bug: request_meta is not available in server.request_context #103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant