Skip to main content
Glama

MCP TypeScript Template

utils.ts625 B
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js"; /** * Creates a CallToolResult with text content from any data * Handles undefined values gracefully by converting them to null * @param data - The data to stringify and include in the result * @returns A properly formatted CallToolResult */ export function createTextResult(data: unknown): CallToolResult { // Handle undefined gracefully by converting to null const safeData = data === undefined ? null : data; return { content: [ { type: "text", text: JSON.stringify(safeData, null, 2), }, ], }; }

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/moonlitknight/mcp1template'

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