@mcp-use/inspector 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -0
- package/dist/cli/inspect.d.ts +3 -0
- package/dist/cli/inspect.d.ts.map +1 -0
- package/dist/client/assets/index-BOon65c9.css +1 -0
- package/dist/client/assets/index-Risbd_Le.js +1656 -0
- package/dist/client/index.html +17 -0
- package/dist/index.js +107 -0
- package/dist/server/favicon-proxy.d.ts +4 -0
- package/dist/server/favicon-proxy.d.ts.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.d.ts.map +1 -0
- package/dist/server/mcp-inspector.d.ts +26 -0
- package/dist/server/mcp-inspector.d.ts.map +1 -0
- package/dist/server/middleware.d.ts +20 -0
- package/dist/server/middleware.d.ts.map +1 -0
- package/dist/server/server.d.ts +9 -0
- package/dist/server/server.d.ts.map +1 -0
- package/dist/server/unified.d.ts +9 -0
- package/dist/server/unified.d.ts.map +1 -0
- package/package.json +105 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=Ubuntu:wght@400;500;700&display=swap" rel="stylesheet">
|
|
10
|
+
<title>MCP Inspector</title>
|
|
11
|
+
<script type="module" crossorigin src="/inspector/assets/index-Risbd_Le.js"></script>
|
|
12
|
+
<link rel="stylesheet" crossorigin href="/inspector/assets/index-BOon65c9.css">
|
|
13
|
+
</head>
|
|
14
|
+
<body>
|
|
15
|
+
<div id="root"></div>
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/server/middleware.ts
|
|
2
|
+
import { Buffer } from "buffer";
|
|
3
|
+
import { existsSync } from "fs";
|
|
4
|
+
import { dirname, join } from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
var __dirname = dirname(__filename);
|
|
8
|
+
function mountInspector(app, path = "/inspector", mcpServerUrl) {
|
|
9
|
+
const basePath = path.startsWith("/") ? path : `/${path}`;
|
|
10
|
+
const clientDistPath = join(__dirname, "../../dist/client");
|
|
11
|
+
if (!existsSync(clientDistPath)) {
|
|
12
|
+
console.warn(`\u26A0\uFE0F MCP Inspector client files not found at ${clientDistPath}`);
|
|
13
|
+
console.warn(` Run 'yarn build' in the inspector package to build the UI`);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
app.get(`${basePath}/config.json`, (_req, res) => {
|
|
17
|
+
res.json({
|
|
18
|
+
autoConnectUrl: mcpServerUrl || null
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
app.get(`${basePath}/api/favicon/:url`, async (req, res) => {
|
|
22
|
+
const url = req.params.url;
|
|
23
|
+
if (!url) {
|
|
24
|
+
res.status(400).json({ error: "URL parameter is required" });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
try {
|
|
28
|
+
const decodedUrl = decodeURIComponent(url);
|
|
29
|
+
let fullUrl = decodedUrl;
|
|
30
|
+
if (!decodedUrl.startsWith("http://") && !decodedUrl.startsWith("https://")) {
|
|
31
|
+
fullUrl = `https://${decodedUrl}`;
|
|
32
|
+
}
|
|
33
|
+
const urlObj = new URL(fullUrl);
|
|
34
|
+
const faviconUrls = [
|
|
35
|
+
`${urlObj.origin}/favicon.ico`,
|
|
36
|
+
`${urlObj.origin}/favicon.png`,
|
|
37
|
+
`${urlObj.origin}/apple-touch-icon.png`
|
|
38
|
+
];
|
|
39
|
+
for (const faviconUrl of faviconUrls) {
|
|
40
|
+
try {
|
|
41
|
+
const response = await fetch(faviconUrl, {
|
|
42
|
+
headers: {
|
|
43
|
+
"User-Agent": "Mozilla/5.0 (compatible; MCP-Inspector/1.0)"
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (response.ok) {
|
|
47
|
+
const contentType = response.headers.get("content-type") || "image/x-icon";
|
|
48
|
+
const buffer = await response.arrayBuffer();
|
|
49
|
+
res.setHeader("Content-Type", contentType);
|
|
50
|
+
res.setHeader("Cache-Control", "public, max-age=86400");
|
|
51
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
52
|
+
res.send(Buffer.from(buffer));
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
res.status(404).json({ error: "No favicon found" });
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Favicon proxy error:", error);
|
|
62
|
+
res.status(400).json({ error: "Invalid URL or fetch failed" });
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
app.use(`${basePath}/assets`, (_req, res) => {
|
|
66
|
+
const assetPath = join(clientDistPath, "assets", _req.path);
|
|
67
|
+
if (existsSync(assetPath)) {
|
|
68
|
+
if (assetPath.endsWith(".js")) {
|
|
69
|
+
res.setHeader("Content-Type", "application/javascript");
|
|
70
|
+
} else if (assetPath.endsWith(".css")) {
|
|
71
|
+
res.setHeader("Content-Type", "text/css");
|
|
72
|
+
}
|
|
73
|
+
res.sendFile(assetPath);
|
|
74
|
+
} else {
|
|
75
|
+
res.status(404).send("Asset not found");
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (basePath !== "") {
|
|
79
|
+
app.get("/oauth/callback", (req, res) => {
|
|
80
|
+
const queryString = req.url.split("?")[1] || "";
|
|
81
|
+
const redirectUrl = queryString ? `${basePath}/oauth/callback?${queryString}` : `${basePath}/oauth/callback`;
|
|
82
|
+
res.redirect(302, redirectUrl);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
app.get(basePath, (_req, res) => {
|
|
86
|
+
const indexPath = join(clientDistPath, "index.html");
|
|
87
|
+
if (!existsSync(indexPath)) {
|
|
88
|
+
res.status(500).send("Inspector UI not found. Please build the inspector package.");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
res.sendFile(indexPath);
|
|
92
|
+
});
|
|
93
|
+
app.get(`${basePath}/`, (_req, res) => {
|
|
94
|
+
res.redirect(301, basePath);
|
|
95
|
+
});
|
|
96
|
+
app.get(`${basePath}/*`, (_req, res) => {
|
|
97
|
+
const indexPath = join(clientDistPath, "index.html");
|
|
98
|
+
if (!existsSync(indexPath)) {
|
|
99
|
+
res.status(500).send("Inspector UI not found. Please build the inspector package.");
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
res.sendFile(indexPath);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
mountInspector
|
|
107
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"favicon-proxy.d.ts","sourceRoot":"","sources":["../../src/server/favicon-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAG3B,QAAA,MAAM,GAAG,4EAAa,CAAA;AAqJtB,eAAe,GAAG,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Inspector - Middleware for mounting inspector UI on Express apps
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for importing the inspector as a library.
|
|
5
|
+
* For standalone server usage, see standalone.ts
|
|
6
|
+
*/
|
|
7
|
+
export { mountInspector } from './middleware.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { MCPSession } from 'mcp-use';
|
|
2
|
+
interface MCPServer {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
url?: string;
|
|
6
|
+
command?: string;
|
|
7
|
+
status: 'connected' | 'disconnected' | 'error';
|
|
8
|
+
session?: MCPSession;
|
|
9
|
+
tools: any[];
|
|
10
|
+
resources: any[];
|
|
11
|
+
lastActivity: Date;
|
|
12
|
+
}
|
|
13
|
+
export declare class MCPInspector {
|
|
14
|
+
private servers;
|
|
15
|
+
private client;
|
|
16
|
+
constructor();
|
|
17
|
+
listServers(): Promise<MCPServer[]>;
|
|
18
|
+
connectToServer(url?: string, command?: string): Promise<MCPServer>;
|
|
19
|
+
getServer(id: string): Promise<MCPServer | null>;
|
|
20
|
+
executeTool(serverId: string, toolName: string, input: any): Promise<any>;
|
|
21
|
+
getServerTools(serverId: string): Promise<any[]>;
|
|
22
|
+
getServerResources(serverId: string): Promise<any[]>;
|
|
23
|
+
disconnectServer(serverId: string): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=mcp-inspector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-inspector.d.ts","sourceRoot":"","sources":["../../src/server/mcp-inspector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzC,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,WAAW,GAAG,cAAc,GAAG,OAAO,CAAA;IAC9C,OAAO,CAAC,EAAE,UAAU,CAAA;IACpB,KAAK,EAAE,GAAG,EAAE,CAAA;IACZ,SAAS,EAAE,GAAG,EAAE,CAAA;IAChB,YAAY,EAAE,IAAI,CAAA;CACnB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAoC;IACnD,OAAO,CAAC,MAAM,CAAW;;IAMnB,WAAW,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IAInC,eAAe,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAsEnE,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAIhD,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAwBzE,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAQhD,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAQpD,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAYxD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Express } from 'express';
|
|
2
|
+
/**
|
|
3
|
+
* Mount the MCP Inspector UI at a specified path on an Express app
|
|
4
|
+
* Similar to how FastAPI mounts Swagger UI at /docs
|
|
5
|
+
*
|
|
6
|
+
* @param app - Express application instance
|
|
7
|
+
* @param path - Mount path (default: '/inspector')
|
|
8
|
+
* @param mcpServerUrl - Optional MCP server URL to auto-connect to
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { createMCPServer } from 'mcp-use'
|
|
13
|
+
* import { mountInspector } from '@mcp-use/inspector'
|
|
14
|
+
*
|
|
15
|
+
* const server = createMCPServer('my-server')
|
|
16
|
+
* mountInspector(server) // Mounts at /inspector
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare function mountInspector(app: Express, path?: string, mcpServerUrl?: string): void;
|
|
20
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/server/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAA;AASzD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,GAAE,MAAqB,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CA+IrG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function startServer(): Promise<{
|
|
2
|
+
port: number;
|
|
3
|
+
fetch: (request: Request, Env?: unknown, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
|
|
4
|
+
}>;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
startServer: typeof startServer;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AA2QA,iBAAe,WAAW;;;GA4DzB;;;;AAOD,wBAA8B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare function startServer(): Promise<{
|
|
2
|
+
port: number;
|
|
3
|
+
fetch: (request: Request, Env?: unknown, executionCtx?: import("hono").ExecutionContext) => Response | Promise<Response>;
|
|
4
|
+
}>;
|
|
5
|
+
declare const _default: {
|
|
6
|
+
startServer: typeof startServer;
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
//# sourceMappingURL=unified.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../src/server/unified.ts"],"names":[],"mappings":"AA2QA,iBAAe,WAAW;;;GA8DzB;;;;AAOD,wBAA8B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-use/inspector",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.2.1",
|
|
5
|
+
"description": "MCP Inspector - A tool for inspecting and debugging MCP servers",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"mcp",
|
|
10
|
+
"inspector",
|
|
11
|
+
"debug",
|
|
12
|
+
"tools"
|
|
13
|
+
],
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/server/index.d.ts",
|
|
17
|
+
"import": "./dist/server/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/server/index.js",
|
|
21
|
+
"types": "./dist/server/index.d.ts",
|
|
22
|
+
"bin": {
|
|
23
|
+
"mcp-inspect": "./dist/cli/inspect.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"express": "^4.18.0"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@hono/node-server": "^1.19.5",
|
|
33
|
+
"@mcp-ui/client": "^5.12.1",
|
|
34
|
+
"@modelcontextprotocol/sdk": "1.12.1",
|
|
35
|
+
"@radix-ui/react-alert-dialog": "^1.1.15",
|
|
36
|
+
"@radix-ui/react-dialog": "^1.1.15",
|
|
37
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
38
|
+
"@radix-ui/react-label": "^2.1.7",
|
|
39
|
+
"@radix-ui/react-select": "^2.2.6",
|
|
40
|
+
"@radix-ui/react-tooltip": "^1.2.8",
|
|
41
|
+
"@tailwindcss/cli": "^4.1.14",
|
|
42
|
+
"@tailwindcss/vite": "^4.1.14",
|
|
43
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
44
|
+
"class-variance-authority": "^0.7.1",
|
|
45
|
+
"clsx": "^2.1.1",
|
|
46
|
+
"cmdk": "^1.1.1",
|
|
47
|
+
"express": "^4.18.0",
|
|
48
|
+
"framer-motion": "^12.23.22",
|
|
49
|
+
"hono": "^4.0.0",
|
|
50
|
+
"lucide-react": "^0.545.0",
|
|
51
|
+
"motion": "^12.23.22",
|
|
52
|
+
"next-themes": "^0.4.6",
|
|
53
|
+
"react": "^19.2.0",
|
|
54
|
+
"react-dom": "^19.2.0",
|
|
55
|
+
"react-resizable-panels": "^3.0.6",
|
|
56
|
+
"react-router-dom": "^7.9.3",
|
|
57
|
+
"react-syntax-highlighter": "^15.6.6",
|
|
58
|
+
"sonner": "^2.0.7",
|
|
59
|
+
"tailwind-merge": "^3.3.1",
|
|
60
|
+
"vite-express": "^0.21.1",
|
|
61
|
+
"mcp-use": "0.3.0"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@antfu/eslint-config": "^5.4.1",
|
|
68
|
+
"@eslint-react/eslint-plugin": "^1.38.4",
|
|
69
|
+
"@radix-ui/react-slot": "^1.2.3",
|
|
70
|
+
"@types/express": "^4.17.0",
|
|
71
|
+
"@types/node": "^24.7.0",
|
|
72
|
+
"@types/react": "^19.2.2",
|
|
73
|
+
"@types/react-dom": "^19.2.1",
|
|
74
|
+
"@vitejs/plugin-react": "^5.0.4",
|
|
75
|
+
"concurrently": "^9.2.1",
|
|
76
|
+
"eslint": "^9.36.0",
|
|
77
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
78
|
+
"eslint-plugin-react-refresh": "^0.4.0",
|
|
79
|
+
"tailwindcss": "^4.1.14",
|
|
80
|
+
"tsx": "^4.6.0",
|
|
81
|
+
"tw-animate-css": "^1.4.0",
|
|
82
|
+
"typescript": "^5.9.3",
|
|
83
|
+
"vite": "^7.1.9"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"dev": "concurrently \"npm run dev:client\" \"npm run dev:server\"",
|
|
87
|
+
"dev:client": "vite --port 3000",
|
|
88
|
+
"dev:server": "VITE_DEV=true tsx watch src/server/server.ts",
|
|
89
|
+
"dev:standalone": "tsx watch src/server/server.ts",
|
|
90
|
+
"build": "npm run build:client && npm run build:server",
|
|
91
|
+
"build:client": "vite build",
|
|
92
|
+
"build:server": "tsup src/server/index.ts --format esm && tsc -p tsconfig.server.json --emitDeclarationOnly --declaration",
|
|
93
|
+
"start": "node dist/server/server.js",
|
|
94
|
+
"preview": "vite preview",
|
|
95
|
+
"type-check": "tsc --noEmit",
|
|
96
|
+
"lint": "eslint .",
|
|
97
|
+
"lint:fix": "eslint . --fix",
|
|
98
|
+
"install:yarn": "yarn install",
|
|
99
|
+
"install:pnpm": "pnpm install",
|
|
100
|
+
"install:npm": "npm install",
|
|
101
|
+
"lint:yarn": "yarn eslint . --fix",
|
|
102
|
+
"lint:npm": "npm run lint:fix",
|
|
103
|
+
"lint:pnpm": "pnpm lint:fix"
|
|
104
|
+
}
|
|
105
|
+
}
|