diff --git a/MCP.md b/MCP.md index 3b93189855..e12edb0b2e 100644 --- a/MCP.md +++ b/MCP.md @@ -33,6 +33,9 @@ the defaults. > also reach the MCP server directly at `/mcp`, but not all > deployments expose the backend, so these docs use frontend paths. +Set `DISABLE_MCP_INSTRUCTIONS=true` on the API to send no server instructions, +for example on all but one of several instances that the same agent connects. + ## Connecting with Google login When your administrator has enabled [WorkOS AuthKit](DEPLOY.md#workos-authkit), diff --git a/packages/api/src/config.ts b/packages/api/src/config.ts index a8b24858e4..10cc73ddc8 100644 --- a/packages/api/src/config.ts +++ b/packages/api/src/config.ts @@ -76,6 +76,7 @@ export const DEFAULT_CONNECTIONS = env.DEFAULT_CONNECTIONS; export const DEFAULT_SOURCES = env.DEFAULT_SOURCES; export const IS_PROMQL_ENABLED = env.ENABLE_PROMQL === 'true'; +export const DISABLE_MCP_INSTRUCTIONS = env.DISABLE_MCP_INSTRUCTIONS === 'true'; export const EXTERNAL_API_RATE_LIMIT_MAX = (() => { const parsed = Number(env.EXTERNAL_API_RATE_LIMIT_MAX); diff --git a/packages/api/src/mcp/mcpServer.ts b/packages/api/src/mcp/mcpServer.ts index 1e4cd4a609..9f3c1a7dbd 100644 --- a/packages/api/src/mcp/mcpServer.ts +++ b/packages/api/src/mcp/mcpServer.ts @@ -1,7 +1,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import type { Implementation } from '@modelcontextprotocol/sdk/types.js'; -import { CODE_VERSION, FRONTEND_URL } from '@/config'; +import { CODE_VERSION, DISABLE_MCP_INSTRUCTIONS, FRONTEND_URL } from '@/config'; import dashboardPrompts from './prompts/dashboards/index'; import alertsTools from './tools/alerts/index'; @@ -42,8 +42,12 @@ const PROMQL_INSTRUCTIONS = 'clickstack_promql. The builder tools do not read them; clickstack_sql only\n' + 'inspects the raw tags and samples of a ClickHouse TimeSeries table.'; -/** The instructions a client sees. PromQL is mentioned only while it is enabled. */ -function serverInstructions(context: McpContext): string { +/** + * The instructions a client sees: none with DISABLE_MCP_INSTRUCTIONS, and + * PromQL only while it is enabled. + */ +function serverInstructions(context: McpContext): string | undefined { + if (DISABLE_MCP_INSTRUCTIONS) return undefined; return isPromqlEnabled(context) ? `${SERVER_INSTRUCTIONS}\n\n${PROMQL_INSTRUCTIONS}` : SERVER_INSTRUCTIONS;