Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

feat: Approval policies (#914)

Heer Ambavi9b9f12e966ea
diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json
index 9f0c1d3e0..25106ebac 100644
--- a/.github/fern/openapi/openapi.json
+++ b/.github/fern/openapi/openapi.json
@@ -2876,6 +2876,13 @@
},
"MCPServerInitInfo": {
"properties": {
+ "approval_policies": {
+ "additionalProperties": {
+ "$ref": "#/components/schemas/ToolApprovalPolicyAction"
+ },
+ "description": "Sticky per-tool approval policies (keyed by tool name) that auto-allow future calls.",
+ "type": "object"
+ },
"id": {
"description": "Internal MCP server id.",
"type": "string"
@@ -5101,6 +5108,19 @@
],
"type": "object"
},
+ "ToolApprovalPolicyAction": {
+ "discriminator": {
+ "mapping": {
+ "allow_session": "#/components/schemas/ToolApprovalPolicyAllowSession"
+ },
+ "propertyName": "type"
+ },
+ "oneOf": [
+ {
+ "$ref": "#/components/schemas/ToolApprovalPolicyAllowSession"
+ }
+ ]
+ },
"ToolApprovalPolicyAllowSession": {
"properties": {
"expire_at": {
@@ -5123,17 +5143,7 @@
"ToolApprovalPolicyItem": {
"properties": {
"action": {
- "discriminator": {
- "mapping": {
- "allow_session": "#/components/schemas/ToolApprovalPolicyAllowSession"
- },
- "propertyName": "type"
- },
- "oneOf": [
- {
- "$ref": "#/components/schemas/ToolApprovalPolicyAllowSession"
- }
- ]
+ "$ref": "#/components/schemas/ToolApprovalPolicyAction"
},
"name": {
"description": "Tool name on that server.",
diff --git a/docs/openapi.json b/docs/openapi.json
index 9f0c1d3e0..25106ebac 100644
--- a/docs/openapi.json
+++ b/docs/openapi.json
@@ -2876,6 +2876,13 @@
},
"MCPServerInitInfo": {
"properties": {
+ "approval_policies": {
+ "additionalProperties": {
+ "$ref": "#/components/schemas/ToolApprovalPolicyAction"
+ },
+ "description": "Sticky per-tool approval policies (keyed by tool name) that auto-allow future calls.",
+ "type": "object"
+ },
"id": {
"description": "Internal MCP server id.",
"type": "string"
@@ -5101,6 +5108,19 @@
],
"type": "object"
},
+ "ToolApprovalPolicyAction": {
+ "discriminator": {
+ "mapping": {
+ "allow_session": "#/components/schemas/ToolApprovalPolicyAllowSession"
+ },
+ "propertyName": "type"
+ },
+ "oneOf": [
+ {
+ "$ref": "#/components/schemas/ToolApprovalPolicyAllowSession"
+ }
+ ]
+ },
"ToolApprovalPolicyAllowSession": {
"properties": {
"expire_at": {
@@ -5123,17 +5143,7 @@
"ToolApprovalPolicyItem": {
"properties": {
"action": {
- "discriminator": {
- "mapping": {
- "allow_session": "#/components/schemas/ToolApprovalPolicyAllowSession"
- },
- "propertyName": "type"
- },
- "oneOf": [
- {
- "$ref": "#/components/schemas/ToolApprovalPolicyAllowSession"
- }
- ]
+ "$ref": "#/components/schemas/ToolApprovalPolicyAction"
},
"name": {
"description": "Tool name on that server.",
diff --git a/packages/trueforge-core/src/agent-session/TurnHandle.ts b/packages/trueforge-core/src/agent-session/TurnHandle.ts
index 64581effc..e12798500 100644
--- a/packages/trueforge-core/src/agent-session/TurnHandle.ts
+++ b/packages/trueforge-core/src/agent-session/TurnHandle.ts
@@ -517,6 +517,7 @@ export class TurnHandle<TTurnCustom extends object = Record<string, never>> {
name: initInfo.name,
session_id: initInfo.session_id,
transport_type: initInfo.transport_type,
+ approval_policies: initInfo.approval_policies,
})),
});
await this.store.appendToEvents({
diff --git a/packages/trueforge-core/src/agent-session/TurnResourceResolver.ts b/packages/trueforge-core/src/agent-session/TurnResourceResolver.ts
index 9bcfed4a3..2f34b5d36 100644
--- a/packages/trueforge-core/src/agent-session/TurnResourceResolver.ts
+++ b/packages/trueforge-core/src/agent-session/TurnResourceResolver.ts
@@ -205,6 +205,7 @@ export class TurnResourceResolver<
source,
selectors: toSelectors(entry),
preload: entry.preload,
+ approvalPolicies: previousTurn?.snapshot.mcp_servers?.[entry.name]?.approval_policies,
});
}),
);
diff --git a/packages/trueforge-core/src/core/events/schema.ts b/packages/trueforge-core/src/core/events/schema.ts
index 8c629e613..245302cd9 100644
--- a/packages/trueforge-core/src/core/events/schema.ts
+++ b/packages/trueforge-core/src/core/events/schema.ts
@@ -108,11 +108,15 @@ export const ToolApprovalPolicyAllowSessionSchema = z
})
.openapi('ToolApprovalPolicyAllowSession');
+export const ToolApprovalPolicySchema = z
+ .discriminatedUnion('type', [ToolApprovalPolicyAllowSessionSchema])
+ .openapi('ToolApprovalPolicyAction');
+
export const ToolApprovalPolicyItemSchema = z
.object({
server_name: z.string().min(1, 'server_name is required').describe('MCP server name.'),
name: z.string().min(1, 'name is required').describe('Tool name on that server.'),
- action: z.discriminatedUnion('type', [ToolApprovalPolicyAllowSessionSchema]),
+ action: ToolApprovalPolicySchema,
})
.openapi('ToolApprovalPolicyItem');
@@ -366,6 +370,10 @@ export const MCPServerInitInfoSchema = z
.enum(['streamable-http', 'sse'])
.optional()
.describe('Transport used to connect to the MCP server.'),
+ approval_policies: z
+ .record(z.string(), ToolApprovalPolicySchema)
+ .optional()
+ .describe('Sticky per-tool approval policies (keyed by tool name) that auto-allow future calls.'),
})
.openapi('MCPServerInitInfo');
@@ -447,6 +455,7 @@ export type ApprovalDecision = z.infer<typeof ApprovalDecisionSchema>;
export type UserToolApprovalMessage = z.infer<typeof UserToolApprovalMessageSchema>;
export type UserToolResponseMessage = z.infer<typeof UserToolResponseMessageSchema>;
export type ToolApprovalPolicyItem = z.infer<typeof ToolApprovalPolicyItemSchema>;
+export type ToolApprovalPolicyAction = z.infer<typeof ToolApprovalPolicySchema>;
export type UserToolApprovalPolicyMessage = z.infer<typeof UserToolApprovalPolicyMessageSchema>;
export type UserToolApprovalEvent = z.infer<typeof UserToolApprovalEventSchema>;
export type UserToolResponseEvent = z.infer<typeof UserToolResponseEventSchema>;
diff --git a/packages/trueforge-core/src/core/index.ts b/packages/trueforge-core/src/core/index.ts
index f8076ae54..cee913050 100644
--- a/packages/trueforge-core/src/core/index.ts
+++ b/packages/trueforge-core/src/core/index.ts
@@ -130,6 +130,7 @@ export type {
MCPServerInitInfo,
ThreadDoneEvent,
ThreadOverwriteContextEvent,
+ ToolApprovalPolicyAction,
UserMCPAuthContinueEvent,
UserMCPAuthContinueMessage,
UserToolApprovalEvent,
diff --git a/packages/trueforge-core/src/core/mcp/IMCPServer.ts b/packages/trueforge-core/src/core/mcp/IMCPServer.ts
index 07defaec9..429ced534 100644
--- a/packages/trueforge-core/src/core/mcp/IMCPServer.ts
+++ b/packages/trueforge-core/src/core/mcp/IMCPServer.ts
@@ -1,6 +1,12 @@
import type { CallToolRequest, CallToolResult, ListToolsResult } from '@modelcontextprotocol/sdk/types.js';
import type { RegisteredPassthroughEvent } from '../events/PassthroughEvents';
-import type { AgentInfo, ApprovalDecision, MCPServerAuthInfo, MCPServerInitInfo } from '../events/schema';
+import type {
+ AgentInfo,
+ ApprovalDecision,
+ MCPServerAuthInfo,
+ MCPServerInitInfo,
+ ToolApprovalPolicyAction,
+} from '../events/schema';
import type { InternalToolCallInfo } from '../llm/LLMTypes';
import type { SandboxInfo } from '../sandbox/Sandbox';
@@ -114,6 +120,11 @@ export interface IToolSet {
// Existing synchronous Code Mode allow-list. Optional implementations fall
// back to the current unrestricted envelope; callTool still enforces policy.
getAllowedToolNamesForSandbox?(): string[] | undefined;
+
+ // Per-tool approval policies. User MCP tool sets record and expose policies;
+ // system tool sets are never approval-gated and implement these as no-ops.
+ setApprovalPolicy(toolName: string, action: ToolApprovalPolicyAction): void;
+ getApprovalPolicies(): Record<string, ToolApprovalPolicyAction>;
}
/** Policy-free tool provider; a {@link ToolSet} wraps it to layer per-agent selector policy on top. */
diff --git a/packages/trueforge-core/src/core/mcp/LocalToolMCP.ts b/packages/trueforge-core/src/core/mcp/LocalToolMCP.ts
index 2de15d11d..539f788c8 100644
--- a/packages/trueforge-core/src/core/mcp/LocalToolMCP.ts
+++ b/packages/trueforge-core/src/core/mcp/LocalToolMCP.ts
@@ -1,6 +1,6 @@
import type { CallToolRequest, ListToolsResult } from '@modelcontextprotocol/sdk/types.js';
import { z } from 'zod';
-import type { ApprovalDecision } from '../events/schema';
+import type { ApprovalDecision, ToolApprovalPolicyAction } from '../events/schema';
import type { InternalToolCallInfo } from '../llm/LLMTypes';
import type { AgentTracing } from '../tracing/AgentTracing';
import {
@@ -113,6 +113,16 @@ export abstract class LocalToolMCP implements IToolSet {
);
}
+ // System tool sets are never approval-gated, so policies are a no-op here.
+ setApprovalPolicy(_toolName: string, _action: ToolApprovalPolicyAction): void {
+ void _toolName;
+ void _action;
+ }
+
+ getApprovalPolicies(): Record<string, ToolApprovalPolicyAction> {
+ return {};
+ }
+
// Local tools are not approval gated by default.
// Second arg kept for IToolSet / DeferredTool compatibility (unused here).
toolCallInfo(params: CallToolRequest['params'], _resolveUnderlyingTool?: boolean): Promise<InternalToolCallInfo> {
diff --git a/packages/trueforge-core/src/core/mcp/ToolSet.ts b/packages/trueforge-core/src/core/mcp/ToolSet.ts
index b5a618c33..ec219ae1a 100644
--- a/packages/trueforge-core/src/core/mcp/ToolSet.ts
+++ b/packages/trueforge-core/src/core/mcp/ToolSet.ts
@@ -1,6 +1,6 @@
import type { CallToolRequest, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
import { McpConnectionError } from '../errors';
-import type { ApprovalDecision } from '../events/schema';
+import type { ApprovalDecision, ToolApprovalPolicyAction } from '../events/schema';
import type { InternalToolCallInfo } from '../llm/LLMTypes';
import {
isAuthRequired,
@@ -26,23 +26,55 @@ export class ToolSet implements IToolSet {
readonly hasPreloadedTools: boolean;
private readonly source: ToolSource;
- private readonly policy: ToolSelectorPolicy;
+ private readonly toolSelectorPolicy: ToolSelectorPolicy;
+ private readonly approvalPolicies = new Map<string, ToolApprovalPolicyAction>();
- constructor(params: { source: ToolSource; selectors: ToolSelectorConfig; preload: boolean }) {
+ private static isPolicyApplicable(policy: ToolApprovalPolicyAction, asOf: Date): boolean {
+ return policy.expire_at === undefined || new Date(policy.expire_at).getTime() > asOf.getTime();
+ }
+
+ constructor(params: {
+ source: ToolSource;
+ selectors: ToolSelectorConfig;
+ preload: boolean;
+ approvalPolicies: Record<string, ToolApprovalPolicyAction> | undefined;
+ }) {
this.source = params.source;
this.name = params.source.name;
this.id = params.source.id;
this.description = params.source.description;
- this.policy = new ToolSelectorPolicy({
+ this.toolSelectorPolicy = new ToolSelectorPolicy({
selectors: params.selectors,
preload: params.preload,
});
- this.preload = this.policy.preload;
- this.hasPreloadedTools = this.policy.hasPreloadedTools;
+ this.preload = this.toolSelectorPolicy.preload;
+ this.hasPreloadedTools = this.toolSelectorPolicy.hasPreloadedTools;
+ // Drop already-expired policies carried forward from the previous snapshot so
+ // dead policies don't accumulate and get re-persisted turn after turn.
+ const asOf = new Date();
+ for (const [toolName, action] of Object.entries(params.approvalPolicies ?? {})) {
+ if (ToolSet.isPolicyApplicable(action, asOf)) {
+ this.approvalPolicies.set(toolName, action);
+ }
+ }
}
getAllowedToolNamesForSandbox(): string[] | undefined {
- return this.policy.allowedNamesForSandbox();
+ return this.toolSelectorPolicy.allowedNamesForSandbox();
+ }
+
+ // Last write wins for a given tool.
+ setApprovalPolicy(toolName: string, action: ToolApprovalPolicyAction): void {
+ this.approvalPolicies.set(toolName, action);
+ }
+
+ getApprovalPolicies(): Record<string, ToolApprovalPolicyAction> {
+ return Object.fromEntries(this.approvalPolicies);
+ }
+
+ private hasApplicableApprovalPolicy(toolName: string): boolean {
+ const policy = this.approvalPolicies.get(toolName);
+ return policy !== undefined && ToolSet.isPolicyApplicable(policy, new Date());
}
async listTools(): Promise<ListToolsResponse> {
@@ -52,7 +84,7 @@ export class ToolSet implements IToolSet {
}
const tools = response.result.tools;
- const missingTools = this.policy.missingEnableLiterals(tools);
+ const missingTools = this.toolSelectorPolicy.missingEnableLiterals(tools);
if (missingTools.length > 0) {
throw new McpConnectionError(
`Requested tools not found in MCP server ${this.name}: ${missingTools.join(', ')}`,
@@ -61,7 +93,7 @@ export class ToolSet implements IToolSet {
}
return {
- result: { tools: this.policy.filterAndAnnotate(tools) },
+ result: { tools: this.toolSelectorPolicy.filterAndAnnotate(tools) },
wasInitialized: response.wasInitialized,
};
}
@@ -108,7 +140,7 @@ export class ToolSet implements IToolSet {
}
private async assertToolAllowed(toolName: string, annotations: ToolAnnotations | undefined): Promise<void> {
- const allowed = await this.policy.isAllowed(toolName, () => Promise.resolve(annotations));
+ const allowed = await this.toolSelectorPolicy.isAllowed(toolName, () => Promise.resolve(annotations));
if (!allowed) {
throw new McpConnectionError(`Tool '${toolName}' is not allowed on MCP server ${this.name}`, 403);
}
@@ -121,7 +153,9 @@ export class ToolSet implements IToolSet {
): Promise<InternalToolCallInfo> {
return {
...(await this.source.toolCallInfo(params, resolveUnderlyingTool)),
- is_approval_required: this.policy.requiresApproval(params.name, annotations),
+ is_approval_required:
+ this.toolSelectorPolicy.requiresApproval(params.name, annotations) &&
+ !this.hasApplicableApprovalPolicy(params.name),
};
}
diff --git a/packages/trueforge-core/src/core/mcp/convertMCPServers.ts b/packages/trueforge-core/src/core/mcp/convertMCPServers.ts
index ffbf39225..9da2e6b3f 100644
--- a/packages/trueforge-core/src/core/mcp/convertMCPServers.ts
+++ b/packages/trueforge-core/src/core/mcp/convertMCPServers.ts
@@ -54,15 +54,20 @@ export async function convertMCPServersToTools(params: {
authRequirementInfo.push(listResponse.authRequired);
continue;
}
- const { result: mcpTools, wasInitialized } = listResponse;
- if (wasInitialized) {
- initializationInfo.push(wasInitialized);
- }
-
const toolSet = allServers[i];
if (toolSet === undefined) {
throw new Error(`Unreachable: missing tool set at index ${String(i)}`);
}
+
+ const { result: mcpTools, wasInitialized } = listResponse;
+ if (wasInitialized) {
+ const approvalPolicies = toolSet.getApprovalPolicies();
+ initializationInfo.push(
+ Object.keys(approvalPolicies).length > 0
+ ? { ...wasInitialized, approval_policies: approvalPolicies }
+ : wasInitialized,
+ );
+ }
const sortedTools = [...mcpTools.tools].sort((a, b) => (a.name > b.name ? 1 : -1));
for (const mcpTool of sortedTools) {
if (!mcpTool.preload) {
diff --git a/packages/trueforge-core/src/core/runtime/AgentThread.ts b/packages/trueforge-core/src/core/runtime/AgentThread.ts
index 1e44ee764..8f586f4fd 100644
--- a/packages/trueforge-core/src/core/runtime/AgentThread.ts
+++ b/packages/trueforge-core/src/core/runtime/AgentThread.ts
@@ -757,6 +757,12 @@ export class AgentThread {
return getOpenToolCallIds(this.context).has(toolCallId);
}
+ // User-configured MCP tool sets (spec.mcp_servers) for this thread. Excludes
+ // system tool sets (sandbox / deferred / capabilities).
+ public getUserToolSets(): readonly IToolSet[] {
+ return this.definition.toolSets ?? [];
+ }
+
// True when this thread is paused waiting on the user to resolve a pending tool
// approval or a client-side tool response.
public isAwaitingUserInput(): boolean {
diff --git a/packages/trueforge-core/src/core/runtime/AgentThreadOrchestrator.ts b/packages/trueforge-core/src/core/runtime/AgentThreadOrchestrator.ts
index a76c5203b..e2c33ab3e 100644
--- a/packages/trueforge-core/src/core/runtime/AgentThreadOrchestrator.ts
+++ b/packages/trueforge-core/src/core/runtime/AgentThreadOrchestrator.ts
@@ -5,6 +5,7 @@ import {
newEventId,
type ActionRequiredEvent,
type ModelMessageEvent,
+ type ToolApprovalPolicyItem,
type ToolResponseEvent,
type UserToolApprovalMessage,
type UserToolResponseMessage,
@@ -261,6 +262,41 @@ export class AgentThreadOrchestrator {
return total;
}
+ /**
+ * Apply tool approval policies to the tool sets. Validates
+ * every `server_name` against the currently-configured MCP servers first —
+ * fail-closed: if any name is unknown nothing is applied.
+ */
+ public applyApprovalPolicies(policies: ToolApprovalPolicyItem[]): { errors: string[] } {
+ const knownServerNames = new Set<string>();
+ for (const thread of this.agentThreads.values()) {
+ for (const toolSet of thread.getUserToolSets()) {
+ knownServerNames.add(toolSet.name);
+ }
+ }
+
+ const errors: string[] = [];
+ policies.forEach((policy, index) => {
+ if (!knownServerNames.has(policy.server_name)) {
+ errors.push(`policies[${String(index)}]: unknown server_name '${policy.server_name}'`);
+ }
+ });
+ if (errors.length > 0) {
+ return { errors };
+ }
+
+ for (const policy of policies) {
+ for (const thread of this.agentThreads.values()) {
+ for (const toolSet of thread.getUserToolSets()) {
+ if (toolSet.name === policy.server_name) {
+ toolSet.setApprovalPolicy(policy.name, policy.action);
+ }
+ }
+ }
+ }
+ return { errors: [] };
+ }
+
public async *send(messages: AgentThreadSendBatch): AsyncGenerator<AgentThreadAppendContext, void, unknown> {
const byThread = new Map<string, AgentThreadRuntimeSendBatch>();
for (const thread of this.agentThreads.values()) {
diff --git a/packages/trueforge-core/tests/agent-session/store/storeContractSuite.ts b/packages/trueforge-core/tests/agent-session/store/storeContractSuite.ts
index 860143533..27b2ef52f 100644
--- a/packages/trueforge-core/tests/agent-session/store/storeContractSuite.ts
+++ b/packages/trueforge-core/tests/agent-session/store/storeContractSuite.ts
@@ -3107,6 +3107,80 @@ export function runStoreContractSuite(createStore: () => ISessionStore) {
svc: { id: 'svc', name: 'svc', transport_type: 'sse' },
});
});
+
+ it('patchMCPServers persists approval_policies on the entry (sole policy writer)', async () => {
+ const store = createStore();
+ await seedSession(store);
+ await store.createTurn(makeCreateTurnInput({ sessionId, turnId: 'turn-1' }));
+ await store.patchMCPServers({
+ session_id: sessionId,
+ turn_id: 'turn-1',
+ mcp_servers: [
+ {
+ id: 'svc',
+ name: 'svc',
+ session_id: 'mcp-1',
+ transport_type: 'streamable-http',
+ approval_policies: {
+ write_note: { type: 'allow_session' },
+ delete_note: { type: 'allow_session', expire_at: '2999-01-01T00:00:00.000Z' },
+ },
+ },
+ ],
+ });
+ const turn = await store.getTurn({ session_id: sessionId, turn_id: 'turn-1' });
+ expect(mustGet(turn).snapshot.mcp_servers?.['svc']).toEqual({
+ id: 'svc',
+ name: 'svc',
+ session_id: 'mcp-1',
+ transport_type: 'streamable-http',
+ approval_policies: {
+ write_note: { type: 'allow_session' },
+ delete_note: { type: 'allow_session', expire_at: '2999-01-01T00:00:00.000Z' },
+ },
+ });
+ });
+
+ it('patchMCPServers wholesale replace drops omitted approval_policies (self-cleaning)', async () => {
+ const store = createStore();
+ await seedSession(store);
+ await store.createTurn(makeCreateTurnInput({ sessionId, turnId: 'turn-1' }));
+ await store.patchMCPServers({
+ session_id: sessionId,
+ turn_id: 'turn-1',
+ mcp_servers: [
+ {
+ id: 'svc',
+ name: 'svc',
+ session_id: 'mcp-1',
+ approval_policies: {
+ write_note: { type: 'allow_session' },
+ delete_note: { type: 'allow_session' },
+ },
+ },
+ ],
+ });
+ // Next MCP init re-persists the entry without the pruned/expired policies.
+ await store.patchMCPServers({
+ session_id: sessionId,
+ turn_id: 'turn-1',
+ mcp_servers: [
+ {
+ id: 'svc',
+ name: 'svc',
+ session_id: 'mcp-1',
+ approval_policies: { write_note: { type: 'allow_session' } },
+ },
+ ],
+ });
+ const turn = await store.getTurn({ session_id: sessionId, turn_id: 'turn-1' });
+ expect(mustGet(turn).snapshot.mcp_servers?.['svc']).toEqual({
+ id: 'svc',
+ name: 'svc',
+ session_id: 'mcp-1',
+ approval_policies: { write_note: { type: 'allow_session' } },
+ });
+ });
});
describe('pagination', () => {
diff --git a/packages/trueforge-core/tests/core/harnessMocks.ts b/packages/trueforge-core/tests/core/harnessMocks.ts
index 81bfccf03..89b81944c 100644
--- a/packages/trueforge-core/tests/core/harnessMocks.ts
+++ b/packages/trueforge-core/tests/core/harnessMocks.ts
@@ -52,6 +52,8 @@ export function makeMockIMCPServer(params: {
),
callTool: jest.fn(),
toolCallInfo: jest.fn(),
+ setApprovalPolicy: jest.fn(),
+ getApprovalPolicies: jest.fn(() => ({})),
};
}
diff --git a/packages/trueforge-core/tests/core/mcp/mcpInitializeAggregation.test.ts b/packages/trueforge-core/tests/core/mcp/mcpInitializeAggregation.test.ts
index 1b0c7844d..cb7d775ba 100644
--- a/packages/trueforge-core/tests/core/mcp/mcpInitializeAggregation.test.ts
+++ b/packages/trueforge-core/tests/core/mcp/mcpInitializeAggregation.test.ts
@@ -1,4 +1,4 @@
-import type { MCPServerInitInfo } from '../../../src/core/events/schema';
+import type { MCPServerInitInfo, ToolApprovalPolicyAction } from '../../../src/core/events/schema';
import { EventType } from '../../../src/core/events/schema';
import type { AgentToolSchema, IToolSet, ListToolsResponse } from '../../../src/core/mcp/IMCPServer';
import { convertMCPServersToTools } from '../../../src/core/mcp/convertMCPServers';
@@ -9,6 +9,7 @@ function makeServer(params: {
name: string;
initInfo?: MCPServerInitInfo;
tools?: AgentToolSchema[] | undefined;
+ approvalPolicies?: Record<string, ToolApprovalPolicyAction>;
}): IToolSet {
const base = makeMockIMCPServer({
name: params.name,
@@ -17,6 +18,7 @@ function makeServer(params: {
});
return {
...base,
+ ...(params.approvalPolicies ? { getApprovalPolicies: jest.fn(() => params.approvalPolicies ?? {}) } : {}),
listTools: jest.fn((): Promise<ListToolsResponse> =>
Promise.resolve({
result: {
@@ -52,6 +54,29 @@ describe('convertMCPServersToTools initialization aggregation', () => {
expect(convertedTools.tools.length).toBe(2);
});
+ it('carries the tool set approval policies onto its init info', async () => {
+ const withPoliciesInit: MCPServerInitInfo = {
+ id: 'with-policies',
+ name: 'with-policies',
+ session_id: 'sess-with-policies',
+ };
+ const policies: Record<string, ToolApprovalPolicyAction> = {
+ write_note: { type: 'allow_session' },
+ delete_note: { type: 'allow_session', expire_at: '2999-01-01T00:00:00.000Z' },
+ };
+ const bareInit: MCPServerInitInfo = { id: 'bare', name: 'bare', session_id: 'sess-bare' };
+
+ const { initializationInfo } = await convertMCPServersToTools({
+ tfyManagedServers: [],
+ userServers: [
+ makeServer({ name: 'with-policies', initInfo: withPoliciesInit, approvalPolicies: policies }),
+ makeServer({ name: 'bare', initInfo: bareInit }),
+ ],
+ });
+
+ expect(initializationInfo).toEqual([bareInit, { ...withPoliciesInit, approval_policies: policies }]);
+ });
+
it('skips initialization entries for OAuth-required servers', async () => {
const oauthServer: IToolSet = {
name: 'oauth-server',
@@ -67,6 +92,8 @@ describe('convertMCPServersToTools initialization aggregation', () => {
),
callTool: jest.fn(),
toolCallInfo: jest.fn(),
+ setApprovalPolicy: jest.fn(),
+ getApprovalPolicies: jest.fn(() => ({})),
};
const readyInit: MCPServerInitInfo = {
diff --git a/packages/trueforge-core/tests/core/mcp/remoteMcpServer.test.ts b/packages/trueforge-core/tests/core/mcp/remoteMcpServer.test.ts
index 1ecb1dd56..9cfaee087 100644
--- a/packages/trueforge-core/tests/core/mcp/remoteMcpServer.test.ts
+++ b/packages/trueforge-core/tests/core/mcp/remoteMcpServer.test.ts
@@ -145,6 +145,7 @@ function makeServer(params: {
source: remote,
selectors: params.selectors ?? DEFAULT_SELECTORS,
preload: params.preload ?? false,
+ approvalPolicies: undefined,
});
}
diff --git a/packages/trueforge-core/tests/orchestration/helpers/helpers.ts b/packages/trueforge-core/tests/orchestration/helpers/helpers.ts
index e4d40d1af..6727e0db6 100644
--- a/packages/trueforge-core/tests/orchestration/helpers/helpers.ts
+++ b/packages/trueforge-core/tests/orchestration/helpers/helpers.ts
@@ -1,9 +1,6 @@
import type { ILLM } from '../../../src/core/llm/ILLM';
import type { ExtendedChatCompletionChunk, RawAssistantMessageWithUsage } from '../../../src/core/llm/LLMTypes';
import { getEmptyUsage } from '../../../src/core/llm/LLMTypes';
-import type { IToolSet, ToolSource } from '../../../src/core/mcp/IMCPServer';
-import { toolResultResponse } from '../../../src/core/mcp/IMCPServer';
-import { ToolSet } from '../../../src/core/mcp/ToolSet';
import type {
AgentThreadExecutionEvent,
AgentThreadExecutionResult,
@@ -133,59 +130,6 @@ export async function* writeNoteToolCallStream() {
};
}
-function makeWriteNoteSource(callTool: ToolSource['callTool']): ToolSource {
- return {
- name: 'notes',
- id: 'notes',
- listTools: () =>
- Promise.resolve({
- result: {
- tools: [
- {
- name: WRITE_NOTE_TOOL_NAME,
- description: 'Write a note',
- inputSchema: {
- type: 'object',
- properties: { text: { type: 'string' } },
- },
- preload: true,
- },
- ],
- },
- wasInitialized: undefined,
- }),
- callTool,
- toolCallInfo: () =>
- Promise.resolve({
- type: 'mcp',
- mcp_server_id: 'notes',
- mcp_server_name: 'notes',
- original_tool_name: WRITE_NOTE_TOOL_NAME,
- }),
- };
-}
-
-/** Approval-gated write_note tool set; `callTool` spy proves allow runs the source and deny does not. */
-export function makeApprovalGatedWriteNoteToolSet(): {
- toolSet: IToolSet;
- callTool: jest.Mock;
-} {
- const callTool = jest.fn(() => Promise.resolve(toolResultResponse({ text: WRITE_NOTE_RESULT })));
- return {
- toolSet: new ToolSet({
- source: makeWriteNoteSource(callTool),
- selectors: {
- enableTools: ['@all'],
- disableTools: [],
- preloadTools: [],
- requireApprovalForTools: [WRITE_NOTE_TOOL_NAME],
- },
- preload: true,
- }),
- callTool,
- };
-}
-
/** Consume send() then execute(); return raw events and the generator result. */
export async function runTurn(input: {
orchestrator: AgentThreadOrchestrator;
diff --git a/packages/trueforge-core/tests/orchestration/orchestrationApproval.test.ts b/packages/trueforge-core/tests/orchestration/orchestrationApproval.test.ts
index eff7f395a..51b884cb5 100644
--- a/packages/trueforge-core/tests/orchestration/orchestrationApproval.test.ts
+++ b/packages/trueforge-core/tests/orchestration/orchestrationApproval.test.ts
@@ -1,5 +1,8 @@
/** Pause on write_note approval, then resume after allow or deny. */
import { EventType } from '../../src/core/events/schema';
+import type { IToolSet, ToolSource } from '../../src/core/mcp/IMCPServer';
+import { toolResultResponse } from '../../src/core/mcp/IMCPServer';
+import { ToolSet } from '../../src/core/mcp/ToolSet';
import { AgentThread } from '../../src/core/runtime/AgentThread';
import { InternalEventType, type AgentThreadConstructorInput } from '../../src/core/runtime/AgentThread.types';
import { AgentThreadOrchestrator } from '../../src/core/runtime/AgentThreadOrchestrator';
@@ -7,7 +10,6 @@ import { NOOP_AGENT_TRACING } from '../../src/core/tracing/NoopAgentTracing';
import { makeSilentLogger } from '../core/harnessMocks';
import {
llmCreateInputs,
- makeApprovalGatedWriteNoteToolSet,
runTurn,
textReplyStream,
WRITE_NOTE_ARGUMENTS,
@@ -17,6 +19,60 @@ import {
writeNoteToolCallStream,
} from './helpers/helpers';
+/** notes MCP server exposing an approval-gated write_note tool. */
+function makeWriteNoteSource(callTool: ToolSource['callTool']): ToolSource {
+ return {
+ name: 'notes',
+ id: 'notes',
+ listTools: () =>
+ Promise.resolve({
+ result: {
+ tools: [
+ {
+ name: WRITE_NOTE_TOOL_NAME,
+ description: 'Write a note',
+ inputSchema: { type: 'object', properties: { text: { type: 'string' } } },
+ preload: true,
+ },
+ ],
+ },
+ wasInitialized: undefined,
+ }),
+ callTool,
+ toolCallInfo: () =>
+ Promise.resolve({
+ type: 'mcp',
+ mcp_server_id: 'notes',
+ mcp_server_name: 'notes',
+ original_tool_name: WRITE_NOTE_TOOL_NAME,
+ }),
+ };
+}
+
+const GATED_WRITE_NOTE_SELECTORS = {
+ enableTools: ['@all'],
+ disableTools: [],
+ preloadTools: [],
+ requireApprovalForTools: [WRITE_NOTE_TOOL_NAME],
+};
+
+/** Approval-gated write_note tool set; `callTool` spy proves allow runs the source and deny does not. */
+function makeApprovalGatedWriteNoteToolSet(): {
+ toolSet: IToolSet;
+ callTool: jest.Mock;
+} {
+ const callTool = jest.fn(() => Promise.resolve(toolResultResponse({ text: WRITE_NOTE_RESULT })));
+ return {
+ toolSet: new ToolSet({
+ source: makeWriteNoteSource(callTool),
+ selectors: GATED_WRITE_NOTE_SELECTORS,
+ preload: true,
+ approvalPolicies: undefined,
+ }),
+ callTool,
+ };
+}
+
const ROOT_ID = 'thread_root';
const DENY_REASON = 'not allowed in this test';
/** ToolSet deny → isError path wraps the text payload again for context. */
@@ -236,6 +292,173 @@ describe('orchestration: pause then resume on tool approval', () => {
});
});
+const POLICY_SERVER_NAME = 'notes';
+
+describe('AgentThreadOrchestrator.applyApprovalPolicies', () => {
+ // The policy applies to user MCP servers (definition.toolSets), unlike the
+ // approval-flow harness above which registers the tool set as a system tool set.
+ let toolSet: IToolSet;
+ let orchestrator: AgentThreadOrchestrator;
+
+ beforeEach(() => {
+ toolSet = makeApprovalGatedWriteNoteToolSet().toolSet;
+ const thread = new AgentThread({
+ definition: {
+ modelClient: { create: jest.fn(), createNonStream: jest.fn() },
+ instruction: INSTRUCTION,
+ messages: undefined,
+ modelParams: undefined,
+ responseFormat: undefined,
+ iterationLimit: undefined,
+ toolSets: [toolSet],
+ },
+ threadId: ROOT_ID,
+ title: 'orchestration-approval-policy',
+ parent: undefined,
+ agentInfo: undefined,
+ context: undefined,
+ currentContextUsage: undefined,
+ preComputedCompletion: undefined,
+ sandbox: undefined,
+ capabilities: undefined,
+ capabilityState: undefined,
+ tracing: NOOP_AGENT_TRACING,
+ logger: makeSilentLogger(),
+ });
+ orchestrator = new AgentThreadOrchestrator({
+ agentThreads: new Map([[thread.threadId, thread]]),
+ createDynamicSubAgentThread: () => Promise.reject(new Error('unexpected sub-agent in policy test')),
+ tracing: NOOP_AGENT_TRACING,
+ logger: makeSilentLogger(),
+ });
+ });
+
+ it('records a policy on the matching tool set for a known server', () => {
+ const result = orchestrator.applyApprovalPolicies([
+ { server_name: POLICY_SERVER_NAME, name: WRITE_NOTE_TOOL_NAME, action: { type: 'allow_session' } },
+ ]);
+
+ expect(result.errors).toEqual([]);
+ expect(toolSet.getApprovalPolicies()).toEqual({
+ [WRITE_NOTE_TOOL_NAME]: { type: 'allow_session' },
+ });
+ });
+
+ it('carries expiry through onto the recorded policy', () => {
+ const expire_at = '2099-01-01T00:00:00.000Z';
+
+ orchestrator.applyApprovalPolicies([
+ { server_name: POLICY_SERVER_NAME, name: WRITE_NOTE_TOOL_NAME, action: { type: 'allow_session', expire_at } },
+ ]);
+
+ expect(toolSet.getApprovalPolicies()).toEqual({
+ [WRITE_NOTE_TOOL_NAME]: { type: 'allow_session', expire_at },
+ });
+ });
+
+ it('rejects an unknown server name and applies nothing (fail-closed)', () => {
+ const result = orchestrator.applyApprovalPolicies([
+ { server_name: POLICY_SERVER_NAME, name: WRITE_NOTE_TOOL_NAME, action: { type: 'allow_session' } },
+ { server_name: 'does-not-exist', name: 'whatever', action: { type: 'allow_session' } },
+ ]);
+
+ expect(result.errors).toHaveLength(1);
+ expect(result.errors[0]).toContain('does-not-exist');
+ // Nothing applied because validation failed for one item.
+ expect(toolSet.getApprovalPolicies()).toEqual({});
+ });
+
+ it('last write wins for the same (server, tool)', () => {
+ orchestrator.applyApprovalPolicies([
+ { server_name: POLICY_SERVER_NAME, name: WRITE_NOTE_TOOL_NAME, action: { type: 'allow_session' } },
+ ]);
+ orchestrator.applyApprovalPolicies([
+ {
+ server_name: POLICY_SERVER_NAME,
+ name: WRITE_NOTE_TOOL_NAME,
+ action: { type: 'allow_session', expire_at: '2099-01-01T00:00:00.000Z' },
+ },
+ ]);
+
+ expect(toolSet.getApprovalPolicies()).toEqual({
+ [WRITE_NOTE_TOOL_NAME]: { type: 'allow_session', expire_at: '2099-01-01T00:00:00.000Z' },
+ });
+ });
+});
+
+describe('ToolSet: policy-aware is_approval_required', () => {
+ const writeNoteParams = { name: WRITE_NOTE_TOOL_NAME, arguments: { text: 'hi' } };
+
+ it('requires approval by default for a gated tool', async () => {
+ const { toolSet } = makeApprovalGatedWriteNoteToolSet();
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(true);
+ });
+
+ it('without an applicable policy, callTool returns approvalRequired and does not run the tool', async () => {
+ const { toolSet, callTool } = makeApprovalGatedWriteNoteToolSet();
+ const response = await toolSet.callTool(writeNoteParams);
+ expect('approvalRequired' in response).toBe(true);
+ expect(callTool).not.toHaveBeenCalled();
+ });
+
+ it('an applicable policy auto-allows: no approval flag, callTool runs without a decision', async () => {
+ const { toolSet, callTool } = makeApprovalGatedWriteNoteToolSet();
+ toolSet.setApprovalPolicy(WRITE_NOTE_TOOL_NAME, { type: 'allow_session' });
+
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(false);
+
+ const response = await toolSet.callTool(writeNoteParams);
+ expect('approvalRequired' in response).toBe(false);
+ expect(callTool).toHaveBeenCalledTimes(1);
+ });
+
+ it('an unexpired policy auto-allows', async () => {
+ const { toolSet } = makeApprovalGatedWriteNoteToolSet();
+ toolSet.setApprovalPolicy(WRITE_NOTE_TOOL_NAME, {
+ type: 'allow_session',
+ expire_at: '2099-01-01T00:00:00.000Z',
+ });
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(false);
+ });
+
+ it('an expired policy still requires approval', async () => {
+ const { toolSet } = makeApprovalGatedWriteNoteToolSet();
+ toolSet.setApprovalPolicy(WRITE_NOTE_TOOL_NAME, {
+ type: 'allow_session',
+ expire_at: '2000-01-01T00:00:00.000Z',
+ });
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(true);
+ });
+
+ it('carries an applicable policy forward from the previous snapshot at construction', async () => {
+ const toolSet = new ToolSet({
+ source: makeWriteNoteSource(jest.fn()),
+ selectors: GATED_WRITE_NOTE_SELECTORS,
+ preload: true,
+ approvalPolicies: { [WRITE_NOTE_TOOL_NAME]: { type: 'allow_session' } },
+ });
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(false);
+ });
+
+ it('drops already-expired policies carried forward from the snapshot', async () => {
+ const toolSet = new ToolSet({
+ source: makeWriteNoteSource(jest.fn()),
+ selectors: GATED_WRITE_NOTE_SELECTORS,
+ preload: true,
+ approvalPolicies: { [WRITE_NOTE_TOOL_NAME]: { type: 'allow_session', expire_at: '2000-01-01T00:00:00.000Z' } },
+ });
+ // Pruned at seed, so it is neither exposed nor auto-allowing.
+ expect(toolSet.getApprovalPolicies()).toEqual({});
+ const info = await toolSet.toolCallInfo(writeNoteParams);
+ expect(info.is_approval_required).toBe(true);
+ });
+});
+
function makeApprovalHarness(finalReply: string): {
orchestrator: AgentThreadOrchestrator;
thread: AgentThread;
diff --git a/packages/trueforge-sdk/src/api/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts b/packages/trueforge-sdk/src/api/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts
new file mode 100644
index 000000000..cd7719d2b
--- /dev/null
+++ b/packages/trueforge-sdk/src/api/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts
@@ -0,0 +1,5 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as TrueForge from "../index.js";
+
+export type ComponentsSchemasToolApprovalPolicyAllowSession = TrueForge.ToolApprovalPolicyAllowSession;
diff --git a/packages/trueforge-sdk/src/api/types/McpServerInitInfo.ts b/packages/trueforge-sdk/src/api/types/McpServerInitInfo.ts
index 30121da6c..3ba9c907f 100644
--- a/packages/trueforge-sdk/src/api/types/McpServerInitInfo.ts
+++ b/packages/trueforge-sdk/src/api/types/McpServerInitInfo.ts
@@ -3,6 +3,8 @@
import type * as TrueForge from "../index.js";
export interface McpServerInitInfo {
+ /** Sticky per-tool approval policies (keyed by tool name) that auto-allow future calls. */
+ approvalPolicies?: Record<string, TrueForge.ComponentsSchemasToolApprovalPolicyAllowSession>;
/** Internal MCP server id. */
id: string;
/** Configured MCP server name. */
diff --git a/packages/trueforge-sdk/src/api/types/ToolApprovalPolicyItem.ts b/packages/trueforge-sdk/src/api/types/ToolApprovalPolicyItem.ts
index bcbe037cd..4b19a071c 100644
--- a/packages/trueforge-sdk/src/api/types/ToolApprovalPolicyItem.ts
+++ b/packages/trueforge-sdk/src/api/types/ToolApprovalPolicyItem.ts
@@ -3,7 +3,7 @@
import type * as TrueForge from "../index.js";
export interface ToolApprovalPolicyItem {
- action: TrueForge.ToolApprovalPolicyAllowSession;
+ action: TrueForge.ComponentsSchemasToolApprovalPolicyAllowSession;
/** Tool name on that server. */
name: string;
/** MCP server name. */
diff --git a/packages/trueforge-sdk/src/api/types/index.ts b/packages/trueforge-sdk/src/api/types/index.ts
index d94cd0213..cbbaeca3b 100644
--- a/packages/trueforge-sdk/src/api/types/index.ts
+++ b/packages/trueforge-sdk/src/api/types/index.ts
@@ -39,6 +39,7 @@ export * from "./ChatCompletionContentPartText.js";
export * from "./ChatCompletionMessageToolCall.js";
export * from "./ChatCompletionMessageToolCallFunction.js";
export * from "./CompactionConfig.js";
+export * from "./ComponentsSchemasToolApprovalPolicyAllowSession.js";
export * from "./ConfiguredMcpServer.js";
export * from "./ConfiguredModel.js";
export * from "./ConfiguredModelProvider.js";
diff --git a/packages/trueforge-sdk/src/serialization/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts b/packages/trueforge-sdk/src/serialization/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts
new file mode 100644
index 000000000..01c66d252
--- /dev/null
+++ b/packages/trueforge-sdk/src/serialization/types/ComponentsSchemasToolApprovalPolicyAllowSession.ts
@@ -0,0 +1,15 @@
+// This file was auto-generated by Fern from our API Definition.
+
+import type * as TrueForge from "../../api/index.js";
+import type * as core from "../../core/index.js";
+import type * as serializers from "../index.js";
+import { ToolApprovalPolicyAllowSession } from "./ToolApprovalPolicyAllowSession.js";
+
+export const ComponentsSchemasToolApprovalPolicyAllowSession: core.serialization.ObjectSchema<
+ serializers.ComponentsSchemasToolApprovalPolicyAllowSession.Raw,
+ TrueForge.ComponentsSchemasToolApprovalPolicyAllowSession
+> = ToolApprovalPolicyAllowSession;
+
+export declare namespace ComponentsSchemasToolApprovalPolicyAllowSession {
+ export type Raw = ToolApprovalPolicyAllowSession.Raw;
+}
diff --git a/packages/trueforge-sdk/src/serialization/types/McpServerInitInfo.ts b/packages/trueforge-sdk/src/serialization/types/McpServerInitInfo.ts
index d42ee58a3..84d4e75ad 100644
--- a/packages/trueforge-sdk/src/serialization/types/McpServerInitInfo.ts
+++ b/packages/trueforge-sdk/src/serialization/types/McpServerInitInfo.ts
@@ -3,12 +3,19 @@
import type * as TrueForge from "../../api/index.js";
import * as core from "../../core/index.js";
import type * as serializers from "../index.js";
+import { ComponentsSchemasToolApprovalPolicyAllowSession } from "./ComponentsSchemasToolApprovalPolicyAllowSession.js";
import { McpServerInitInfoTransportType } from "./McpServerInitInfoTransportType.js";
export const McpServerInitInfo: core.serialization.ObjectSchema<
serializers.McpServerInitInfo.Raw,
TrueForge.McpServerInitInfo
> = core.serialization.object({
+ approvalPolicies: core.serialization.property(
+ "approval_policies",
+ core.serialization
+ .record(core.serialization.string(), ComponentsSchemasToolApprovalPolicyAllowSession)
+ .optional(),
+ ),
id: core.serialization.string(),
name: core.serialization.string(),
sessionId: core.serialization.property("session_id", core.serialization.string().optional()),
@@ -17,6 +24,7 @@ export const McpServerInitInfo: core.serialization.ObjectSchema<
export declare namespace McpServerInitInfo {
export interface Raw {
+ approval_policies?: Record<string, ComponentsSchemasToolApprovalPolicyAllowSession.Raw> | null;
id: string;
name: string;
session_id?: string | null;
diff --git a/packages/trueforge-sdk/src/serialization/types/ToolApprovalPolicyItem.ts b/packages/trueforge-sdk/src/serialization/types/ToolApprovalPolicyItem.ts
index ef64c3415..9a0c7705c 100644
--- a/packages/trueforge-sdk/src/serialization/types/ToolApprovalPolicyItem.ts
+++ b/packages/trueforge-sdk/src/serialization/types/ToolApprovalPolicyItem.ts
@@ -3,20 +3,20 @@
import type * as TrueForge from "../../api/index.js";
import * as core from "../../core/index.js";
import type * as serializers from "../index.js";
-import { ToolApprovalPolicyAllowSession } from "./ToolApprovalPolicyAllowSession.js";
+import { ComponentsSchemasToolApprovalPolicyAllowSession } from "./ComponentsSchemasToolApprovalPolicyAllowSession.js";
export const ToolApprovalPolicyItem: core.serialization.ObjectSchema<
serializers.ToolApprovalPolicyItem.Raw,
TrueForge.ToolApprovalPolicyItem
> = core.serialization.object({
- action: ToolApprovalPolicyAllowSession,
+ action: ComponentsSchemasToolApprovalPolicyAllowSession,
name: core.serialization.string(),
serverName: core.serialization.property("server_name", core.serialization.string()),
});
export declare namespace ToolApprovalPolicyItem {
export interface Raw {
- action: ToolApprovalPolicyAllowSession.Raw;
+ action: ComponentsSchemasToolApprovalPolicyAllowSession.Raw;
name: string;
server_name: string;
}
diff --git a/packages/trueforge-sdk/src/serialization/types/index.ts b/packages/trueforge-sdk/src/serialization/types/index.ts
index d94cd0213..cbbaeca3b 100644
--- a/packages/trueforge-sdk/src/serialization/types/index.ts
+++ b/packages/trueforge-sdk/src/serialization/types/index.ts
@@ -39,6 +39,7 @@ export * from "./ChatCompletionContentPartText.js";
export * from "./ChatCompletionMessageToolCall.js";
export * from "./ChatCompletionMessageToolCallFunction.js";
export * from "./CompactionConfig.js";
+export * from "./ComponentsSchemasToolApprovalPolicyAllowSession.js";
export * from "./ConfiguredMcpServer.js";
export * from "./ConfiguredModel.js";
export * from "./ConfiguredModelProvider.js";
diff --git a/python/trueforge_sdk/src/trueforge_sdk/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/__init__.py
index 17101a3d2..0f6747ad6 100644
--- a/python/trueforge_sdk/src/trueforge_sdk/__init__.py
+++ b/python/trueforge_sdk/src/trueforge_sdk/__init__.py
@@ -48,6 +48,7 @@ if typing.TYPE_CHECKING:
ChatCompletionMessageToolCall,
ChatCompletionMessageToolCallFunction,
CompactionConfig,
+ ComponentsSchemasToolApprovalPolicyAllowSession,
ConfiguredMcpServer,
ConfiguredModel,
ConfiguredModelProvider,
@@ -348,6 +349,7 @@ _dynamic_imports: typing.Dict[str, str] = {
"ChatCompletionMessageToolCall": ".types",
"ChatCompletionMessageToolCallFunction": ".types",
"CompactionConfig": ".types",
+ "ComponentsSchemasToolApprovalPolicyAllowSession": ".types",
"ConfiguredMcpServer": ".types",
"ConfiguredModel": ".types",
"ConfiguredModelProvider": ".types",
@@ -666,6 +668,7 @@ __all__ = [
"ChatCompletionMessageToolCall",
"ChatCompletionMessageToolCallFunction",
"CompactionConfig",
+ "ComponentsSchemasToolApprovalPolicyAllowSession",
"ConfiguredMcpServer",
"ConfiguredModel",
"ConfiguredModelProvider",
diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py
index a4996ddb6..c6ba92897 100644
--- a/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py
+++ b/python/trueforge_sdk/src/trueforge_sdk/types/__init__.py
@@ -47,6 +47,7 @@ if typing.TYPE_CHECKING:
from .chat_completion_message_tool_call import ChatCompletionMessageToolCall
from .chat_completion_message_tool_call_function import ChatCompletionMessageToolCallFunction
from .compaction_config import CompactionConfig
+ from .components_schemas_tool_approval_policy_allow_session import ComponentsSchemasToolApprovalPolicyAllowSession
from .configured_mcp_server import ConfiguredMcpServer
from .configured_model import ConfiguredModel
from .configured_model_provider import ConfiguredModelProvider
@@ -312,6 +313,7 @@ _dynamic_imports: typing.Dict[str, str] = {
"ChatCompletionMessageToolCall": ".chat_completion_message_tool_call",
"ChatCompletionMessageToolCallFunction": ".chat_completion_message_tool_call_function",
"CompactionConfig": ".compaction_config",
+ "ComponentsSchemasToolApprovalPolicyAllowSession": ".components_schemas_tool_approval_policy_allow_session",
"ConfiguredMcpServer": ".configured_mcp_server",
"ConfiguredModel": ".configured_model",
"ConfiguredModelProvider": ".configured_model_provider",
@@ -601,6 +603,7 @@ __all__ = [
"ChatCompletionMessageToolCall",
"ChatCompletionMessageToolCallFunction",
"CompactionConfig",
+ "ComponentsSchemasToolApprovalPolicyAllowSession",
"ConfiguredMcpServer",
"ConfiguredModel",
"ConfiguredModelProvider",
diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/components_schemas_tool_approval_policy_allow_session.py b/python/trueforge_sdk/src/trueforge_sdk/types/components_schemas_tool_approval_policy_allow_session.py
new file mode 100644
index 000000000..8fdd3330f
--- /dev/null
+++ b/python/trueforge_sdk/src/trueforge_sdk/types/components_schemas_tool_approval_policy_allow_session.py
@@ -0,0 +1,5 @@
+# This file was auto-generated by Fern from our API Definition.
+
+from .tool_approval_policy_allow_session import ToolApprovalPolicyAllowSession
+
+ComponentsSchemasToolApprovalPolicyAllowSession = ToolApprovalPolicyAllowSession
diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/mcp_server_init_info.py b/python/trueforge_sdk/src/trueforge_sdk/types/mcp_server_init_info.py
index 74bb464f2..72d19d7df 100644
--- a/python/trueforge_sdk/src/trueforge_sdk/types/mcp_server_init_info.py
+++ b/python/trueforge_sdk/src/trueforge_sdk/types/mcp_server_init_info.py
@@ -5,10 +5,18 @@ import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
+from .components_schemas_tool_approval_policy_allow_session import ComponentsSchemasToolApprovalPolicyAllowSession
from .mcp_server_init_info_transport_type import McpServerInitInfoTransportType
class McpServerInitInfo(UncheckedBaseModel):
+ approval_policies: typing.Optional[typing.Dict[str, ComponentsSchemasToolApprovalPolicyAllowSession]] = (
+ pydantic.Field(default=None)
+ )
+ """
+ Sticky per-tool approval policies (keyed by tool name) that auto-allow future calls.
+ """
+
id: str = pydantic.Field()
"""
Internal MCP server id.
diff --git a/python/trueforge_sdk/src/trueforge_sdk/types/tool_approval_policy_item.py b/python/trueforge_sdk/src/trueforge_sdk/types/tool_approval_policy_item.py
index 1c1ce0e89..715940055 100644
--- a/python/trueforge_sdk/src/trueforge_sdk/types/tool_approval_policy_item.py
+++ b/python/trueforge_sdk/src/trueforge_sdk/types/tool_approval_policy_item.py
@@ -5,11 +5,11 @@ import typing
import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
-from .tool_approval_policy_allow_session import ToolApprovalPolicyAllowSession
+from .components_schemas_tool_approval_policy_allow_session import ComponentsSchemasToolApprovalPolicyAllowSession
class ToolApprovalPolicyItem(UncheckedBaseModel):
- action: ToolApprovalPolicyAllowSession
+ action: ComponentsSchemasToolApprovalPolicyAllowSession
name: str = pydantic.Field()
"""
Tool name on that server.