Add mcp-use/inspector route

This commit is contained in:
2026-04-20 18:33:44 +05:30
parent 0334c5836b
commit 35e8fadca2
3 changed files with 800 additions and 1 deletions
+9
View File
@@ -10,6 +10,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url";
import { serve } from "@hono/node-server";
import * as lancedbSdk from "@lancedb/lancedb";
import { mountInspector } from "@mcp-use/inspector";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
import { Hono } from "hono";
@@ -251,6 +252,14 @@ export async function main() {
// Health check endpoint
app.get("/health", (c) => c.json({ status: "ok" }));
// MCP Inspector at root path - auto-connects to /mcp
// Use environment variable for public URL, fallback to localhost for dev
const mcpPublicUrl = process.env.MCP_PUBLIC_URL || `http://localhost:${PORT}`;
mountInspector(app, {
autoConnectUrl: `${mcpPublicUrl}/mcp`,
devMode: process.env.NODE_ENV !== "production",
});
// MCP endpoint - handles both GET and POST
app.all("/mcp", async (c) => {
// Get parsed body from Hono (automatic JSON parsing)