From 9fdab5fb971aaa330b2d1bec61edd53ec92771de Mon Sep 17 00:00:00 2001 From: Oliver Kieselbach Date: Sat, 4 Apr 2026 13:47:15 +0200 Subject: [PATCH] info exposure reduced during startup --- src/McpServer/autopilot-monitor-mcp/src/index.ts | 15 +++------------ .../autopilot-monitor-mcp/src/tools/admin.ts | 12 +++++++----- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/McpServer/autopilot-monitor-mcp/src/index.ts b/src/McpServer/autopilot-monitor-mcp/src/index.ts index 2201373a..cbb124bb 100644 --- a/src/McpServer/autopilot-monitor-mcp/src/index.ts +++ b/src/McpServer/autopilot-monitor-mcp/src/index.ts @@ -47,14 +47,9 @@ app.use(express.urlencoded({ extended: true })); // OAuth proxy (must be before auth middleware) app.use(createOAuthRouter()); -// Health check +// Health check — minimal response to avoid leaking server internals app.get('/health', (_req, res) => { - res.json({ - status: 'healthy', - server: 'autopilot-monitor-mcp', - version: SERVER_VERSION, - search: { backend: knowledgeBase.name, documents: knowledgeBase.size }, - }); + res.json({ status: 'healthy' }); }); // Track transports by session ID for reuse @@ -136,11 +131,7 @@ app.all('/mcp', async (req, res) => { }); const server = app.listen(PORT, '0.0.0.0', () => { - console.error(`Autopilot-Monitor MCP Server running (Streamable HTTP on port ${PORT})`); - console.error(`API URL: ${process.env.AUTOPILOT_API_URL ?? 'https://autopilotmonitor-api.azurewebsites.net'}`); - console.error(`Search backend: ${knowledgeBase.name} | Documents: ${knowledgeBase.size} | Rules dir: ${RULES_DIR}`); - console.error(`Health: http://localhost:${PORT}/health`); - console.error(`MCP endpoint: http://localhost:${PORT}/mcp`); + console.error(`Autopilot-Monitor MCP Server running on port ${PORT}`); }); // --- Graceful shutdown --- diff --git a/src/McpServer/autopilot-monitor-mcp/src/tools/admin.ts b/src/McpServer/autopilot-monitor-mcp/src/tools/admin.ts index f313025e..59650e1b 100644 --- a/src/McpServer/autopilot-monitor-mcp/src/tools/admin.ts +++ b/src/McpServer/autopilot-monitor-mcp/src/tools/admin.ts @@ -269,12 +269,12 @@ export function registerAdminTools(server: McpServer): void { server.tool( 'query_raw_events', 'TIER 2 — RAW CROSS-SESSION EVENT QUERY (fallback for broader scope). ' + - 'Query raw enrollment events with flexible filters across sessions within a tenant. ' + - 'tenantId is always required (events are partitioned per tenant). Global Admin can query any tenant. ' + + 'Query raw enrollment events with flexible filters across sessions. ' + + 'Omit tenantId for cross-tenant search (Global Admin), or specify tenantId for single-tenant. ' + 'Use this when search_events_semantic does not cover the time range or session scope you need, ' + 'or when you need exact event-type filtering across many sessions. Returns raw event data.', { - tenantId: z.string().describe('Tenant ID to query (required). Global Admin can query any tenant.'), + tenantId: z.string().optional().describe('Tenant ID. Omit for cross-tenant search (Global Admin only).'), sessionId: z.string().optional().describe('Filter to a specific session'), eventType: z.string().optional().describe('Event type filter (e.g. "app_install_failed", "error_detected")'), severity: z.enum(['Info', 'Warning', 'Error', 'Critical']).optional(), @@ -287,8 +287,10 @@ export function registerAdminTools(server: McpServer): void { async (args) => { try { const { tenantId, ...rest } = args; - const params: Record = { ...rest, tenantId }; - const data = await apiFetch(`/api/raw/events${buildQuery(params)}`); + const params: Record = { ...rest }; + if (tenantId) params.tenantId = tenantId; + const basePath = tenantId ? '/api/raw/events' : '/api/global/raw/events'; + const data = await apiFetch(`${basePath}${buildQuery(params)}`); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }] }; } catch (error: unknown) { return toolError('query_raw_events', args, error);