amazon-seller-mcp
Version:
Model Context Protocol (MCP) client for Amazon Selling Partner API
94 lines (93 loc) • 2.27 kB
TypeScript
/**
* Error handling utilities for MCP server
*
* This file contains functions for translating errors to MCP error responses
* and handling errors in MCP tools and resources.
*/
/**
* Handle an error in an MCP tool
*
* @param error Error to handle
* @returns MCP tool error response
*/
export declare function handleToolError(error: unknown): {
content: Array<{
type: 'text';
text: string;
} | {
type: 'resource_link';
uri: string;
name: string;
mimeType?: string;
description?: string;
}>;
isError: boolean;
errorDetails?: {
code: string;
message: string;
details?: unknown;
};
};
/**
* Handle an error in an MCP resource
*
* @param error Error to handle
* @returns MCP resource error response
*/
export declare function handleResourceError(error: unknown): {
contents: Array<{
uri: string;
text: string;
mimeType?: string;
}>;
};
/**
* Wrap a tool handler with error handling
*
* @param handler Tool handler function
* @returns Wrapped tool handler function
*/
export declare function wrapToolHandlerWithErrorHandling<T = unknown>(handler: (params: T) => Promise<{
content: Array<{
type: 'text';
text: string;
} | {
type: 'resource_link';
uri: string;
name: string;
mimeType?: string;
description?: string;
}>;
isError?: boolean;
}>): (params: T) => Promise<{
content: Array<{
type: 'text';
text: string;
} | {
type: 'resource_link';
uri: string;
name: string;
mimeType?: string;
description?: string;
}>;
isError?: boolean;
}>;
/**
* Wrap a resource handler with error handling
*
* @param handler Resource handler function
* @returns Wrapped resource handler function
*/
export declare function wrapResourceHandlerWithErrorHandling(handler: (uri: URL, params: Record<string, string>) => Promise<{
contents: Array<{
uri: string;
text: string;
mimeType?: string;
}>;
}>): (uri: URL, params: Record<string, string>) => Promise<{
contents: Array<{
uri: string;
text: string;
mimeType?: string;
}>;
}>;