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
7 changes: 7 additions & 0 deletions .changeset/trueforge-mcp-id-tool-info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@truefoundry/trueforge': patch
'@truefoundry/trueforge-core': patch
'@truefoundry/trueforge-assistant-ui-runtime': patch
---

The built-in TrueForge MCP now uses the same id and name, `trueforge:mcp`, and labels its tools as `truefoundry-system` instead of `mcp`.
2 changes: 1 addition & 1 deletion packages/assistant-ui-runtime/src/collectPending.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function derivePendingMcpAuth(

const UPDATE_CURRENT_SESSION_TOOL_NAME = 'update_current_session';
/** Mirrors `TRUEFORGE_MCP_ID` in trueforge-core. This package does not depend on it. */
const TRUEFORGE_MCP_SERVER_ID = 'built-in:trueforge-mcp';
const TRUEFORGE_MCP_SERVER_ID = 'trueforge:mcp';

function isUpdateCurrentSessionCall(part: ToolCallPart): boolean {
// The TrueForge server is deferred, so its tools arrive as `call_tool` and the
Expand Down
23 changes: 4 additions & 19 deletions packages/assistant-ui-runtime/test/collectPending.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,13 @@ describe('findLatestSessionSpecUpdate', () => {
const messages = [
assistantMessage('a1', {
content: [
toolCall(
'first',
'call_tool',
{ mcp_server: 'built-in:trueforge-mcp', tool_name: 'update_current_session' },
'{}',
),
toolCall('first', 'call_tool', { mcp_server: 'trueforge:mcp', tool_name: 'update_current_session' }, '{}'),
],
}),
userMessage('u2'),
assistantMessage('a2', {
content: [
toolCall(
'second',
'call_tool',
{ mcp_server: 'built-in:trueforge-mcp', tool_name: 'update_current_session' },
'{}',
),
toolCall('second', 'call_tool', { mcp_server: 'trueforge:mcp', tool_name: 'update_current_session' }, '{}'),
],
}),
];
Expand All @@ -183,15 +173,10 @@ describe('findLatestSessionSpecUpdate', () => {
toolCall('other-server', 'call_tool', { mcp_server: 'github', tool_name: 'update_current_session' }, '{}'),
toolCall('direct', 'update_current_session', {}, '{}'),
toolCall('running', 'call_tool', {
mcp_server: 'built-in:trueforge-mcp',
mcp_server: 'trueforge:mcp',
tool_name: 'update_current_session',
}),
toolCall(
'done',
'call_tool',
{ mcp_server: 'built-in:trueforge-mcp', tool_name: 'update_current_session' },
'{}',
),
toolCall('done', 'call_tool', { mcp_server: 'trueforge:mcp', tool_name: 'update_current_session' }, '{}'),
],
}),
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function specWantsSandbox(spec: AgentSpec): boolean {
return spec.config.sandbox.enabled;
}

/** Runtime id of the built-in TrueForge management MCP. Display name stays on the connection. */
export const TRUEFORGE_MCP_ID = 'built-in:trueforge-mcp';
/** Runtime id and display name of the built-in TrueForge management MCP. */
export const TRUEFORGE_MCP_ID = 'trueforge:mcp';
Comment thread
heerambavi1998 marked this conversation as resolved.
Resolved

const TRUEFORGE_MCP_SELECTORS: ToolSelectorConfig = {
enableTools: DEFAULT_ENABLE_TOOLS,
Expand Down Expand Up @@ -288,6 +288,7 @@ export class TurnResourceResolver<
logger: this.deps.logger,
tracing: input.tracing,
signal: input.signal,
isSystem: true,
}),
),
});
Expand Down
6 changes: 5 additions & 1 deletion packages/trueforge-core/src/core/mcp/RemoteMCP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export class RemoteMCP implements ToolSource {
private readonly requestTimeoutMs: number;
private readonly connectTimeoutMs: number;
private readonly maxResponseBytes: number;
/** When true, tool_info.type is `truefoundry-system` instead of `mcp`. */
private readonly isSystem: boolean;
// Redacted display url for trace spans (derived from url; unused when tracing is a no-op).
private readonly traceUrl: string;

Expand All @@ -97,6 +99,7 @@ export class RemoteMCP implements ToolSource {
connectTimeoutMs: number;
maxResponseBytes?: number | undefined;
signal: AbortSignal;
isSystem?: boolean;
}) {
this.name = params.connection.name;
this.id = params.id;
Expand All @@ -108,6 +111,7 @@ export class RemoteMCP implements ToolSource {
this.requestTimeoutMs = params.requestTimeoutMs;
this.connectTimeoutMs = params.connectTimeoutMs;
this.maxResponseBytes = params.maxResponseBytes ?? DEFAULT_MAX_MCP_RESPONSE_BYTES;
this.isSystem = params.isSystem ?? false;
this.logger = params.logger;
this.tracing = params.tracing ?? NOOP_AGENT_TRACING;
this.traceUrl = redactUrlForTrace(params.connection.url);
Expand Down Expand Up @@ -283,7 +287,7 @@ export class RemoteMCP implements ToolSource {
toolCallInfo(params: CallToolRequest['params'], _resolveUnderlyingTool?: boolean): Promise<InternalToolCallInfo> {
void _resolveUnderlyingTool;
return Promise.resolve({
type: 'mcp',
type: this.isSystem ? 'truefoundry-system' : 'mcp',
original_tool_name: params.name,
mcp_server_id: this.id,
mcp_server_name: this.name,
Expand Down
2 changes: 0 additions & 2 deletions packages/trueforge-core/src/core/runtime/AgentThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,6 @@ export class AgentThread {

// Preloaded builtins (current time, sub-agents, and so on) are already on the tool list.
// Deferred discovery tools exist only when some server still has tools to discover.
// DeferredTool keys each server by its `id`; built-ins carry a namespaced id
// (e.g. `built-in.*`, `capability:*`) so they can't collide with a user server's name.
const deferredServers = [...this.systemToolSets, ...(this.definition.toolSets ?? [])].filter(
toolSet => !toolSet.preload,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('TurnResourceResolver rootCapabilities', () => {
id === TRUEFORGE_MCP_ID
? {
url: 'http://internal.example/mcp',
name: 'trueforge-mcp',
name: TRUEFORGE_MCP_ID,
description: 'TrueForge management',
}
: undefined,
Expand All @@ -87,8 +87,9 @@ describe('TurnResourceResolver rootCapabilities', () => {
const root = await resolver.resolveAgentDefinition({ spec, signal, tracing });
const nested = await resolver.resolveAgentDefinition({ spec, signal, tracing, agent_info: child });

expect(root.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe('built-in:trueforge-mcp');
expect(nested.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe('built-in:trueforge-mcp');
expect(root.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe(TRUEFORGE_MCP_ID);
expect(nested.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe(TRUEFORGE_MCP_ID);
expect(root.extraCapabilities?.[0]?.systemToolSets?.[0]?.name).toBe(TRUEFORGE_MCP_ID);
});

it('keeps direct capability sources distinct from configured MCPs with the same display name', async () => {
Expand All @@ -104,7 +105,7 @@ describe('TurnResourceResolver rootCapabilities', () => {
id === TRUEFORGE_MCP_ID
? {
url: 'http://internal.example/mcp',
name: 'trueforge-mcp',
name: TRUEFORGE_MCP_ID,
description: 'TrueForge management',
}
: {
Expand Down Expand Up @@ -138,8 +139,8 @@ describe('TurnResourceResolver rootCapabilities', () => {
});

expect(resolved.definition.toolSets?.[0]?.id).toBe('trueforge-mcp');
expect(resolved.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe('built-in:trueforge-mcp');
expect(resolved.extraCapabilities?.[0]?.systemToolSets?.[0]?.name).toBe('trueforge-mcp');
expect(resolved.extraCapabilities?.[0]?.systemToolSets?.[0]?.id).toBe(TRUEFORGE_MCP_ID);
expect(resolved.extraCapabilities?.[0]?.systemToolSets?.[0]?.name).toBe(TRUEFORGE_MCP_ID);
});

it('omits extraCapabilities when none are configured', async () => {
Expand Down
25 changes: 25 additions & 0 deletions packages/trueforge-core/tests/core/mcp/remoteMcpServer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,31 @@ function makeServer(params: {
}

describe('RemoteMCP + ToolSet', () => {
it('can label tools as truefoundry-system for built-in management MCP', async () => {
const remote = new RemoteMCP({
id: 'trueforge:mcp',
connection: {
url: 'https://mcp.example.com/mcp',
name: 'trueforge:mcp',
description: 'TrueForge management',
},
logger: noopLogger,
tracing: NOOP_AGENT_TRACING,
requestTimeoutMs: 60_000,
connectTimeoutMs: 5_000,
signal: new AbortController().signal,
isSystem: true,
});

await expect(remote.toolCallInfo({ name: 'update_current_session' })).resolves.toEqual({
type: 'truefoundry-system',
original_tool_name: 'update_current_session',
mcp_server_id: 'trueforge:mcp',
mcp_server_name: 'trueforge:mcp',
is_approval_required: false,
});
});

it('passes a connection-specific fetch to the MCP transport', async () => {
installFakeConnection();
const fetch = jest.fn() as unknown as RemoteMcpFetch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ describe('AgentThread deferred discovery registration', () => {
const names = await registeredToolNames({
capabilities: [
currentDateTime({ tracing: NOOP_AGENT_TRACING }),
{ systemToolSets: [makeMockIMCPServer({ name: 'trueforge-mcp', preload: false })] },
{ systemToolSets: [makeMockIMCPServer({ name: 'trueforge:mcp', preload: false })] },
],
});

Expand Down
2 changes: 1 addition & 1 deletion packages/trueforge/src/apis/turns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ function buildTrueForgeMcpConnection(input: {
return undefined;
}
return {
name: 'trueforge-mcp',
name: TRUEFORGE_MCP_ID,
description:
"Create, update, and read agents, schedules, and sandbox environments in this deployment. Read this chat's " +
'configuration and the configured models, MCP servers, and skills. Does not run agents or turns.',
Expand Down
3 changes: 2 additions & 1 deletion packages/trueforge/src/mcp/server/trueforge/server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { TRUEFORGE_MCP_ID } from '@truefoundry/trueforge-core/agent-session';
import { z } from 'zod';
import type { McpToolDescriptor } from './openApiTools';
import { runTool } from './result';
Expand Down Expand Up @@ -50,7 +51,7 @@ export function createTrueForgeMcpServer(input: {
tools: readonly CompiledMcpTool[];
}): McpServer {
const server = new McpServer(
{ name: 'trueforge-mcp', title: TRUEFORGE_SERVER_TITLE, version: input.version },
{ name: TRUEFORGE_MCP_ID, title: TRUEFORGE_SERVER_TITLE, version: input.version },
{ instructions: TRUEFORGE_INSTRUCTIONS },
);
registerOpenApiTools(server, input.client, input.tools);
Expand Down
Loading