[BUG] Crash when triggering a prompt provided by MCP

Resolved 💬 3 comments Opened Jul 15, 2025 by tomakehurst Closed Nov 30, 2025

Environment

  • Platform (select one):
  • [X] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.51
  • Operating System: macOS 15.5
  • Terminal: Terminal App

Bug Description

Triggering a prompt provided by an MCP server via /<prompt> causes Claude Code to exit immediately, printing the stacktrace pasted below.

The MCP server is written using version 0.5.0 of the official Kotlin MCP SDK.

Steps to Reproduce

  1. Install MCP server into global Claude Code settings.
  2. Run claude
  3. Start typing /<prompt name> then tab-complete it when it is shown.
  4. Press enter

Expected Behavior

Message indicating that a required prompts parameter was not specified (this particular prompt has 2 required params).

Actual Behavior

Claude Code immediately exits with the output below.

Additional Context

Stack trace on exit:

file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1336
Assistant:`;A3.DEFAULT_TIMEOUT=600000;A3.AnthropicError=hB;A3.APIError=Z6;A3.APIConnectionError=dq;A3.APIConnectionTimeoutError=st;A3.APIUserAbortError=TD;A3.NotFoundError=Ae;A3.ConflictError=Be;A3.RateLimitError=De;A3.BadRequestError=ot;A3.AuthenticationError=tt;A3.InternalServerError=Ie;A3.PermissionDeniedError=et;A3.UnprocessableEntityError=Qe;A3.toFile=KC1;class iq extends A3{constructor(){super(...arguments);this.completions=new hO(this),this.messages=new aK(this),this.models=new xm(this),this.beta=new LJ(this)}}iq.Completions=hO;iq.Messages=aK;iq.Models=xm;iq.Beta=LJ;var HG="API Error",Te="Prompt is too long",cn1="Credit balance is too low",jC1="Invalid API key · Please run /login",yC1="Invalid API key · Fix external API key",pn1="Claude AI usage limit reached",ln1="Repeated server overload with Opus model",hY="(no content)",kC1="OAuth token revoked · Please run /login",in1="Repeated 529 Overloaded errors",fm="Opus is experiencing high load, please use /model to switch to Sonnet";function xC1(A,B,Q){if(A instanceof Error&&A.message.includes(in1))return KF({content:ln1});if(A instanceof Error&&A.message.includes(fm))return KF({content:fm});if(A instanceof Z6&&A.status===429&&qB()){let D=A.headers?.get?.("anthropic-ratelimit-unified-reset"),I=Number(D)||0,Z=`${pn1}|${I}`;return KF({content:Z})}if(A instanceof Error&&A.message.includes("prompt is too long"))return KF({content:Te});if(qB()&&A instanceof Z6&&A.status===400&&A.message.toLowerCase().includes("invalid model name")&&(Cu(B)||B==="opus"))return KF({content:"Claude Opus 4 is not available with the Claude Pro plan. If you have updated your subscription plan recently, run /logout and /login for the plan to take effect."});if(A instanceof Error&&A.message.includes("Your credit balance is too low"))return KF({content:cn1});if(A instanceof Error&&A.message.toLowerCase().includes("x-api-key")){let{source:D}=QF(Q);return KF({content:D==="ANTHROPIC_API_KEY"||D==="apiKeyHelper"?yC1:jC1})}if(A instanceof Z6&&A.status===403&&A.message.includes("OAuth token has been revoked"))return KF({content:kC1});if(process.env.CLAUDE_CODE_USE_BEDROCK&&A instanceof Error&&A.message.toLowerCase().includes("model id"))return KF({content:`${HG} (${B}): ${A.message}`});if(A instanceof Error)return KF({content:`${HG}: ${A.message}`});return KF({content:HG})}function nn1(A){if(A!=="refusal")return;return E1("tengu_refusal_api_response",{}),KF({content:`${HG}: Claude Code is unable to respond to this request, which appears to violate our Usage Policy (https://www.anthropic.com/legal/aup). Please double press esc to edit your last message or start a new session for Claude Code to assist with a different task.`})}function q12(A,B){return new Set([...A].filter((Q)=>!B.has(Q)))}function $12(A,B){return A.size>0&&B.size>0&&[...A].every((Q)=>B.has(Q))}B81();var mO="2025-06-18";var fC1=[mO,"2025-03-26","2024-11-05","2024-10-07"],vC1="2.0",L12=v.union([v.string(),v.number().int()]),M12=v.string(),yxQ=v.object({progressToken:v.optional(L12)}).passthrough(),SX=v.object({_meta:v.optional(yxQ)}).passthrough(),uY=v.object({method:v.string(),params:v.optional(SX)}),Pe=v.object({_meta:v.optional(v.object({}).passthrough())}).passthrough(),UU=v.object({method:v.string(),params:v.optional(Pe)}),_X=v.object({_meta:v.optional(v.object({}).passthrough())}).passthrough(),bC1=v.union([v.string(),v.number().int()]),R12=v.object({jsonrpc:v.literal(vC1),id:bC1}).merge(uY).strict(),gC1=(A)=>R12.safeParse(A).success,O12=v.object({jsonrpc:v.literal(vC1)}).merge(UU).strict(),T12=(A)=>O12.safeParse(A).success,P12=v.object({jsonrpc:v.literal(vC1),id:bC1,result:_X}).strict(),Se=(A)=>P12.safeParse(A).success,EF;(function(A){A[A.ConnectionClosed=-32000]="ConnectionClosed",A[A.RequestTimeout=-32001]="RequestTimeout",A[A.ParseError=-32700]="ParseError",A[A.InvalidRequest=-32600]="InvalidRequest",A[A.MethodNotFound=-32601]="MethodNotFound",A[A.InvalidParams=-32602]="InvalidParams",A[A.InternalError=-32603]="InternalError"})(EF||(EF={}));var S12=v.object({jsonrpc:v.literal(vC1),id:bC1,error:v.object({code:v.number().int(),message:v.string(),data:v.optional(v.unknown())})}).strict(),_12=(A)=>S12.safeParse(A).success,wU=v.union([R12,O12,P12,S12]),nq=_X.strict(),hC1=UU.extend({method:v.literal("notifications/cancelled"),params:Pe.extend({requestId:bC1,reason:v.string().optional()})}),_e=v.object({name:v.string(),title:v.optional(v.string())}).passthrough(),j12=_e.extend({version:v.string()}),kxQ=v.object({experimental:v.optional(v.object({}).passthrough()),sampling:v.optional(v.object({}).passthrough()),elicitation:v.optional(v.object({}).passthrough()),roots:v.optional(v.object({listChanged:v.optional(v.boolean())}).passthrough())}).passthrough(),an1=uY.extend({method:v.literal("initialize"),params:SX.extend({protocolVersion:v.string(),capabilities:kxQ,clientInfo:j12})});var xxQ=v.object({experimental:v.optional(v.object({}).passthrough()),logging:v.optional(v.object({}).passthrough()),completions:v.optional(v.object({}).passthrough()),prompts:v.optional(v.object({listChanged:v.optional(v.boolean())}).passthrough()),resources:v.optional(v.object({subscribe:v.optional(v.boolean()),listChanged:v.optional(v.boolean())}).passthrough()),tools:v.optional(v.object({listChanged:v.optional(v.boolean())}).passthrough())}).passthrough(),rn1=_X.extend({protocolVersion:v.string(),capabilities:xxQ,serverInfo:j12,instructions:v.optional(v.string())}),uC1=UU.extend({method:v.literal("notifications/initialized")}),y12=(A)=>uC1.safeParse(A).success,mC1=uY.extend({method:v.literal("ping")}),fxQ=v.object({progress:v.number(),total:v.optional(v.number()),message:v.optional(v.string())}).passthrough(),dC1=UU.extend({method:v.literal("notifications/progress"),params:Pe.merge(fxQ).extend({progressToken:L12})}),cC1=uY.extend({params:SX.extend({cursor:v.optional(M12)}).optional()}),pC1=_X.extend({nextCursor:v.optional(M12)}),k12=v.object({uri:v.string(),mimeType:v.optional(v.string()),_meta:v.optional(v.object({}).passthrough())}).passthrough(),x12=k12.extend({text:v.string()}),f12=k12.extend({blob:v.string().base64()}),v12=_e.extend({uri:v.string(),description:v.optional(v.string()),mimeType:v.optional(v.string()),_meta:v.optional(v.object({}).passthrough())}),vxQ=_e.extend({uriTemplate:v.string(),description:v.optional(v.string()),mimeType:v.optional(v.string()),_meta:v.optional(v.object({}).passthrough())}),bxQ=cC1.extend({method:v.literal("resources/list")}),xy=pC1.extend({resources:v.array(v12)}),gxQ=cC1.extend({method:v.literal("resources/templates/list")}),sn1=pC1.extend({resourceTemplates:v.array(vxQ)}),hxQ=uY.extend({method:v.literal("resources/read"),params:SX.extend({uri:v.string()})}),je=_X.extend({contents:v.array(v.union([x12,f12]))}),uxQ=UU.extend({method:v.literal("notifications/resources/list_changed")}),mxQ=uY.extend({method:v.literal("resources/subscribe"),params:SX.extend({uri:v.string()})}),dxQ=uY.extend({method:v.literal("resources/unsubscribe"),params:SX.extend({uri:v.string()})}),cxQ=UU.extend({method:v.literal("notifications/resources/updated"),params:Pe.extend({uri:v.string()})}),pxQ=v.object({name:v.string(),description:v.optional(v.string()),required:v.optional(v.boolean())}).passthrough(),lxQ=_e.extend({description:v.optional(v.string()),arguments:v.optional(v.array(pxQ)),_meta:v.optional(v.object({}).passthrough())}),ixQ=cC1.extend({method:v.literal("prompts/list")}),ye=pC1.extend({prompts:v.array(lxQ)}),nxQ=uY.extend({method:v.literal("prompts/get"),params:SX.extend({name:v.string(),arguments:v.optional(v.record(v.string()))})}),on1=v.object({type:v.literal("text"),text:v.string(),_meta:v.optional(v.object({}).passthrough())}).passthrough(),tn1=v.object({type:v.literal("image"),data:v.string().base64(),mimeType:v.string(),_meta:v.optional(v.object({}).passthrough())}).passthrough(),en1=v.object({type:v.literal("audio"),data:v.string().base64(),mimeType:v.string(),_meta:v.optional(v.object({}).passthrough())}).passthrough(),axQ=v.object({type:v.literal("resource"),resource:v.union([x12,f12]),_meta:v.optional(v.object({}).passthrough())}).passthrough(),rxQ=v12.extend({type:v.literal("resource_link")}),b12=v.union([on1,tn1,en1,rxQ,axQ]),sxQ=v.object({role:v.enum(["user","assistant"]),content:b12}).passthrough(),Aa1=_X.extend({description:v.optional(v.string()),messages:v.array(sxQ)}),oxQ=UU.extend({method:v.literal("notifications/prompts/list_changed")}),txQ=v.object({title:v.optional(v.string()),readOnlyHint:v.optional(v.boolean()),destructiveHint:v.optional(v.boolean()),idempotentHint:v.optional(v.boolean()),openWorldHint:v.optional(v.boolean())}).passthrough(),exQ=_e.extend({description:v.optional(v.string()),inputSchema:v.object({type:v.literal("object"),properties:v.optional(v.object({}).passthrough()),required:v.optional(v.array(v.string()))}).passthrough(),outputSchema:v.optional(v.object({type:v.literal("object"),properties:v.optional(v.object({}).passthrough()),required:v.optional(v.array(v.string()))}).passthrough()),annotations:v.optional(txQ),_meta:v.optional(v.object({}).passthrough())}),Ba1=cC1.extend({method:v.literal("tools/list")}),ke=pC1.extend({tools:v.array(exQ)}),vm=_X.extend({content:v.array(b12).default([]),structuredContent:v.object({}).passthrough().optional(),isError:v.optional(v.boolean())}),$o4=vm.or(_X.extend({toolResult:v.unknown()})),Qa1=uY.extend({method:v.literal("tools/call"),params:SX.extend({name:v.string(),arguments:v.optional(v.record(v.unknown()))})}),AfQ=UU.extend({method:v.literal("notifications/tools/list_changed")}),g12=v.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),BfQ=uY.extend({method:v.literal("logging/setLevel"),params:SX.extend({level:g12})}),QfQ=UU.extend({method:v.literal("notifications/message"),params:Pe.extend({level:g12,logger:v.optional(v.string()),data:v.unknown()})}),DfQ=v.object({name:v.string().optional()}).passthrough(),IfQ=v.object({hints:v.optional(v.array(DfQ)),costPriority:v.optional(v.number().min(0).max(1)),speedPriority:v.optional(v.number().min(0).max(1)),intelligencePriority:v.optional(v.number().min(0).max(1))}).passthrough(),ZfQ=v.object({role:v.enum(["user","assistant"]),content:v.union([on1,tn1,en1])}).passthrough(),GfQ=uY.extend({method:v.literal("sampling/createMessage"),params:SX.extend({messages:v.array(ZfQ),systemPrompt:v.optional(v.string()),includeContext:v.optional(v.enum(["none","thisServer","allServers"])),temperature:v.optional(v.number()),maxTokens:v.number().int(),stopSequences:v.optional(v.array(v.string())),metadata:v.optional(v.object({}).passthrough()),modelPreferences:v.optional(IfQ)})}),Da1=_X.extend({model:v.string(),stopReason:v.optional(v.enum(["endTurn","stopSequence","maxTokens"]).or(v.string())),role:v.enum(["user","assistant"]),content:v.discriminatedUnion("type",[on1,tn1,en1])}),FfQ=v.object({type:v.literal("boolean"),title:v.optional(v.string()),description:v.optional(v.string()),default:v.optional(v.boolean())}).passthrough(),YfQ=v.object({type:v.literal("string"),title:v.optional(v.string()),description:v.optional(v.string()),minLength:v.optional(v.number()),maxLength:v.optional(v.number()),format:v.optional(v.enum(["email","uri","date","date-time"]))}).passthrough(),WfQ=v.object({type:v.enum(["number","integer"]),title:v.optional(v.string()),description:v.optional(v.string()),minimum:v.optional(v.number()),maximum:v.optional(v.number())}).passthrough(),JfQ=v.object({type:v.literal("string"),title:v.optional(v.string()),description:v.optional(v.string()),enum:v.array(v.string()),enumNames:v.optional(v.array(v.string()))}).passthrough(),CfQ=v.union([FfQ,YfQ,WfQ,JfQ]),XfQ=uY.extend({method:v.literal("elicitation/create"),params:SX.extend({message:v.string(),requestedSchema:v.object({type:v.literal("object"),properties:v.record(v.string(),CfQ),required:v.optional(v.array(v.string()))}).passthrough()})}),Ia1=_X.extend({action:v.enum(["accept","decline","cancel"]),content:v.optional(v.record(v.string(),v.unknown()))}),VfQ=v.object({type:v.literal("ref/resource"),uri:v.string()}).passthrough();var KfQ=v.object({type:v.literal("ref/prompt"),name:v.string()}).passthrough(),EfQ=uY.extend({method:v.literal("completion/complete"),params:SX.extend({ref:v.union([KfQ,VfQ]),argument:v.object({name:v.string(),value:v.string()}).passthrough(),context:v.optional(v.object({arguments:v.optional(v.record(v.string(),v.string()))}))})}),Za1=_X.extend({completion:v.object({values:v.array(v.string()).max(100),total:v.optional(v.number().int()),hasMore:v.optional(v.boolean())}).passthrough()}),HfQ=v.object({uri:v.string().startsWith("file://"),name:v.optional(v.string()),_meta:v.optional(v.object({}).passthrough())}).passthrough(),Ga1=uY.extend({method:v.literal("roots/list")}),Fa1=_X.extend({roots:v.array(HfQ)}),zfQ=UU.extend({method:v.literal("notifications/roots/list_changed")}),Lo4=v.union([mC1,an1,EfQ,BfQ,nxQ,ixQ,bxQ,gxQ,hxQ,mxQ,dxQ,Qa1,Ba1]),Mo4=v.union([hC1,dC1,uC1,zfQ]),Ro4=v.union([nq,Da1,Ia1,Fa1]),Oo4=v.union([mC1,GfQ,XfQ,Ga1]),To4=v.union([hC1,dC1,QfQ,cxQ,uxQ,AfQ,oxQ]),Po4=v.union([nq,rn1,Za1,Aa1,ye,xy,sn1,je,vm,ke]);class HF extends Error{constructor(A,B,Q){super(`MCP error ${A}: ${B}`);this.code=A,this.data=Q,this.name="McpError"}}var UfQ=60000;class xe{constructor(A){this._options=A,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(hC1,(B)=>{let Q=this._requestHandlerAbortControllers.get(B.params.requestId);Q===null||Q===void 0||Q.abort(B.params.reason)}),this.setNotificationHandler(dC1,(B)=>{this._onprogress(B)}),this.setRequestHandler(mC1,(B)=>({}))}_setupTimeout(A,B,Q,D,I=!1){this._timeoutInfo.set(A,{timeoutId:setTimeout(D,B),startTime:Date.now(),timeout:B,maxTotalTimeout:Q,resetTimeoutOnProgress:I,onTimeout:D})}_resetTimeout(A){let B=this._timeoutInfo.get(A);if(!B)return!1;let Q=Date.now()-B.startTime;if(B.maxTotalTimeout&&Q>=B.maxTotalTimeout)throw this._timeoutInfo.delete(A),new HF(EF.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:B.maxTotalTimeout,totalElapsed:Q});return clearTimeout(B.timeoutId),B.timeoutId=setTimeout(B.onTimeout,B.timeout),!0}_cleanupTimeout(A){let B=this._timeoutInfo.get(A);if(B)clearTimeout(B.timeoutId),this._timeoutInfo.delete(A)}async connect(A){var B,Q,D;this._transport=A;let I=(B=this.transport)===null||B===void 0?void 0:B.onclose;this._transport.onclose=()=>{I===null||I===void 0||I(),this._onclose()};let Z=(Q=this.transport)===null||Q===void 0?void 0:Q.onerror;this._transport.onerror=(F)=>{Z===null||Z===void 0||Z(F),this._onerror(F)};let G=(D=this._transport)===null||D===void 0?void 0:D.onmessage;this._transport.onmessage=(F,Y)=>{if(G===null||G===void 0||G(F,Y),Se(F)||_12(F))this._onresponse(F);else if(gC1(F))this._onrequest(F,Y);else if(T12(F))this._onnotification(F);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(F)}`))},await this._transport.start()}_onclose(){var A;let B=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(A=this.onclose)===null||A===void 0||A.call(this);let Q=new HF(EF.ConnectionClosed,"Connection closed");for(let D of B.values())D(Q)}_onerror(A){var B;(B=this.onerror)===null||B===void 0||B.call(this,A)}_onnotification(A){var B;let Q=(B=this._notificationHandlers.get(A.method))!==null&&B!==void 0?B:this.fallbackNotificationHandler;if(Q===void 0)return;Promise.resolve().then(()=>Q(A)).catch((D)=>this._onerror(new Error(`Uncaught error in notification handler: ${D}`)))}_onrequest(A,B){var Q,D,I,Z;let G=(Q=this._requestHandlers.get(A.method))!==null&&Q!==void 0?Q:this.fallbackRequestHandler;if(G===void 0){(D=this._transport)===null||D===void 0||D.send({jsonrpc:"2.0",id:A.id,error:{code:EF.MethodNotFound,message:"Method not found"}}).catch((W)=>this._onerror(new Error(`Failed to send an error response: ${W}`)));return}let F=new AbortController;this._requestHandlerAbortControllers.set(A.id,F);let Y={signal:F.signal,sessionId:(I=this._transport)===null||I===void 0?void 0:I.sessionId,_meta:(Z=A.params)===null||Z===void 0?void 0:Z._meta,sendNotification:(W)=>this.notification(W,{relatedRequestId:A.id}),sendRequest:(W,J,C)=>this.request(W,J,{...C,relatedRequestId:A.id}),authInfo:B===null||B===void 0?void 0:B.authInfo,requestId:A.id,requestInfo:B===null||B===void 0?void 0:B.requestInfo};Promise.resolve().then(()=>G(A,Y)).then((W)=>{var J;if(F.signal.aborted)return;return(J=this._transport)===null||J===void 0?void 0:J.send({result:W,jsonrpc:"2.0",id:A.id})},(W)=>{var J,C;if(F.signal.aborted)return;return(J=this._transport)===null||J===void 0?void 0:J.send({jsonrpc:"2.0",id:A.id,error:{code:Number.isSafeInteger(W.code)?W.code:EF.InternalError,message:(C=W.message)!==null&&C!==void 0?C:"Internal error"}})}).catch((W)=>this._onerror(new Error(`Failed to send response: ${W}`))).finally(()=>{this._requestHandlerAbortControllers.delete(A.id)})}_onprogress(A){let{progressToken:B,...Q}=A.params,D=Number(B),I=this._progressHandlers.get(D);if(!I){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(A)}`));return}let Z=this._responseHandlers.get(D),G=this._timeoutInfo.get(D);if(G&&Z&&G.resetTimeoutOnProgress)try{this._resetTimeout(D)}catch(F){Z(F);return}I(Q)}_onresponse(A){let B=Number(A.id),Q=this._responseHandlers.get(B);if(Q===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(A)}`));return}if(this._responseHandlers.delete(B),this._progressHandlers.delete(B),this._cleanupTimeout(B),Se(A))Q(A);else{let D=new HF(A.error.code,A.error.message,A.error.data);Q(D)}}get transport(){return this._transport}async close(){var A;await((A=this._transport)===null||A===void 0?void 0:A.close())}request(A,B,Q){let{relatedRequestId:D,resumptionToken:I,onresumptiontoken:Z}=Q!==null&&Q!==void 0?Q:{};return new Promise((G,F)=>{var Y,W,J,C,X,V;if(!this._transport){F(new Error("Not connected"));return}if(((Y=this._options)===null||Y===void 0?void 0:Y.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod(A.method);(W=Q===null||Q===void 0?void 0:Q.signal)===null||W===void 0||W.throwIfAborted();let K=this._requestMessageId++,E={...A,jsonrpc:"2.0",id:K};if(Q===null||Q===void 0?void 0:Q.onprogress)this._progressHandlers.set(K,Q.onprogress),E.params={...A.params,_meta:{...((J=A.params)===null||J===void 0?void 0:J._meta)||{},progressToken:K}};let z=(R)=>{var P;this._responseHandlers.delete(K),this._progressHandlers.delete(K),this._cleanupTimeout(K),(P=this._transport)===null||P===void 0||P.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:K,reason:String(R)}},{relatedRequestId:D,resumptionToken:I,onresumptiontoken:Z}).catch((L)=>this._onerror(new Error(`Failed to send cancellation: ${L}`))),F(R)};this._responseHandlers.set(K,(R)=>{var P;if((P=Q===null||Q===void 0?void 0:Q.signal)===null||P===void 0?void 0:P.aborted)return;if(R instanceof Error)return F(R);try{let L=B.parse(R.result);G(L)}catch(L){F(L)}}),(C=Q===null||Q===void 0?void 0:Q.signal)===null||C===void 0||C.addEventListener("abort",()=>{var R;z((R=Q===null||Q===void 0?void 0:Q.signal)===null||R===void 0?void 0:R.reason)});let q=(X=Q===null||Q===void 0?void 0:Q.timeout)!==null&&X!==void 0?X:UfQ,M=()=>z(new HF(EF.RequestTimeout,"Request timed out",{timeout:q}));this._setupTimeout(K,q,Q===null||Q===void 0?void 0:Q.maxTotalTimeout,M,(V=Q===null||Q===void 0?void 0:Q.resetTimeoutOnProgress)!==null&&V!==void 0?V:!1),this._transport.send(E,{relatedRequestId:D,resumptionToken:I,onresumptiontoken:Z}).catch((R)=>{this._cleanupTimeout(K),F(R)})})}async notification(A,B){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(A.method);let Q={...A,jsonrpc:"2.0"};await this._transport.send(Q,B)}setRequestHandler(A,B){let Q=A.shape.method.value;this.assertRequestHandlerCapability(Q),this._requestHandlers.set(Q,(D,I)=>{return Promise.resolve(B(A.parse(D),I))})}removeRequestHandler(A){this._requestHandlers.delete(A)}assertCanSetRequestHandler(A){if(this._requestHandlers.has(A))throw new Error(`A request handler for ${A} already exists, which would be overridden`)}setNotificationHandler(A,B){this._notificationHandlers.set(A.shape.method.value,(Q)=>Promise.resolve(B(A.parse(Q))))}removeNotificationHandler(A){this._notificationHandlers.delete(A)}}function lC1(A,B){return Object.entries(B).reduce((Q,[D,I])=>{if(I&&typeof I==="object")Q[D]=Q[D]?{...Q[D],...I}:I;else Q[D]=I;return Q},{...A})}var h02=G1(ya1(),1);class ka1 extends xe{constructor(A,B){var Q;super(B);this._clientInfo=A,this._cachedToolOutputValidators=new Map,this._capabilities=(Q=B===null||B===void 0?void 0:B.capabilities)!==null&&Q!==void 0?Q:{},this._ajv=new h02.default}registerCapabilities(A){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=lC1(this._capabilities,A)}assertCapability(A,B){var Q;if(!((Q=this._serverCapabilities)===null||Q===void 0?void 0:Q[A]))throw new Error(`Server does not support ${A} (required for ${B})`)}async connect(A,B){if(await super.connect(A),A.sessionId!==void 0)return;try{let Q=await this.request({method:"initialize",params:{protocolVersion:mO,capabilities:this._capabilities,clientInfo:this._clientInfo}},rn1,B);if(Q===void 0)throw new Error(`Server sent invalid initialize result: ${Q}`);if(!fC1.includes(Q.protocolVersion))throw new Error(`Server's protocol version is not supported: ${Q.protocolVersion}`);if(this._serverCapabilities=Q.capabilities,this._serverVersion=Q.serverInfo,A.setProtocolVersion)A.setProtocolVersion(Q.protocolVersion);this._instructions=Q.instructions,await this.notification({method:"notifications/initialized"})}catch(Q){throw this.close(),Q}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(A){var B,Q,D,I,Z;switch(A){case"logging/setLevel":if(!((B=this._serverCapabilities)===null||B===void 0?void 0:B.logging))throw new Error(`Server does not support logging (required for ${A})`);break;case"prompts/get":case"prompts/list":if(!((Q=this._serverCapabilities)===null||Q===void 0?void 0:Q.prompts))throw new Error(`Server does not support prompts (required for ${A})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!((D=this._serverCapabilities)===null||D===void 0?void 0:D.resources))throw new Error(`Server does not support resources (required for ${A})`);if(A==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${A})`);break;case"tools/call":case"tools/list":if(!((I=this._serverCapabilities)===null||I===void 0?void 0:I.tools))throw new Error(`Server does not support tools (required for ${A})`);break;case"completion/complete":if(!((Z=this._serverCapabilities)===null||Z===void 0?void 0:Z.completions))throw new Error(`Server does not support completions (required for ${A})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(A){var B;switch(A){case"notifications/roots/list_changed":if(!((B=this._capabilities.roots)===null||B===void 0?void 0:B.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${A})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(A){switch(A){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${A})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${A})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${A})`);break;case"ping":break}}async ping(A){return this.request({method:"ping"},nq,A)}async complete(A,B){return this.request({method:"completion/complete",params:A},Za1,B)}async setLoggingLevel(A,B){return this.request({method:"logging/setLevel",params:{level:A}},nq,B)}async getPrompt(A,B){return this.request({method:"prompts/get",params:A},Aa1,B)}async listPrompts(A,B){return this.request({method:"prompts/list",params:A},ye,B)}async listResources(A,B){return this.request({method:"resources/list",params:A},xy,B)}async listResourceTemplates(A,B){return this.request({method:"resources/templates/list",params:A},sn1,B)}async readResource(A,B){return this.request({method:"resources/read",params:A},je,B)}async subscribeResource(A,B){return this.request({method:"resources/subscribe",params:A},nq,B)}async unsubscribeResource(A,B){return this.request({method:"resources/unsubscribe",params:A},nq,B)}async callTool(A,B=vm,Q){let D=await this.request({method:"tools/call",params:A},B,Q),I=this.getToolOutputValidator(A.name);if(I){if(!D.structuredContent&&!D.isError)throw new HF(EF.InvalidRequest,`Tool ${A.name} has an output schema but did not return structured content`);if(D.structuredContent)try{if(!I(D.structuredContent))throw new HF(EF.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(I.errors)}`)}catch(Z){if(Z instanceof HF)throw Z;throw new HF(EF.InvalidParams,`Failed to validate structured content: ${Z instanceof Error?Z.message:String(Z)}`)}}return D}cacheToolOutputSchemas(A){this._cachedToolOutputValidators.clear();for(let B of A)if(B.outputSchema)try{let Q=this._ajv.compile(B.outputSchema);this._cachedToolOutputValidators.set(B.name,Q)}catch(Q){}}getToolOutputValidator(A){return this._cachedToolOutputValidators.get(A)}async listTools(A,B){let Q=await this.request({method:"tools/list",params:A},ke,B);return this.cacheToolOutputSchemas(Q.tools),Q}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var P22=G1(T22(),1);import XX1 from"node:process";import{PassThrough as TbQ}from"node:stream";class ve{append(A){this._buffer=this._buffer?Buffer.concat([this._buffer,A]):A}readMessage(){if(!this._buffer)return null;let A=this._buffer.indexOf(`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

HF [McpError]: MCP error -32603: Internal error
    at ka1._onresponse (file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1336:17679)
    at _transport.onmessage (file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1336:14832)
    at J.C.client.transport.onmessage (file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1969:8981)
    at ca1.processReadBuffer (file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:2324)
    at Socket.<anonymous> (file:///Users/tomakehurst/.nvm/versions/node/v18.20.7/lib/node_modules/@anthropic-ai/claude-code/cli.js:1338:1690)
    at Socket.emit (node:events:517:28)
    at Socket.emit (node:domain:489:12)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10) {
  code: -32603,
  data: {}
}

Node.js v18.20.7

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗