Repository navigation
Conversation
For tools/call requests, the middleware unmarshaled the entire arguments payload into map[string]any just to extract owner and repo. This allocates a map and deep-parses the full JSON on every tool call. Replace with a typed struct containing only the owner and repo fields. This reduces allocations and CPU on the hot request path. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
There was a problem hiding this comment.
🟡 Changes recommended
The new typed unmarshal can change extraction behavior for partially malformed arguments (and the exported struct field removal is a breaking API change).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR optimizes the WithMCPParse HTTP middleware hot path by avoiding full map[string]any allocation/parsing when extracting owner/repo from tools/call request arguments, and adjusts context/test structures accordingly.
Changes:
- Switch
tools/callargument parsing frommap[string]anyto a small typed decode forowner/repo. - Remove
MCPMethodInfo.Argumentsfrom the context payload and update tests to stop asserting it. - Keep existing behavior for invalid JSON by continuing without parsed fields.
File summaries
| File | Description |
|---|---|
| pkg/http/middleware/mcp_parse.go | Changes argument parsing to avoid full map allocation in tools/call handling. |
| pkg/http/middleware/mcp_parse_test.go | Updates tests to align with the new parsing strategy and removed context field. |
| pkg/context/mcp_info.go | Removes the Arguments field from MCPMethodInfo. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Closing as duplicate of #10, which implements the identical fix with a slightly clearer comment. Both PRs independently arrived at the same solution: replacing the full map[string]any argument unmarshal with a typed struct containing only owner and |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Daigrin <198701947+Daigrin@users.noreply.github.com>
Co-authored-by: Daigrin <198701947+Daigrin@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: Daigrin <198701947+Daigrin@users.noreply.github.com>
Resolved the merge conflicts in commit |
Co-authored-by: Daigrin <198701947+Daigrin@users.noreply.github.com>
Problem
For every ools/call request, the MCP parse middleware unmarshaled the entire �rguments JSON payload into map[string]any just to extract the owner and
epo fields. This allocates a map and deep-parses the full arguments document on every tool call — the server hot path.
Solution
Replace the map[string]any unmarshal with a small typed struct containing only the owner and
epo fields. The JSON decoder still skips unknown fields, but we avoid:
Changes
Validation
epo for downstream use
Note: Go toolchain was not available in the development environment for local build/test verification. The change is a mechanical refactoring with no logic changes.