core: improve MCP reliability and add status monitoring

- Added 5-second timeout to MCP client verification to prevent hanging connections
- New GET /mcp endpoint to monitor server connection status
- Automatically removes unresponsive MCP clients during initialization
This commit is contained in:
Dax Raad
2025-10-07 04:04:19 -04:00
parent 27c211ef86
commit a440e09cfe
4 changed files with 82 additions and 1 deletions

View File

@@ -31,6 +31,7 @@ import { SessionRevert } from "../session/revert"
import { lazy } from "../util/lazy"
import { Todo } from "../session/todo"
import { InstanceBootstrap } from "../project/bootstrap"
import { MCP } from "../mcp"
const ERRORS = {
400: {
@@ -1183,6 +1184,26 @@ export namespace Server {
return c.json(modes)
},
)
.get(
"/mcp",
describeRoute({
description: "Get MCP server status",
operationId: "mcp.status",
responses: {
200: {
description: "MCP server status",
content: {
"application/json": {
schema: resolver(z.any()),
},
},
},
},
}),
async (c) => {
return c.json(await MCP.status())
},
)
.post(
"/tui/append-prompt",
describeRoute({