Skip to main content
Glama
toolresult.ts500 B
import {CallToolResult} from "@modelcontextprotocol/sdk/types.js"; export async function wrapToolResult(caption: string, fn: () => any): Promise<CallToolResult> { try { const result = await fn() return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] } } catch (e) { return { content: [{ type: "text", text: JSON.stringify({error: `Tool ${caption} failed: ${e}`}) }], isError: true } } }

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/SimplifierIO/simplifier-mcp'

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