-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Labels
Description
Objective
Add a newMCPError helper function to reduce the 30+ repeated &jsonrpc.Error{Code: ..., Message: ..., Data: ...} literals scattered across MCP tool files.
Context
From discussion #18080 (go-sdk module review): The tool files (mcp_tools_readonly.go, mcp_tools_privileged.go, mcp_tools_management.go) contain many duplicated jsonrpc.Error struct literals. A small helper function would reduce repetition, enforce consistent error patterns, and make future error format changes easier.
Files to Modify
pkg/cli/mcp_server_helpers.go— add the helper functionpkg/cli/mcp_tools_readonly.go— replace error literals with helper callspkg/cli/mcp_tools_privileged.go— replace error literals with helper callspkg/cli/mcp_tools_management.go— replace error literals with helper calls
Implementation
// In mcp_server_helpers.go
func newMCPError(code int, msg string, data any) error {
return &jsonrpc.Error{Code: code, Message: msg, Data: mcpErrorData(data)}
}Replace all &jsonrpc.Error{...} literals with newMCPError(...) calls where there's an existing mcpErrorData helper or equivalent.
Acceptance Criteria
-
newMCPErrorhelper added tomcp_server_helpers.go - All (or majority of)
&jsonrpc.Error{...}literals in tool files replaced withnewMCPError(...)calls - No behavioral changes — error codes and messages remain identical
-
make test-unitpasses -
make agent-finishpasses
Generated by Plan Command for issue #discussion #18080
- expires on Feb 27, 2026, 12:38 PM UTC
Reactions are currently unavailable