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
+790 -1
View File
File diff suppressed because one or more lines are too long
+1
View File
@@ -56,6 +56,7 @@
"@langchain/core": "^0.2.0", "@langchain/core": "^0.2.0",
"@langchain/ollama": "^0.1.0", "@langchain/ollama": "^0.1.0",
"@langchain/openai": "^0.1.0", "@langchain/openai": "^0.1.0",
"@mcp-use/inspector": "^2.1.0",
"@modelcontextprotocol/sdk": "^1.0.4", "@modelcontextprotocol/sdk": "^1.0.4",
"acorn": "^8.16.0", "acorn": "^8.16.0",
"cheerio": "^1.2.0", "cheerio": "^1.2.0",
+9
View File
@@ -10,6 +10,7 @@ import path from "node:path";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { serve } from "@hono/node-server"; import { serve } from "@hono/node-server";
import * as lancedbSdk from "@lancedb/lancedb"; import * as lancedbSdk from "@lancedb/lancedb";
import { mountInspector } from "@mcp-use/inspector";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js"; import { WebStandardStreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/webStandardStreamableHttp.js";
import { Hono } from "hono"; import { Hono } from "hono";
@@ -251,6 +252,14 @@ export async function main() {
// Health check endpoint // Health check endpoint
app.get("/health", (c) => c.json({ status: "ok" })); 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 // MCP endpoint - handles both GET and POST
app.all("/mcp", async (c) => { app.all("/mcp", async (c) => {
// Get parsed body from Hono (automatic JSON parsing) // Get parsed body from Hono (automatic JSON parsing)