Security fix for MCP
This commit is contained in:
@@ -58,9 +58,12 @@ export function createHealthRoute(args: CreateHealthRouteArgs): () => Promise<Re
|
||||
status: 200,
|
||||
})
|
||||
} catch (err) {
|
||||
// Log the real error for ops; keep the PUBLIC body generic — a 503 with
|
||||
// `db: 'down'` is all an orchestrator needs, and raw DB error text (host,
|
||||
// credentials-in-URL, driver internals) must not leak on a public route.
|
||||
console.warn('[ipal] createHealthRoute: database unreachable:', err)
|
||||
const body = {
|
||||
db: 'down',
|
||||
error: err instanceof Error ? err.message : 'unknown',
|
||||
status: 'error',
|
||||
timestamp: new Date().toISOString(),
|
||||
tookMs: Date.now() - startedAt,
|
||||
|
||||
@@ -187,7 +187,11 @@ export function createMcpRoute(args: CreateMcpRouteArgs) {
|
||||
if (p.name === 'get_page') {return rpcResult(id, toolText(await getPage(toolArgs)))}
|
||||
return rpcResult(id, toolText(`Unknown tool: ${p.name}`, true))
|
||||
} catch (err) {
|
||||
return rpcResult(id, toolText(err instanceof Error ? err.message : 'Tool error', true))
|
||||
// Log the real error server-side; return a GENERIC message to the
|
||||
// (anonymous) caller so internal details — DB schema, host, stack —
|
||||
// never leak over a public endpoint.
|
||||
console.warn('[ipal] createMcpRoute: tool execution failed:', err)
|
||||
return rpcResult(id, toolText('Tool execution failed.', true))
|
||||
}
|
||||
}
|
||||
case 'tools/list':
|
||||
|
||||
Reference in New Issue
Block a user