Base branded error class for MCP protocol errors, with code/data fields and factory logic to map error codes to specific error subclasses.
export class ProtocolError extends Error {
static {
Object.defineProperty(this, 'mcpBrand', { value: 'mcp.ProtocolError' });
}
static override [Symbol.hasInstance](value: unknown): boolean {
return brandedHasInstance(this, value);
}
/**
* Brand-based type guard: equivalent to `value instanceof this`, as an
* explicit static predicate (the axios/AWS-SDK `isInstance` style). Reads
* the caller's own brand via `this`, so every branded subclass gets a
* correctly-scoped guard by inheritance. Must be invoked on the class โ
* in callback position write `v => SdkError.isInstance(v)`, not
* `.filter(SdkError.isInstance)` (detached calls throw rather than
* silently matching nothing).
*/
static isInstance<T extends ab
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key