Skip to main content
Glama
middlewares.ts685 B
import { ToolCallback } from "@modelcontextprotocol/sdk/server/mcp"; import { ZodRawShape } from "zod"; export const withErrorHandling = <Args extends ZodRawShape>( cb: ToolCallback<Args> ): ToolCallback<Args> => { return (async (args, extra) => { try { return await cb(args, extra); } catch (err) { const errorMessage = err instanceof Error ? err.message : String(err); const responseData = (err as any)?.response?.data; const status = (err as any)?.response?.status; throw new Error( JSON.stringify({ error: errorMessage, responseData, status, }) ); } }) as ToolCallback<Args>; };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baruchiro/paperless-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server