Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit 79e5bfa

Browse files
committed
refactor: update build scripts and improve inspector middleware
- Modify build script to separate mcp-use and other builds for better clarity - Adjust inspector middleware to enhance routing and serve the main HTML file for the root path - Ensure proper handling of trailing slashes in inspector routes
1 parent f869d50 commit 79e5bfa

3 files changed

Lines changed: 24 additions & 9 deletions

File tree

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"packages/*"
88
],
99
"scripts": {
10-
"build": "pnpm run -r build",
10+
"build": "pnpm run build:mcp-use && pnpm run build:other",
11+
"build:mcp-use": "pnpm --filter mcp-use build",
12+
"build:other": "pnpm --filter '!mcp-use' --filter '!test_app' build",
1113
"test": "pnpm run -r test",
1214
"lint": "eslint .",
1315
"lint:fix": "eslint . --fix",

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ program
171171
processes.push(serverProc);
172172

173173
// Auto-open inspector if enabled
174-
if (options.open) {
174+
if (options.open !== false) {
175175
const startTime = Date.now();
176176
const ready = await waitForServer(port);
177177
if (ready) {

packages/inspector/src/server/middleware.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,6 @@ export function mountInspector(app: Express, path: string = '/inspector', mcpSer
125125
}
126126
})
127127

128-
// Redirect /inspector/ to /inspector (remove trailing slash)
129-
app.get(`${basePath}/`, (_req: Request, res: Response) => {
130-
res.redirect(301, basePath)
131-
})
132-
133128
// Handle OAuth callback redirects - redirect /oauth/callback to /inspector/oauth/callback
134129
// This helps when OAuth providers are configured with the wrong redirect URL
135130
if (basePath !== '') {
@@ -142,8 +137,26 @@ export function mountInspector(app: Express, path: string = '/inspector', mcpSer
142137
})
143138
}
144139

145-
// Serve the main HTML file for all inspector routes
146-
app.get(`${basePath}*`, (_req: Request, res: Response) => {
140+
// Serve the main HTML file for the root inspector path (exact match)
141+
app.get(basePath, (_req: Request, res: Response) => {
142+
const indexPath = join(clientDistPath, 'index.html')
143+
144+
if (!existsSync(indexPath)) {
145+
res.status(500).send('Inspector UI not found. Please build the inspector package.')
146+
return
147+
}
148+
149+
// Serve the HTML file (Vite built with base: '/inspector')
150+
res.sendFile(indexPath)
151+
})
152+
153+
// Redirect /inspector/ to /inspector (remove trailing slash)
154+
app.get(`${basePath}/`, (_req: Request, res: Response) => {
155+
res.redirect(301, basePath)
156+
})
157+
158+
// Serve the main HTML file for all other inspector routes (SPA routing)
159+
app.get(`${basePath}/*`, (_req: Request, res: Response) => {
147160
const indexPath = join(clientDistPath, 'index.html')
148161

149162
if (!existsSync(indexPath)) {

0 commit comments

Comments
 (0)