Skip to main content
Glama
resourcesresult.ts578 B
import {ReadResourceResult} from "@modelcontextprotocol/sdk/types.js"; export async function wrapResourceResult(uri: URL, fn: () => any, mimeType: string = "application/json"): Promise<ReadResourceResult> { try { const result = await fn() return { contents: [{ uri: uri.href, text: JSON.stringify(result, null, 2), mimeType: mimeType, }] } } catch (e) { return { contents: [{ uri: uri.href, text: JSON.stringify({error: `Could not get data! ${e}`}), mimeType: mimeType, }] } } }

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