Repository navigation
fix(iam-mcp-server): inject ctx instead of requiring it - #4838
Open
mangeshraut712 wants to merge 7 commits into
Open
mangeshraut712 wants to merge 7 commits into
mangeshraut712 wants to merge 7 commits into
Conversation
3 of 6 tasks
Contributor
Author
|
Fixes #4675 Why: What: Annotate as Test: |
Contributor
Author
|
CI is green. Injects ctx instead of requiring it on the IAM tools. Please review and merge when you can. |
list_users, get_user, and create_user annotated ctx as CallToolResult, so the SDK treated it as a required argument and every call failed with "ctx Field required". Annotate ctx as the MCP Context so the server injects it.
mangeshraut712
force-pushed
the
cursor/iam-mcp-ctx-field-ed4d
branch
from
October 27, 2026 14:24
f64d0cf to
9e554ef
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4675
Problem
list_users,get_user, andcreate_userannotatedctxasCallToolResult. Because the MCP SDK only injects parameters annotated with itsContexttype, it exposedctxas a required client argument and calls failed withctx Field required.Change
Annotate those parameters as
mcp.server.mcpserver.Context, imported asMcpContextto avoid colliding with the server-localContextclass. The SDK now injects the request context instead of publishing it in the tool schema.As a result:
list_usersaccepts an empty argument object.get_userandcreate_userrequire onlyuser_nameamong the affected required inputs.Verification
test_user_tools_do_not_require_ctxverifies thatctxis absent from each public tool schema and invokes all three tools throughmcp.call_toolwithout a client-supplied context.src/iam-mcp-server/run_tests.shpassed: Ruff lint and format checks, Pyright with 0 errors, and 232 passing tests.Compatibility
No breaking API change.
Checklist
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.