{"record":{"id":"bc58cc303735c5b3","repo":"eyaltoledano/claude-task-master","slug":"capability-error","errorCode":"CAPABILITY_ERROR","errorMessage":"${message}","messagePattern":"\\$\\{message\\}","errorType":"error_code","errorClass":"MCPSessionError","httpStatus":null,"severity":"error","filePath":"mcp-server/src/custom-sdk/errors.js","lineNumber":73,"sourceCode":"\t// Map common error patterns\n\tif (message.includes('session') || message.includes('connection')) {\n\t\treturn new MCPSessionError(message, {\n\t\t\tcause: originalError,\n\t\t\tcode: 'SESSION_ERROR'\n\t\t});\n\t}\n\n\tif (message.includes('sampling') || message.includes('timeout')) {\n\t\treturn new MCPSamplingError(message, {\n\t\t\tcause: originalError,\n\t\t\tcode: 'SAMPLING_ERROR'\n\t\t});\n\t}\n\n\tif (message.includes('capabilities') || message.includes('not supported')) {\n\t\treturn new MCPSessionError(message, {\n\t\t\tcause: originalError,\n\t\t\tcode: 'CAPABILITY_ERROR'\n\t\t});\n\t}\n\n\t// Default to generic MCP error\n\treturn new MCPError(message, {\n\t\tcause: originalError,\n\t\tcode: 'UNKNOWN_ERROR'\n\t});\n}\n\n/**\n * Check if error is retryable\n * @param {Error} error - Error to check\n * @returns {boolean} True if error might be retryable\n */\nexport function isRetryableError(error) {\n\tif (error instanceof MCPSamplingError && error.code === 'SAMPLING_ERROR') {\n\t\treturn true;","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/custom-sdk/errors.js#L55-L91","documentation":"mapMCPError re-wraps errors whose message contains 'capabilities' or 'not supported' as MCPSessionError with code CAPABILITY_ERROR, meaning the connected MCP peer does not support the requested operation (e.g. sampling or a tool the server doesn't expose).","triggerScenarios":"Calling doGenerate/doGenerateObject/doStream against an MCP server whose advertised capabilities exclude the needed feature, or calling a method the server's protocol version doesn't support.","commonSituations":"Server implementation predates the sampling capability; client and server protocol version mismatch; misconfigured server without the feature enabled; calling tools/list on a prompts-only server.","solutions":["Check the server's advertised capabilities in its initialize response and enable the needed one","Upgrade the MCP server to a version supporting the requested capability","Remove/feature-flag the unsupported call path in your code","Verify client and server protocol versions are compatible"],"exampleFix":"// before\nconst res = await doGenerate(prompt); // server lacks sampling capability\n// after\nconst caps = server.getCapabilities();\nif (!caps.sampling) throw new Error('Server does not support sampling');\nconst res = await doGenerate(prompt);","handlingStrategy":"validation","validationCode":"function assertCapability(server, capability) {\n  const caps = server.getCapabilities?.() ?? {};\n  if (!caps[capability]) {\n    throw new Error(`MCP server does not support capability: ${capability}`);\n  }\n}\nassertCapability(server, 'sampling');","typeGuard":"function isCapabilityError(e: unknown): e is MCPSessionError {\n  return typeof e === 'object' && e !== null && (e as any).code === 'CAPABILITY_ERROR';\n}","tryCatchPattern":"try {\n  await doGenerate(prompt);\n} catch (e) {\n  if (isCapabilityError(e)) {\n    // disable feature or fall back to a non-MCP path\n    return localFallbackGenerate(prompt);\n  }\n  throw e;\n}","preventionTips":["Inspect the initialize response capabilities before calling features","Keep client and server protocol versions in sync","Feature-gate calls on capability discovery rather than assuming support"],"tags":["mcp","capabilities","protocol"],"backgroundTag":"capability-not-supported","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}