Skip to main content
Glama
express-plugin.ts1.19 kB
import http from 'node:http' import express from 'express' let serverInstance: http.Server | undefined const app = express(); (function () { const originalCreateServerInternal = http.createServer http.createServer = function patchedHttpCreateServer(...createServerArgs) { const fastMcpOriginalListener = createServerArgs[0] const dispatcherFunction = (req: express.Request, res: express.Response) => { const passToFastMcp = (err: any) => { if (err) { console.error('Error from Express layer; FastMCP will not be called:', err) return } if (typeof fastMcpOriginalListener === 'function') { fastMcpOriginalListener(req as any, res as any) } else { console.error('fastMcpOriginalListener is not a callable function.') } } app(req, res, passToFastMcp) } const finalArgs = [dispatcherFunction, ...createServerArgs.slice(1)] const newServerInstance = originalCreateServerInternal.apply(this, finalArgs as any) if (typeof serverInstance !== 'undefined') { serverInstance = newServerInstance } return newServerInstance } })() export default app

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/Panzer-Jack/feuse-mcp'

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