Skip to content
Merged
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 packages/core/src/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ vi.mock('../tools/mcp-client-manager.js', () => ({
McpClientManager: vi.fn().mockImplementation(() => ({
startConfiguredMcpServers: vi.fn(),
getMcpInstructions: vi.fn().mockReturnValue('MCP Instructions'),
setMainRegistries: vi.fn(),
})),
}));

Expand Down Expand Up @@ -368,6 +369,7 @@ describe('Server Config (config.ts)', () => {
mcpStarted = true;
}),
getMcpInstructions: vi.fn(),
setMainRegistries: vi.fn(),
}) as Partial<McpClientManager> as McpClientManager,
);

Expand Down Expand Up @@ -401,6 +403,7 @@ describe('Server Config (config.ts)', () => {
mcpStarted = true;
}),
getMcpInstructions: vi.fn(),
setMainRegistries: vi.fn(),
}) as Partial<McpClientManager> as McpClientManager,
);

Expand Down
21 changes: 19 additions & 2 deletions packages/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ export interface AgentOverride {
modelConfig?: ModelConfig;
runConfig?: AgentRunConfig;
enabled?: boolean;
tools?: string[];
mcpServers?: Record<string, MCPServerConfig>;
}

export interface AgentSettings {
Expand Down Expand Up @@ -520,6 +522,7 @@ export interface ConfigParameters {
question?: string;

coreTools?: string[];
mainAgentTools?: string[];
/** @deprecated Use Policy Engine instead */
allowedTools?: string[];
/** @deprecated Use Policy Engine instead */
Expand Down Expand Up @@ -675,6 +678,7 @@ export class Config implements McpContext, AgentLoopContext {
readonly enableConseca: boolean;

private readonly coreTools: string[] | undefined;
private readonly mainAgentTools: string[] | undefined;
/** @deprecated Use Policy Engine instead */
private readonly allowedTools: string[] | undefined;
/** @deprecated Use Policy Engine instead */
Expand Down Expand Up @@ -888,6 +892,7 @@ export class Config implements McpContext, AgentLoopContext {
this.question = params.question;

this.coreTools = params.coreTools;
this.mainAgentTools = params.mainAgentTools;
this.allowedTools = params.allowedTools;
this.excludeTools = params.excludeTools;
this.toolDiscoveryCommand = params.toolDiscoveryCommand;
Expand Down Expand Up @@ -1231,10 +1236,14 @@ export class Config implements McpContext, AgentLoopContext {
discoverToolsHandle?.end();
this.mcpClientManager = new McpClientManager(
this.clientVersion,
this._toolRegistry,
this,
this.eventEmitter,
);
this.mcpClientManager.setMainRegistries({
toolRegistry: this._toolRegistry,
promptRegistry: this.promptRegistry,
resourceRegistry: this.resourceRegistry,
});
// We do not await this promise so that the CLI can start up even if
// MCP servers are slow to connect.
this.mcpInitializationPromise = Promise.allSettled([
Expand Down Expand Up @@ -1887,6 +1896,10 @@ export class Config implements McpContext, AgentLoopContext {
return this.coreTools;
}

getMainAgentTools(): string[] | undefined {
return this.mainAgentTools;
}

getAllowedTools(): string[] | undefined {
return this.allowedTools;
}
Expand Down Expand Up @@ -2982,7 +2995,11 @@ export class Config implements McpContext, AgentLoopContext {
}

async createToolRegistry(): Promise<ToolRegistry> {
const registry = new ToolRegistry(this, this.messageBus);
const registry = new ToolRegistry(
this,
this.messageBus,
/* isMainRegistry= */ true,
);

// helper to create & register core tools that are enabled
const maybeRegister = (
Expand Down
Loading
Loading