- Notifications
You must be signed in to change notification settings - Fork3.3k
Fix stdio mode panic: inject ToolDependencies into request context#1647
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
The issue was that after PR#1640 switched from closure-based deps to context-based deps,the stdio server was missing middleware to inject ToolDependencies into the request context.This caused tools to panic with "ToolDependencies not found in context" when called.Added middleware in NewMCPServer() that wraps all requests with github.ContextWithDeps(),ensuring deps are available to tool handlers via MustDepsFromContext().Also added tests to verify server creation and toolset resolution logic.Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
311d581 intomainUh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull request overview
This PR fixes a critical panic in stdio mode that occurs when any tool is called. The panic was introduced after refactoring to context-based dependency injection, where middleware to inject dependencies into the request context was inadvertently omitted.
Key changes:
- Added middleware in
NewMCPServer()to injectToolDependenciesinto the request context for all tool handlers - Added comprehensive tests for server creation and toolset resolution logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/ghmcp/server.go | Adds middleware after line 205 to inject deps into context viagithub.ContextWithDeps(ctx, deps) for all tool handlers |
| internal/ghmcp/server_test.go | Adds new test file with tests for server creation (verifying middleware is configured) and toolset resolution logic |
Uh oh!
There was an error while loading.Please reload this page.
Summary
Stdio server panics with "ToolDependencies not found in context" on tool calls. After deps were refactored to context-based injection, middleware to inject them was missing.
Why
Tool handlers call
MustDepsFromContext(ctx)but no middleware injects deps into the request context.What changed
NewMCPServer()that wraps requests withgithub.ContextWithDeps(ctx, deps)MCP impact
Prompts tested (tool changes only)
Security / limits
Lint & tests
./script/lint./script/testDocs
Original prompt
✨ Let Copilot coding agentset things up for you — coding agent works faster and does higher quality work when set up for your repo.