Skip to main content
Glama

GitLab MCP Server

by rifqi96
response-formatter.ts1.07 kB
/** * Utility functions for formatting MCP responses */ import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; import axios from "axios"; /** * Format an API response for MCP protocol * * @param data The data to format * @returns Formatted MCP response */ export function formatResponse(data: any) { return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } /** * Handle errors from API calls * * @param error The error object * @param defaultMessage Default message to use * @returns McpError object */ export function handleApiError(error: unknown, defaultMessage: string): McpError { if (axios.isAxiosError(error)) { return new McpError( ErrorCode.InternalError, `GitLab API error: ${error.response?.data?.message || error.message}` ); } if (error instanceof Error) { return new McpError( ErrorCode.InternalError, `${defaultMessage}: ${error.message}` ); } return new McpError( ErrorCode.InternalError, defaultMessage ); }

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/rifqi96/mcp-gitlab'

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