Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

fix(claude): exclude connector MCP tools from sessionSettings allow list

Vedant3d35bf55d0ea
diff --git a/console/packages/agent-providers/src/claude/claude-adapter.test.ts b/console/packages/agent-providers/src/claude/claude-adapter.test.ts
index 2e563e3a2..98e53f69e 100644
--- a/console/packages/agent-providers/src/claude/claude-adapter.test.ts
+++ b/console/packages/agent-providers/src/claude/claude-adapter.test.ts
@@ -227,6 +227,25 @@ describe('ClaudeAdapter session lifecycle', () => {
expect(native.options().settings).toBeUndefined();
});
+ it('excludes connector MCP servers from session settings allow permissions', async () => {
+ const sdk = createFakeSdk();
+ const adapter = new ClaudeAdapter({ query: sdk.query, claudeExecutablePath: '/bin/claude' });
+ await adapter.startSession(
+ startInput({
+ mcpServers: {
+ switch: { transport: 'stdio', command: 'node', args: ['server.mjs'] },
+ atlassian: { transport: 'http', url: 'http://127.0.0.1:4100/mcp' },
+ other: { transport: 'stdio', command: 'node', args: ['other.mjs'] },
+ },
+ connectorMcpServers: ['atlassian'],
+ })
+ );
+ expect(sdk.options().settings).toEqual({
+ enabledPlugins: { 'switch-connector@switch-plugins': false },
+ permissions: { allow: ['mcp__switch', 'mcp__other'] },
+ });
+ });
+
it('runs as a named agent definition, and as none when the caller names none', async () => {
const sdk = createFakeSdk();
const adapter = new ClaudeAdapter({ query: sdk.query, claudeExecutablePath: '/bin/claude' });
diff --git a/console/packages/agent-providers/src/claude/claude-adapter.ts b/console/packages/agent-providers/src/claude/claude-adapter.ts
index 67e525517..d2d79b133 100644
--- a/console/packages/agent-providers/src/claude/claude-adapter.ts
+++ b/console/packages/agent-providers/src/claude/claude-adapter.ts
@@ -366,26 +366,34 @@ function turnStatusMessage(result: SDKResultMessage, outcome: TurnOutcome): stri
/**
* The settings a session adds to the person's own Claude Code settings.
*
- * The tools of the servers the host registers are allowed outright. `canUseTool`
- * allows them too, but Claude Code's auto mode, when it is the person's
- * default, asks its classifier before `canUseTool` is ever reached, and the
- * classifier refuses a Switch tool that hands out access as a permission grant,
- * whatever Switch itself allows. An allow rule is settled before the classifier.
+ * The tools of the servers the host registers, other than connectors, are
+ * allowed outright. `canUseTool` allows them too, but Claude Code's auto mode,
+ * when it is the person's default, asks its classifier before `canUseTool` is
+ * ever reached, and the classifier refuses a Switch tool that hands out access
+ * as a permission grant, whatever Switch itself allows. An allow rule is
+ * settled before the classifier.
+ *
+ * Connectors get no rule here: an allow rule would settle their calls before
+ * the classifier and `canUseTool`, so they would skip the approval the runtime
+ * mode asks for. Their tools follow the runtime mode instead (see
+ * `PERMISSION_MODE_BY_RUNTIME_MODE`): full access runs them, auto lets the
+ * classifier decide, and the other modes ask the person.
*
* The connector plugin Switch used to ship would add a second Switch server with
* its own connection; it is kept off for installs that still have it.
*/
function sessionSettings(
- mcpServers: Record<string, McpServerConfig>
+ mcpServers: Record<string, McpServerConfig>,
+ connectorMcpServers: readonly string[]
): { settings: Record<string, unknown> } | Record<string, never> {
- const names = Object.keys(mcpServers);
- if (names.length === 0) return {};
+ const connectorSet = new Set(connectorMcpServers);
+ const names = Object.keys(mcpServers).filter((name) => !connectorSet.has(name));
+ const hasSwitch = Boolean(mcpServers.switch);
+ if (names.length === 0 && !hasSwitch) return {};
return {
settings: {
- ...(mcpServers.switch
- ? { enabledPlugins: { 'switch-connector@switch-plugins': false } }
- : {}),
- permissions: { allow: names.map((name) => `mcp__${name}`) },
+ ...(hasSwitch ? { enabledPlugins: { 'switch-connector@switch-plugins': false } } : {}),
+ ...(names.length > 0 ? { permissions: { allow: names.map((name) => `mcp__${name}`) } } : {}),
},
};
}
@@ -478,7 +486,7 @@ export class ClaudeAdapter implements ProviderAdapter {
env: input.env,
permissionMode,
strictMcpConfig: false,
- ...sessionSettings(mcpServers),
+ ...sessionSettings(mcpServers, input.connectorMcpServers),
canUseTool: this.makeCanUseTool(input.sessionId),
...(permissionMode === 'bypassPermissions' ? { allowDangerouslySkipPermissions: true } : {}),
...(executable ? { pathToClaudeCodeExecutable: executable } : {}),