Skip to main content
Glama

Vercel MCP Adapter

index.ts1.2 kB
import { type Config, initializeMcpApiHandler } from "./mcp-api-handler"; import { createServerResponseAdapter } from "./server-response-adapter"; import type { ServerOptions } from "@modelcontextprotocol/sdk/server/index.js"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; /** * Creates a MCP handler that can be used to handle MCP requests. * @param initializeServer - A function that initializes the MCP server. Use this to access the server instance and register tools, prompts, and resources. * @param serverOptions - Options for the MCP server. * @param config - Configuration for the MCP handler. * @returns A function that can be used to handle MCP requests. */ export default function createMcpRouteHandler( initializeServer: | ((server: McpServer) => Promise<void>) | ((server: McpServer) => void), serverOptions?: ServerOptions, config?: Config ): (request: Request) => Promise<Response> { const mcpHandler = initializeMcpApiHandler( initializeServer, serverOptions, config ); return (request: Request) => { return createServerResponseAdapter(request.signal, (res) => { mcpHandler(request, res); }); }; }

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/brunobenavent/mcp-vercel'

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