Skip to main content
Glama
mcpGateway.test.ts955 B
import express from "express"; import request from "supertest"; import { describe, expect, it } from "vitest"; import { ExpressMCP } from "../src"; describe("MCP HTTP gateway", () => { it("lists tools and invokes a tool", async () => { const app = express(); app.use(express.json()); app.post("/echo", (req, res) => res.json({ youSent: req.body })); const mcp = new ExpressMCP(app, { mountPath: "/mcp" }); await mcp.init(); mcp.mount("/mcp"); const agent = request(app); const toolsRsp = await agent.get("/mcp/tools").expect(200); const tool = toolsRsp.body.tools.find((t: { name: string }) => t.name.includes("POST_/echo"), ); expect(tool).toBeTruthy(); const invokeRsp = await agent .post("/mcp/invoke") .send({ toolName: tool.name, args: { hello: "world" }, }) .expect(200); expect(invokeRsp.body.ok).toBe(true); expect(invokeRsp.body.result).toEqual({ youSent: { hello: "world" } }); }); });

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/bowen31337/expressjs_mcp'

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