mirror of
https://github.com/bendtherules/ask262.git
synced 2026-08-18 21:31:46 +00:00
Add mcp-use/inspector route
This commit is contained in:
@@ -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",
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user