Fix stdio mode panic: inject ToolDependencies into request context#1647
Merged
SamMorrowDrums merged 2 commits intomainfrom Dec 18, 2025
Merged
Fix stdio mode panic: inject ToolDependencies into request context#1647SamMorrowDrums merged 2 commits intomainfrom
SamMorrowDrums merged 2 commits intomainfrom
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>
Copilot
AI
changed the title
[WIP] Fix stdio mode panics for tool dependencies
Fix stdio mode panic: inject ToolDependencies into request context
Dec 18, 2025
SamMorrowDrums
approved these changes
Dec 18, 2025
Contributor
There was a problem hiding this comment.
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 via github.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 |
23 tasks
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.
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 agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.