@@ -116,6 +116,7 @@ export function wrapTransportError(transport: MCPTransport): void {
116
116
117
117
/**
118
118
* Captures JSON-RPC error responses
119
+ * Only captures server-side errors, not client validation errors
119
120
*/
120
121
function captureJsonRpcErrorResponse (
121
122
errorResponse : unknown ,
@@ -126,13 +127,20 @@ function captureJsonRpcErrorResponse(
126
127
if ( errorResponse && typeof errorResponse === 'object' && 'code' in errorResponse && 'message' in errorResponse ) {
127
128
const jsonRpcError = errorResponse as { code : number ; message : string ; data ?: unknown } ;
128
129
129
- const error = new Error ( jsonRpcError . message ) ;
130
- error . name = `JsonRpcError_${ jsonRpcError . code } ` ;
130
+ // Only capture server-side errors, not client validation errors
131
+ // Per JSON-RPC 2.0 error object spec:
132
+ // https://www.jsonrpc.org/specification#error_object
133
+ const isServerError = jsonRpcError . code === - 32603 || ( jsonRpcError . code >= - 32099 && jsonRpcError . code <= - 32000 ) ;
131
134
132
- captureError ( error , 'protocol' ) ;
135
+ if ( isServerError ) {
136
+ const error = new Error ( jsonRpcError . message ) ;
137
+ error . name = `JsonRpcError_${ jsonRpcError . code } ` ;
138
+
139
+ captureError ( error , 'protocol' ) ;
140
+ }
133
141
}
134
142
} catch {
135
- // Silently ignore capture errors
143
+ // noop
136
144
}
137
145
}
138
146
@@ -143,6 +151,6 @@ function captureTransportError(error: Error, _transport: MCPTransport): void {
143
151
try {
144
152
captureError ( error , 'transport' ) ;
145
153
} catch {
146
- // Silently ignore capture errors
154
+ // noop
147
155
}
148
156
}
0 commit comments