Skip to main content
Glama

Discogs MCP Server

by cswkim
testServer.ts1.34 kB
import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'; import { FastMCP } from 'fastmcp'; import { getRandomPort } from 'get-port-please'; export const runWithTestServer = async ({ run, server: createServer, }: { server?: () => Promise<FastMCP>; run: ({ client, server }: { client: Client; server: FastMCP }) => Promise<void>; }) => { const port = await getRandomPort(); const server = createServer ? await createServer() : new FastMCP({ name: 'Test', version: '1.0.0', }); await server.start({ transportType: 'httpStream', httpStream: { port, }, }); try { const client = new Client( { name: 'example-client', version: '1.0.0', }, { capabilities: {}, }, ); const transport = new StreamableHTTPClientTransport(new URL(`http://localhost:${port}/mcp`)); await client.connect(transport); // Wait a bit to ensure connection is established await new Promise((resolve) => setTimeout(resolve, 1000)); await run({ client, server }); // Clean up connection await transport.terminateSession(); await client.close(); } finally { await server.stop(); } return port; };

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/cswkim/discogs-mcp-server'

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