Skip to main content
Glama
mcp-server.http.ts1.65 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js"; import express from "express"; import { ListMidiOutputsMcpTool } from "../src/mcp/tools/list-midi-outputss.tool"; import { PlayMusicMcpTool } from "../src/mcp/tools/play-music.tool"; (async () => { const app = express(); app.use(express.json()); app.post("/", async (req, res) => { try { const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, }); const server = new McpServer({ name: "vibe-composer-midi-mcp", version: "1.0.0", }); server.registerTool( ListMidiOutputsMcpTool.name, { title: ListMidiOutputsMcpTool.title, description: ListMidiOutputsMcpTool.description, }, ListMidiOutputsMcpTool.handler ); server.registerTool( PlayMusicMcpTool.name, { title: PlayMusicMcpTool.title, description: PlayMusicMcpTool.description, inputSchema: PlayMusicMcpTool.inputSchema, }, PlayMusicMcpTool.handler ); await server.connect(transport); await transport.handleRequest(req, res, req.body); } catch (error) { console.error("Error handling MCP request:", error); if (!res.headersSent) { res.status(500).json({ jsonrpc: "2.0", error: { code: -32603, message: "Internal server error", }, id: null, }); } } }); app.listen(3333); })();

Implementation Reference

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/mikeborozdin/vibe-composer-midi-mcp'

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