Skip to main content
Glama
index.ts1.21 kB
import { Hono } from "hono"; import { cors } from "hono/cors"; import { AIServiceFactory } from "./services/ai-service-factory"; import { MCPController } from "./controllers/mcp-controller"; const app = new Hono<{ Bindings: Bindings }>(); // Add CORS middleware app.use("*", cors()); // Setup routes app.get("/", (c) => c.redirect("/index.html")); app.get("/message", (c) => { return c.text("MCP Server is running!"); }); // MCP API endpoint app.post("/api/mcp", async (c) => { try { const aiService = AIServiceFactory.createService(c.env); const mcpController = new MCPController(aiService); return mcpController.handleRequest(c); } catch (error) { console.error("Error creating AI service:", error); return c.json( { error: "Failed to initialize AI service", message: (error as Error).message }, 500 ); } }); // Health check endpoint app.get("/health", (c) => { return c.json({ status: "ok", version: "1.0.0", provider: c.env.AI_PROVIDER }); }); // Provider info endpoint app.get("/api/provider", (c) => { return c.json({ provider: c.env.AI_PROVIDER, model: c.env.DEFAULT_MODEL }); }); 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/quang-pham-dev/my-mcp-server'

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