The open-source agent harness - the runtime layer that turns an LLM into a working agent.
chore: Make McpServerManifestSchema a discriminated union of TF and Remote manifests (#714)
Srajan Asthana9501536bed00
diff --git a/.changeset/mcp-server-manifest-union.md b/.changeset/mcp-server-manifest-union.mdnew file mode 100644index 000000000..2243ff8ab--- /dev/null+++ b/.changeset/mcp-server-manifest-union.md@@ -0,0 +1,6 @@+---+"@truefoundry/trueforge": patch+"@truefoundry/trueforge-sdk": patch+---++Make MCPServerManifest a type-discriminated oneOf of RemoteMCPServerManifest and TrueFoundryMCPServerManifest.diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.jsonindex 6582ae708..dc948d72e 100644--- a/.github/fern/openapi/openapi.json+++ b/.github/fern/openapi/openapi.json@@ -2726,35 +2726,21 @@"type": "object"},"MCPServerManifest": {- "additionalProperties": false,- "properties": {- "auth": {- "$ref": "#/components/schemas/MCPServerManifestAuth"- },- "description": {- "description": "Concise summary of what this MCP server provides.",- "minLength": 1,- "type": "string"- },- "name": {- "$ref": "#/components/schemas/ResourceName"+ "discriminator": {+ "mapping": {+ "remote": "#/components/schemas/RemoteMCPServerManifest",+ "truefoundry": "#/components/schemas/TrueFoundryMCPServerManifest"},- "type": {- "$ref": "#/components/schemas/MCPServerType"+ "propertyName": "type"+ },+ "oneOf": [+ {+ "$ref": "#/components/schemas/RemoteMCPServerManifest"},- "url": {- "description": "MCP endpoint URL. For `truefoundry`, the resolved AI Gateway proxy URL.",- "format": "uri",- "type": "string"+ {+ "$ref": "#/components/schemas/TrueFoundryMCPServerManifest"}- },- "required": [- "type",- "name",- "url",- "description"- ],- "type": "object"+ ]},"MCPServerManifestAuth": {"description": "Optional auth settings. Omit when the server needs no credentials.",@@ -2789,13 +2775,6 @@}]},- "MCPServerType": {- "enum": [- "remote",- "truefoundry"- ],- "type": "string"- },"MCPToolInfo": {"properties": {"name": {@@ -3359,6 +3338,40 @@],"type": "string"},+ "RemoteMCPServerManifest": {+ "additionalProperties": false,+ "properties": {+ "auth": {+ "$ref": "#/components/schemas/MCPServerManifestAuth"+ },+ "description": {+ "description": "Concise summary of what this MCP server provides.",+ "minLength": 1,+ "type": "string"+ },+ "name": {+ "$ref": "#/components/schemas/ResourceName"+ },+ "type": {+ "enum": [+ "remote"+ ],+ "type": "string"+ },+ "url": {+ "description": "MCP endpoint URL.",+ "format": "uri",+ "type": "string"+ }+ },+ "required": [+ "type",+ "name",+ "url",+ "description"+ ],+ "type": "object"+ },"RequestErrorResponse": {"properties": {"error": {@@ -4814,6 +4827,40 @@],"type": "object"},+ "TrueFoundryMCPServerManifest": {+ "additionalProperties": false,+ "properties": {+ "auth": {+ "$ref": "#/components/schemas/MCPServerManifestAuth"+ },+ "description": {+ "description": "Concise summary of what this MCP server provides.",+ "minLength": 1,+ "type": "string"+ },+ "name": {+ "$ref": "#/components/schemas/ResourceName"+ },+ "type": {+ "enum": [+ "truefoundry"+ ],+ "type": "string"+ },+ "url": {+ "description": "Resolved AI Gateway proxy URL for this TrueFoundry-managed MCP server.",+ "format": "uri",+ "type": "string"+ }+ },+ "required": [+ "type",+ "name",+ "url",+ "description"+ ],+ "type": "object"+ },"TrueFoundryModelProvider": {"additionalProperties": false,"properties": {diff --git a/docs/openapi.json b/docs/openapi.jsonindex 6582ae708..dc948d72e 100644--- a/docs/openapi.json+++ b/docs/openapi.json@@ -2726,35 +2726,21 @@"type": "object"},"MCPServerManifest": {- "additionalProperties": false,- "properties": {- "auth": {- "$ref": "#/components/schemas/MCPServerManifestAuth"- },- "description": {- "description": "Concise summary of what this MCP server provides.",- "minLength": 1,- "type": "string"- },- "name": {- "$ref": "#/components/schemas/ResourceName"+ "discriminator": {+ "mapping": {+ "remote": "#/components/schemas/RemoteMCPServerManifest",+ "truefoundry": "#/components/schemas/TrueFoundryMCPServerManifest"},- "type": {- "$ref": "#/components/schemas/MCPServerType"+ "propertyName": "type"+ },+ "oneOf": [+ {+ "$ref": "#/components/schemas/RemoteMCPServerManifest"},- "url": {- "description": "MCP endpoint URL. For `truefoundry`, the resolved AI Gateway proxy URL.",- "format": "uri",- "type": "string"+ {+ "$ref": "#/components/schemas/TrueFoundryMCPServerManifest"}- },- "required": [- "type",- "name",- "url",- "description"- ],- "type": "object"+ ]},"MCPServerManifestAuth": {"description": "Optional auth settings. Omit when the server needs no credentials.",@@ -2789,13 +2775,6 @@}]},- "MCPServerType": {- "enum": [- "remote",- "truefoundry"- ],- "type": "string"- },"MCPToolInfo": {"properties": {"name": {@@ -3359,6 +3338,40 @@],"type": "string"},+ "RemoteMCPServerManifest": {+ "additionalProperties": false,+ "properties": {+ "auth": {+ "$ref": "#/components/schemas/MCPServerManifestAuth"+ },+ "description": {+ "description": "Concise summary of what this MCP server provides.",+ "minLength": 1,+ "type": "string"+ },+ "name": {+ "$ref": "#/components/schemas/ResourceName"+ },+ "type": {+ "enum": [+ "remote"+ ],+ "type": "string"+ },+ "url": {+ "description": "MCP endpoint URL.",+ "format": "uri",+ "type": "string"+ }+ },+ "required": [+ "type",+ "name",+ "url",+ "description"+ ],+ "type": "object"+ },"RequestErrorResponse": {"properties": {"error": {@@ -4814,6 +4827,40 @@],"type": "object"},+ "TrueFoundryMCPServerManifest": {+ "additionalProperties": false,+ "properties": {+ "auth": {+ "$ref": "#/components/schemas/MCPServerManifestAuth"+ },+ "description": {+ "description": "Concise summary of what this MCP server provides.",+ "minLength": 1,+ "type": "string"+ },+ "name": {+ "$ref": "#/components/schemas/ResourceName"+ },+ "type": {+ "enum": [+ "truefoundry"+ ],+ "type": "string"+ },+ "url": {+ "description": "Resolved AI Gateway proxy URL for this TrueFoundry-managed MCP server.",+ "format": "uri",+ "type": "string"+ }+ },+ "required": [+ "type",+ "name",+ "url",+ "description"+ ],+ "type": "object"+ },"TrueFoundryModelProvider": {"additionalProperties": false,"properties": {diff --git a/packages/trueforge-sdk/src/api/types/McpServerManifest.ts b/packages/trueforge-sdk/src/api/types/McpServerManifest.tsindex 185a2d46c..bb63f5605 100644--- a/packages/trueforge-sdk/src/api/types/McpServerManifest.ts+++ b/packages/trueforge-sdk/src/api/types/McpServerManifest.ts@@ -2,12 +2,4 @@import type * as TrueForge from "../index.js";-export interface McpServerManifest {- auth?: TrueForge.McpServerManifestAuth;- /** Concise summary of what this MCP server provides. */- description: string;- name: TrueForge.ResourceName;- type: TrueForge.McpServerType;- /** MCP endpoint URL. For `truefoundry`, the resolved AI Gateway proxy URL. */- url: string;-}+export type McpServerManifest = TrueForge.RemoteMcpServerManifest | TrueForge.TrueFoundryMcpServerManifest;diff --git a/packages/trueforge-sdk/src/api/types/McpServerType.ts b/packages/trueforge-sdk/src/api/types/McpServerType.tsdeleted file mode 100644index b3535bb27..000000000--- a/packages/trueforge-sdk/src/api/types/McpServerType.ts+++ /dev/null@@ -1,7 +0,0 @@-// This file was auto-generated by Fern from our API Definition.--export const McpServerType = {- Remote: "remote",- Truefoundry: "truefoundry",-} as const;-export type McpServerType = (typeof McpServerType)[keyof typeof McpServerType];diff --git a/packages/trueforge-sdk/src/api/types/RemoteMcpServerManifest.ts b/packages/trueforge-sdk/src/api/types/RemoteMcpServerManifest.tsnew file mode 100644index 000000000..0ae14325e--- /dev/null+++ b/packages/trueforge-sdk/src/api/types/RemoteMcpServerManifest.ts@@ -0,0 +1,13 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../index.js";++export interface RemoteMcpServerManifest {+ auth?: TrueForge.McpServerManifestAuth;+ /** Concise summary of what this MCP server provides. */+ description: string;+ name: TrueForge.ResourceName;+ type: "remote";+ /** MCP endpoint URL. */+ url: string;+}diff --git a/packages/trueforge-sdk/src/api/types/TrueFoundryMcpServerManifest.ts b/packages/trueforge-sdk/src/api/types/TrueFoundryMcpServerManifest.tsnew file mode 100644index 000000000..ef07a62bf--- /dev/null+++ b/packages/trueforge-sdk/src/api/types/TrueFoundryMcpServerManifest.ts@@ -0,0 +1,13 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../index.js";++export interface TrueFoundryMcpServerManifest {+ auth?: TrueForge.McpServerManifestAuth;+ /** Concise summary of what this MCP server provides. */+ description: string;+ name: TrueForge.ResourceName;+ type: "truefoundry";+ /** Resolved AI Gateway proxy URL for this TrueFoundry-managed MCP server. */+ url: string;+}diff --git a/packages/trueforge-sdk/src/api/types/index.ts b/packages/trueforge-sdk/src/api/types/index.tsindex 635efb65a..fcc78f761 100644--- a/packages/trueforge-sdk/src/api/types/index.ts+++ b/packages/trueforge-sdk/src/api/types/index.ts@@ -117,7 +117,6 @@ export * from "./McpServerInitInfoTransportType.js";export * from "./McpServerManifest.js";export * from "./McpServerManifestAuth.js";export * from "./McpServerToolSelector.js";-export * from "./McpServerType.js";export * from "./McpToolInfo.js";export * from "./Me.js";export * from "./MeSessionType.js";@@ -139,6 +138,7 @@ export * from "./PermissionResourceType.js";export * from "./PreviousTurnIdInput.js";export * from "./RawToolCall.js";export * from "./ReasoningEffort.js";+export * from "./RemoteMcpServerManifest.js";export * from "./RequestErrorResponse.js";export * from "./RequestErrorResponseError.js";export * from "./ResourceName.js";@@ -202,6 +202,7 @@ export * from "./ToolCallRef.js";export * from "./ToolInfo.js";export * from "./ToolResponseEvent.js";export * from "./ToolResponseRequiredEvent.js";+export * from "./TrueFoundryMcpServerManifest.js";export * from "./TrueFoundryModelProvider.js";export * from "./TrueFoundryRegistrySkill.js";export * from "./TrueFoundrySystemToolInfo.js";diff --git a/packages/trueforge-sdk/src/serialization/types/McpServerManifest.ts b/packages/trueforge-sdk/src/serialization/types/McpServerManifest.tsindex cf59434c2..f9cd286ca 100644--- a/packages/trueforge-sdk/src/serialization/types/McpServerManifest.ts+++ b/packages/trueforge-sdk/src/serialization/types/McpServerManifest.ts@@ -3,27 +3,14 @@import type * as TrueForge from "../../api/index.js";import * as core from "../../core/index.js";import type * as serializers from "../index.js";-import { McpServerManifestAuth } from "./McpServerManifestAuth.js";-import { McpServerType } from "./McpServerType.js";-import { ResourceName } from "./ResourceName.js";+import { RemoteMcpServerManifest } from "./RemoteMcpServerManifest.js";+import { TrueFoundryMcpServerManifest } from "./TrueFoundryMcpServerManifest.js";-export const McpServerManifest: core.serialization.ObjectSchema<+export const McpServerManifest: core.serialization.Schema<serializers.McpServerManifest.Raw,TrueForge.McpServerManifest-> = core.serialization.object({- auth: McpServerManifestAuth.optional(),- description: core.serialization.string(),- name: ResourceName,- type: McpServerType,- url: core.serialization.string(),-});+> = core.serialization.undiscriminatedUnion([RemoteMcpServerManifest, TrueFoundryMcpServerManifest]);export declare namespace McpServerManifest {- export interface Raw {- auth?: McpServerManifestAuth.Raw | null;- description: string;- name: ResourceName.Raw;- type: McpServerType.Raw;- url: string;- }+ export type Raw = RemoteMcpServerManifest.Raw | TrueFoundryMcpServerManifest.Raw;}diff --git a/packages/trueforge-sdk/src/serialization/types/McpServerType.ts b/packages/trueforge-sdk/src/serialization/types/McpServerType.tsdeleted file mode 100644index 3f8f43d8f..000000000--- a/packages/trueforge-sdk/src/serialization/types/McpServerType.ts+++ /dev/null@@ -1,12 +0,0 @@-// This file was auto-generated by Fern from our API Definition.--import type * as TrueForge from "../../api/index.js";-import * as core from "../../core/index.js";-import type * as serializers from "../index.js";--export const McpServerType: core.serialization.Schema<serializers.McpServerType.Raw, TrueForge.McpServerType> =- core.serialization.enum_(["remote", "truefoundry"]);--export declare namespace McpServerType {- export type Raw = "remote" | "truefoundry";-}diff --git a/packages/trueforge-sdk/src/serialization/types/RemoteMcpServerManifest.ts b/packages/trueforge-sdk/src/serialization/types/RemoteMcpServerManifest.tsnew file mode 100644index 000000000..b3b25a8f6--- /dev/null+++ b/packages/trueforge-sdk/src/serialization/types/RemoteMcpServerManifest.ts@@ -0,0 +1,28 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { McpServerManifestAuth } from "./McpServerManifestAuth.js";+import { ResourceName } from "./ResourceName.js";++export const RemoteMcpServerManifest: core.serialization.ObjectSchema<+ serializers.RemoteMcpServerManifest.Raw,+ TrueForge.RemoteMcpServerManifest+> = core.serialization.object({+ auth: McpServerManifestAuth.optional(),+ description: core.serialization.string(),+ name: ResourceName,+ type: core.serialization.stringLiteral("remote"),+ url: core.serialization.string(),+});++export declare namespace RemoteMcpServerManifest {+ export interface Raw {+ auth?: McpServerManifestAuth.Raw | null;+ description: string;+ name: ResourceName.Raw;+ type: "remote";+ url: string;+ }+}diff --git a/packages/trueforge-sdk/src/serialization/types/TrueFoundryMcpServerManifest.ts b/packages/trueforge-sdk/src/serialization/types/TrueFoundryMcpServerManifest.tsnew file mode 100644index 000000000..92a0033de--- /dev/null+++ b/packages/trueforge-sdk/src/serialization/types/TrueFoundryMcpServerManifest.ts@@ -0,0 +1,28 @@+// This file was auto-generated by Fern from our API Definition.++import type * as TrueForge from "../../api/index.js";+import * as core from "../../core/index.js";+import type * as serializers from "../index.js";+import { McpServerManifestAuth } from "./McpServerManifestAuth.js";+import { ResourceName } from "./ResourceName.js";++export const TrueFoundryMcpServerManifest: core.serialization.ObjectSchema<+ serializers.TrueFoundryMcpServerManifest.Raw,+ TrueForge.TrueFoundryMcpServerManifest+> = core.serialization.object({+ auth: McpServerManifestAuth.optional(),+ description: core.serialization.string(),+ name: ResourceName,+ type: core.serialization.stringLiteral("truefoundry"),+ url: core.serialization.string(),+});++export declare namespace TrueFoundryMcpServerManifest {+ export interface Raw {+ auth?: McpServerManifestAuth.Raw | null;+ description: string;+ name: ResourceName.Raw;+ type: "truefoundry";+ url: string;+ }+}diff --git a/packages/trueforge-sdk/src/serialization/types/index.ts b/packages/trueforge-sdk/src/serialization/types/index.tsindex 635efb65a..fcc78f761 100644--- a/packages/trueforge-sdk/src/serialization/types/index.ts+++ b/packages/trueforge-sdk/src/serialization/types/index.ts@@ -117,7 +117,6 @@ export * from "./McpServerInitInfoTransportType.js";export * from "./McpServerManifest.js";export * from "./McpServerManifestAuth.js";export * from "./McpServerToolSelector.js";-export * from "./McpServerType.js";export * from "./McpToolInfo.js";export * from "./Me.js";export * from "./MeSessionType.js";@@ -139,6 +138,7 @@ export * from "./PermissionResourceType.js";export * from "./PreviousTurnIdInput.js";export * from "./RawToolCall.js";export * from "./ReasoningEffort.js";+export * from "./RemoteMcpServerManifest.js";export * from "./RequestErrorResponse.js";export * from "./RequestErrorResponseError.js";export * from "./ResourceName.js";@@ -202,6 +202,7 @@ export * from "./ToolCallRef.js";export * from "./ToolInfo.js";export * from "./ToolResponseEvent.js";export * from "./ToolResponseRequiredEvent.js";+export * from "./TrueFoundryMcpServerManifest.js";export * from "./TrueFoundryModelProvider.js";export * from "./TrueFoundryRegistrySkill.js";export * from "./TrueFoundrySystemToolInfo.js";diff --git a/packages/trueforge/src/schemas/mcpServer.ts b/packages/trueforge/src/schemas/mcpServer.tsindex 5c2defb11..349fcdcc1 100644--- a/packages/trueforge/src/schemas/mcpServer.ts+++ b/packages/trueforge/src/schemas/mcpServer.ts@@ -3,6 +3,9 @@* document, admin/chat list projections, and auth_status. Catalog file schemas* live in mcpCatalog.ts.*+ * McpServerManifest is a `type`-discriminated oneOf of+ * RemoteMcpServerManifest | TrueFoundryMcpServerManifest.+ ** Auth: `header` stores shared request headers on the row.* Turn execution resolves DCR tokens via resolveMcpAuth.*/@@ -10,12 +13,14 @@ import { z } from '@hono/zod-openapi';import type { OAuthToken } from '../mcp/auth/types';import { NameSchema } from './common';+const MCP_SERVER_TYPES = ['remote', 'truefoundry'] as const;+/*** Transport/kind of MCP server.* `remote` — user-configured URL (standalone / local registry).* `truefoundry` — TrueFoundry-managed: gateway proxy URL.*/-export const McpServerTypeSchema = z.enum(['remote', 'truefoundry']).openapi('MCPServerType');+export const McpServerTypeSchema = z.enum(MCP_SERVER_TYPES).openapi('MCPServerType');const McpServerHeaderAuthSchema = z.object({@@ -51,18 +56,33 @@ export const McpServerDescriptionSchema = z.min(1).describe('Concise summary of what this MCP server provides.');-/** Configured MCP server document persisted as `mcp_server.manifest`. */-export const McpServerManifestObjectSchema = z+/** User-configured remote MCP endpoint. */+const RemoteMcpServerManifestSchema = z+ .object({+ type: z.literal(McpServerTypeSchema.enum.remote),+ name: NameSchema,+ url: z.url().describe('MCP endpoint URL.'),+ description: McpServerDescriptionSchema,+ auth: McpServerManifestAuthSchema.optional(),+ })+ .strict()+ .openapi('RemoteMCPServerManifest');++/** TrueFoundry-managed MCP server; `url` is the resolved AI Gateway proxy URL. */+const TrueFoundryMcpServerManifestSchema = z.object({- type: McpServerTypeSchema,+ type: z.literal(McpServerTypeSchema.enum.truefoundry),name: NameSchema,- url: z.url().describe('MCP endpoint URL. For `truefoundry`, the resolved AI Gateway proxy URL.'),+ url: z.url().describe('Resolved AI Gateway proxy URL for this TrueFoundry-managed MCP server.'),description: McpServerDescriptionSchema,auth: McpServerManifestAuthSchema.optional(),})- .strict();+ .strict()+ .openapi('TrueFoundryMCPServerManifest');-export const McpServerManifestSchema = McpServerManifestObjectSchema.openapi('MCPServerManifest');+export const McpServerManifestSchema = z+ .discriminatedUnion('type', [RemoteMcpServerManifestSchema, TrueFoundryMcpServerManifestSchema])+ .openapi('MCPServerManifest');export const McpAuthStatusSchema = z.object({@@ -141,6 +161,8 @@ export const GetAvailableMcpServerResponseSchema = zexport type McpServerType = z.infer<typeof McpServerTypeSchema>;export type McpServerManifestAuth = z.infer<typeof McpServerManifestAuthSchema>;+export type RemoteMcpServerManifest = z.infer<typeof RemoteMcpServerManifestSchema>;+export type TrueFoundryMcpServerManifest = z.infer<typeof TrueFoundryMcpServerManifestSchema>;export type McpServerManifest = z.infer<typeof McpServerManifestSchema>;export type McpAuthStatus = z.infer<typeof McpAuthStatusSchema>;export type McpServerAuthPublic = z.infer<typeof McpServerAuthPublicSchema>;diff --git a/packages/trueforge/src/truefoundry/mapSfyMcpServers.ts b/packages/trueforge/src/truefoundry/mapSfyMcpServers.tsindex 0464390fc..305dac5ff 100644--- a/packages/trueforge/src/truefoundry/mapSfyMcpServers.ts+++ b/packages/trueforge/src/truefoundry/mapSfyMcpServers.ts@@ -1,5 +1,5 @@import { z } from 'zod';-import type { McpAuthStatus, McpServerManifest } from '../schemas/mcpServer';+import type { McpAuthStatus, TrueFoundryMcpServerManifest } from '../schemas/mcpServer';/** Placeholder in upstream `proxyUrl` replaced with the tenant gateway base URL. */export const MCP_PROXY_BASE_URL_TEMPLATE = '{{mcpProxyBaseURL}}';@@ -104,7 +104,7 @@ export function resolveMcpProxyUrl(input: { proxyUrl: string; gatewayBaseURL: stexport function toTrueFoundryMcpManifest(input: {server: SfyMcpServerSummary;gatewayUrl: string;-}): McpServerManifest {+}): TrueFoundryMcpServerManifest {return {type: 'truefoundry',name: input.server.name,diff --git a/packages/trueforge/tests/db/mcpServerStoreContractSuite.ts b/packages/trueforge/tests/db/mcpServerStoreContractSuite.tsindex 3486b57d4..4954a3142 100644--- a/packages/trueforge/tests/db/mcpServerStoreContractSuite.ts+++ b/packages/trueforge/tests/db/mcpServerStoreContractSuite.ts@@ -4,11 +4,11 @@*/import { McpServerNameConflictError, type IMcpServerStore } from '../../src/db/mcpServerStore';import type { OAuthClientRecord } from '../../src/mcp/auth/types';-import type { McpServerManifest } from '../../src/schemas/mcpServer';+import type { RemoteMcpServerManifest } from '../../src/schemas/mcpServer';const TENANT = 'default';-function manifest(overrides: Partial<McpServerManifest> = {}): McpServerManifest {+function manifest(overrides: Partial<RemoteMcpServerManifest> = {}): RemoteMcpServerManifest {return {type: 'remote',name: 'linear',