-
Notifications
You must be signed in to change notification settings - Fork 35
Implement standardized MCP error codes using jsonrpc.Error #7769
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
Conversation
Co-authored-by: mnkiefer <[email protected]>
Co-authored-by: mnkiefer <[email protected]>
| return nil, nil, &jsonrpc.Error{ | ||
| Code: jsonrpc.CodeInternalError, | ||
| Message: "request cancelled", | ||
| Data: mcpErrorData(ctx.Err().Error()), |
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.
@copilot you cannot leak internal error data for security reasons.
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.
Fixed in 7c8a907. Removed internal error data from all error responses:
- No command output exposed
- No internal error messages exposed
- Only user-provided input (jq filters, run_id) included in Data field
All error code tests still passing.
- Remove command output from error Data fields - Remove internal error messages from error Data fields - Keep only user-provided input (jq filters, run_id) in Data - Prevents leaking sensitive information like tokens, paths, system details Co-authored-by: pelikhan <[email protected]>
|
@copilot revert last commit |
…ity" This reverts commit 7c8a907. Restoring internal error data in MCP error responses as requested. Co-authored-by: pelikhan <[email protected]>
MCP server tool handlers returned generic errors wrapped in
mcp.CallToolResult. This prevented MCP clients from distinguishing between parameter validation errors and internal failures.Changes
Error Infrastructure
mcpErrorData()helper to marshal error context tojson.RawMessageCallToolResulterror returns withjsonrpc.Errorusing standard codesError Classification
InvalidParams (-32602): Missing required parameters, conflicting flags, invalid jq filtersInternalError (-32603): Command execution failures, Docker preparation, context cancellationError Context
Datafield includes error details, command output, and user-provided input for debuggingExample
Before:
After:
Parameter validation with context:
Testing
Added
mcp_server_error_codes_test.gowith integration tests covering:Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.