@@ -29,7 +29,7 @@ const BaseRequestParamsSchema = z
29
29
*/
30
30
progressToken : z . optional ( ProgressTokenSchema ) ,
31
31
} )
32
- . passthrough ( ) ,
32
+ . passthrough ( )
33
33
) ,
34
34
} )
35
35
. passthrough ( ) ;
@@ -100,12 +100,15 @@ export const JSONRPCResponseSchema = z
100
100
. strict ( ) ;
101
101
102
102
/**
103
- * An incomplete set of error codes that may appear in JSON-RPC responses.
103
+ * @author : Sumitesh Naithani
104
+ * @link : https://docs.trafficserver.apache.org/en/latest/developer-guide/jsonrpc/jsonrpc-node-errors.en.html#standard-errors
105
+ * @description : An incomplete set of error codes that may appear in JSON-RPC responses.
106
+ * @note : SDK-specific errors should use the server error range (-32000 to -32099), as per JSON-RPC 2.0 specification.
104
107
*/
105
108
export enum ErrorCode {
106
- // SDK error codes
107
- ConnectionClosed = - 1 ,
108
- RequestTimeout = - 2 ,
109
+ // SDK error codes (using server error range)
110
+ ConnectionClosed = - 32000 ,
111
+ RequestTimeout = - 32001 ,
109
112
110
113
// Standard JSON-RPC error codes
111
114
ParseError = - 32700 ,
@@ -214,7 +217,7 @@ export const ClientCapabilitiesSchema = z
214
217
*/
215
218
listChanged : z . optional ( z . boolean ( ) ) ,
216
219
} )
217
- . passthrough ( ) ,
220
+ . passthrough ( )
218
221
) ,
219
222
} )
220
223
. passthrough ( ) ;
@@ -258,7 +261,7 @@ export const ServerCapabilitiesSchema = z
258
261
*/
259
262
listChanged : z . optional ( z . boolean ( ) ) ,
260
263
} )
261
- . passthrough ( ) ,
264
+ . passthrough ( )
262
265
) ,
263
266
/**
264
267
* Present if the server offers any resources to read.
@@ -276,7 +279,7 @@ export const ServerCapabilitiesSchema = z
276
279
*/
277
280
listChanged : z . optional ( z . boolean ( ) ) ,
278
281
} )
279
- . passthrough ( ) ,
282
+ . passthrough ( )
280
283
) ,
281
284
/**
282
285
* Present if the server offers any tools to call.
@@ -289,7 +292,7 @@ export const ServerCapabilitiesSchema = z
289
292
*/
290
293
listChanged : z . optional ( z . boolean ( ) ) ,
291
294
} )
292
- . passthrough ( ) ,
295
+ . passthrough ( )
293
296
) ,
294
297
} )
295
298
. passthrough ( ) ;
@@ -480,7 +483,7 @@ export const ListResourcesResultSchema = PaginatedResultSchema.extend({
480
483
export const ListResourceTemplatesRequestSchema = PaginatedRequestSchema . extend (
481
484
{
482
485
method : z . literal ( "resources/templates/list" ) ,
483
- } ,
486
+ }
484
487
) ;
485
488
486
489
/**
@@ -508,7 +511,7 @@ export const ReadResourceRequestSchema = RequestSchema.extend({
508
511
*/
509
512
export const ReadResourceResultSchema = ResultSchema . extend ( {
510
513
contents : z . array (
511
- z . union ( [ TextResourceContentsSchema , BlobResourceContentsSchema ] ) ,
514
+ z . union ( [ TextResourceContentsSchema , BlobResourceContentsSchema ] )
512
515
) ,
513
516
} ) ;
514
517
@@ -747,7 +750,7 @@ export const ListToolsResultSchema = PaginatedResultSchema.extend({
747
750
*/
748
751
export const CallToolResultSchema = ResultSchema . extend ( {
749
752
content : z . array (
750
- z . union ( [ TextContentSchema , ImageContentSchema , EmbeddedResourceSchema ] ) ,
753
+ z . union ( [ TextContentSchema , ImageContentSchema , EmbeddedResourceSchema ] )
751
754
) ,
752
755
isError : z . boolean ( ) . default ( false ) . optional ( ) ,
753
756
} ) ;
@@ -758,7 +761,7 @@ export const CallToolResultSchema = ResultSchema.extend({
758
761
export const CompatibilityCallToolResultSchema = CallToolResultSchema . or (
759
762
ResultSchema . extend ( {
760
763
toolResult : z . unknown ( ) ,
761
- } ) ,
764
+ } )
762
765
) ;
763
766
764
767
/**
@@ -919,7 +922,7 @@ export const CreateMessageResultSchema = ResultSchema.extend({
919
922
* The reason why sampling stopped.
920
923
*/
921
924
stopReason : z . optional (
922
- z . enum ( [ "endTurn" , "stopSequence" , "maxTokens" ] ) . or ( z . string ( ) ) ,
925
+ z . enum ( [ "endTurn" , "stopSequence" , "maxTokens" ] ) . or ( z . string ( ) )
923
926
) ,
924
927
role : z . enum ( [ "user" , "assistant" ] ) ,
925
928
content : z . discriminatedUnion ( "type" , [
@@ -1104,7 +1107,7 @@ export class McpError extends Error {
1104
1107
constructor (
1105
1108
public readonly code : number ,
1106
1109
message : string ,
1107
- public readonly data ?: unknown ,
1110
+ public readonly data ?: unknown
1108
1111
) {
1109
1112
super ( `MCP error ${ code } : ${ message } ` ) ;
1110
1113
}
0 commit comments