eyaltoledano/claude-task-master · error · MCPSessionError

CAPABILITY_ERROR

CAPABILITY_ERROR

Error message

${message}

What it means

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).

Source

Thrown at mcp-server/src/custom-sdk/errors.js:73

	// Map common error patterns
	if (message.includes('session') || message.includes('connection')) {
		return new MCPSessionError(message, {
			cause: originalError,
			code: 'SESSION_ERROR'
		});
	}

	if (message.includes('sampling') || message.includes('timeout')) {
		return new MCPSamplingError(message, {
			cause: originalError,
			code: 'SAMPLING_ERROR'
		});
	}

	if (message.includes('capabilities') || message.includes('not supported')) {
		return new MCPSessionError(message, {
			cause: originalError,
			code: 'CAPABILITY_ERROR'
		});
	}

	// Default to generic MCP error
	return new MCPError(message, {
		cause: originalError,
		code: 'UNKNOWN_ERROR'
	});
}

/**
 * Check if error is retryable
 * @param {Error} error - Error to check
 * @returns {boolean} True if error might be retryable
 */
export function isRetryableError(error) {
	if (error instanceof MCPSamplingError && error.code === 'SAMPLING_ERROR') {
		return true;

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Check the server's advertised capabilities in its initialize response and enable the needed one
  2. Upgrade the MCP server to a version supporting the requested capability
  3. Remove/feature-flag the unsupported call path in your code
  4. Verify client and server protocol versions are compatible

Example fix

// before
const res = await doGenerate(prompt); // server lacks sampling capability
// after
const caps = server.getCapabilities();
if (!caps.sampling) throw new Error('Server does not support sampling');
const res = await doGenerate(prompt);
Defensive patterns

Strategy: validation

Validate before calling

function assertCapability(server, capability) {
  const caps = server.getCapabilities?.() ?? {};
  if (!caps[capability]) {
    throw new Error(`MCP server does not support capability: ${capability}`);
  }
}
assertCapability(server, 'sampling');

Type guard

function isCapabilityError(e: unknown): e is MCPSessionError {
  return typeof e === 'object' && e !== null && (e as any).code === 'CAPABILITY_ERROR';
}

Try / catch

try {
  await doGenerate(prompt);
} catch (e) {
  if (isCapabilityError(e)) {
    // disable feature or fall back to a non-MCP path
    return localFallbackGenerate(prompt);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/bc58cc303735c5b3. Report an issue: GitHub.