Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MCP.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ the defaults.
> also reach the MCP server directly at `<backend_url>/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),
Expand Down
1 change: 1 addition & 0 deletions packages/api/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 7 additions & 3 deletions packages/api/src/mcp/mcpServer.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
Expand Down
Loading