Skip to main content
Glama

NS Travel Information MCP Server

by r-huijts
ResponseFormatter.ts1.06 kB
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; import { AxiosError } from 'axios'; export class ResponseFormatter { static formatSuccess(data: unknown) { return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } static formatError(error: unknown) { if (error instanceof McpError) { return { isError: true, content: [{ type: "text", text: error.message }] }; } if (error instanceof AxiosError) { return { isError: true, content: [{ type: "text", text: `NS API error: ${error.response?.data?.message || error.message || 'Unknown error'}` }] }; } return { isError: true, content: [{ type: "text", text: error instanceof Error ? error.message : 'Unknown error occurred' }] }; } static createMcpError(code: ErrorCode, message: string): McpError { return new McpError(code, message); } }

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/r-huijts/ns-mcp-server'

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