Provides structured MCP error helpers.
// Source: https://github.com/pascalorg/editor | License: MIT | Copyright 2026 Pascal Group Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js'
import { isAgentRefusal } from '@pascal-app/core/agent-tools'
/**
* Throw a structured MCP error. The SDK translates `McpError` into a
* JSON-RPC error response automatically.
*/
export function throwMcpError(code: ErrorCode, message: string, data?: unknown): never {
throw new McpError(code, message, data)
}
/**
* Return a non-throwing tool error payload — used for structured failures that
* we want the client to see inline in `content` rather than as a protocol
* error. Sets `isError: true` so SDK clients treat it as a failure.
*/
export function t
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key