Skip to main content
Glama
index.ts1.26 kB
import { MCPServer } from "mcp-framework"; import { dirname, join } from "path"; import { fileURLToPath } from "url"; import { readFileSync } from "fs"; // Get the directory of the current module (dist directory) const __dirname = dirname(fileURLToPath(import.meta.url)); // Get version from package.json const pkgMetadata = JSON.parse(readFileSync(join(__dirname, '../package.json'), 'utf-8')); const VERSION = pkgMetadata.version; /** * Available transports */ const TRANSPORTS: Record<string, any> = { 'stdio': { type: "stdio" }, 'http': { type: "http-stream", options: { port: 3000, cors: { allowOrigin: "*" } } } } async function main() { // get transport type from environment variable const TRANSPORT_TYPE = process.env.TRANSPORT_TYPE || "stdio"; if (TRANSPORT_TYPE !== "stdio" && TRANSPORT_TYPE !== "http") { throw new Error(`Invalid transport type: ${TRANSPORT_TYPE}`); } // start MCP server const mcpServer = new MCPServer({ name: 'geocontext', version: VERSION, basePath: __dirname, transport: TRANSPORTS[TRANSPORT_TYPE], }); await mcpServer.start(); } main().catch((error) => { console.error("Fatal error in main():", error); process.exit(1); });

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/ignfab/geocontext'

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