Skip to main content
Glama

ESA MCP Server

by d-kimuson
formatTool.ts1.18 kB
import { CallToolResult } from "@modelcontextprotocol/sdk/types.js" import { stringify } from "yaml" const toResponse = (result: unknown) => { if (typeof result === "string" && result === "") { return "success" } if (result === undefined || result === null) { return "success" } if (Array.isArray(result)) return result if (typeof result === "object") { try { // @ts-expect-error if (result["status"] !== undefined) { return result } return { status: "success", ...result, } } catch { return result } } return result } export const formatTool = async ( cb: () => unknown ): Promise<CallToolResult> => { try { const result = await cb() return { content: [ { type: "text", text: stringify(toResponse(result)), }, ], } } catch (error) { console.error("Error in formatTool:", error) return { isError: true, content: [ { type: "text", text: `Error: ${error instanceof Error ? `${error.name}: ${error.message}` : String(error)}`, }, ], } } }

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/d-kimuson/esa-mcp-server'

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