Merge pull request #1 from bendtherules/inspector

Add inspector route
This commit is contained in:
2026-04-21 13:07:53 +05:30
committed by GitHub
6 changed files with 867 additions and 187 deletions
+10
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";
@@ -252,6 +253,7 @@ export async function main() {
app.get("/health", (c) => c.json({ status: "ok" }));
// MCP endpoint - handles both GET and POST
// Must be defined BEFORE inspector (which mounts at /) for proper route matching
app.all("/mcp", async (c) => {
// Get parsed body from Hono (automatic JSON parsing)
let parsedBody: unknown;
@@ -280,6 +282,14 @@ export async function main() {
return response;
});
// MCP Inspector at root path - auto-connects to /mcp
// Mounted AFTER /mcp so specific routes take precedence
const mcpPublicUrl = process.env.COOLIFY_URL || process.env.MCP_PUBLIC_URL || `http://localhost:${PORT}`;
mountInspector(app, {
autoConnectUrl: `${mcpPublicUrl}/mcp`,
devMode: process.env.NODE_ENV !== "production",
});
// Start the server
console.log(`Ask262 MCP HTTP Server running on http://0.0.0.0:${PORT}`);
console.log(`MCP endpoint: POST http://0.0.0.0:${PORT}/mcp`);