From 7bf24719014785b9f8294cb9428cd0beb4b247cc Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Fri, 26 Jun 2026 12:15:15 +0200 Subject: [PATCH 1/3] fix(schema): tolerate invalid items in new session lists --- agent-client-protocol-schema/src/v1/agent.rs | 5 +++++ agent-client-protocol-schema/src/v2/agent.rs | 5 +++++ schema/v1/schema.json | 8 ++++++-- schema/v1/schema.unstable.json | 8 ++++++-- schema/v2/schema.json | 8 ++++++-- schema/v2/schema.unstable.json | 8 ++++++-- 6 files changed, 34 insertions(+), 8 deletions(-) diff --git a/agent-client-protocol-schema/src/v1/agent.rs b/agent-client-protocol-schema/src/v1/agent.rs index 480fc408a..5da02c032 100644 --- a/agent-client-protocol-schema/src/v1/agent.rs +++ b/agent-client-protocol-schema/src/v1/agent.rs @@ -918,6 +918,7 @@ impl AuthMethodTerminal { /// Request parameters for creating a new session. /// /// See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) +#[serde_as] #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[schemars(extend("x-side" = "agent", "x-method" = SESSION_NEW_METHOD_NAME))] @@ -931,9 +932,13 @@ pub struct NewSessionRequest { /// These expand the session's filesystem scope without changing `cwd`, which /// remains the base for relative paths. When omitted or empty, no /// additional roots are activated for the new session. + #[serde_as(deserialize_as = "DefaultOnError>")] + #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] #[serde(default, skip_serializing_if = "Vec::is_empty")] pub additional_directories: Vec, /// List of MCP (Model Context Protocol) servers the agent should connect to. + #[serde_as(deserialize_as = "DefaultOnError>")] + #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] pub mcp_servers: Vec, /// The _meta property is reserved by ACP to allow clients and agents to attach additional /// metadata to their interactions. Implementations MUST NOT make assumptions about values at diff --git a/agent-client-protocol-schema/src/v2/agent.rs b/agent-client-protocol-schema/src/v2/agent.rs index b6d008aeb..070f8093c 100644 --- a/agent-client-protocol-schema/src/v2/agent.rs +++ b/agent-client-protocol-schema/src/v2/agent.rs @@ -994,6 +994,7 @@ impl AuthMethodTerminal { /// Request parameters for creating a new session. /// /// See protocol docs: [Creating a Session](https://agentclientprotocol.com/protocol/session-setup#creating-a-session) +#[serde_as] #[skip_serializing_none] #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, PartialEq, Eq)] #[schemars(extend("x-side" = "agent", "x-method" = SESSION_NEW_METHOD_NAME))] @@ -1007,9 +1008,13 @@ pub struct NewSessionRequest { /// These expand the session's workspace scope without changing `cwd`, which /// remains the base for relative paths. When omitted or empty, no /// additional roots are activated for the new session. + #[serde_as(deserialize_as = "DefaultOnError>")] + #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] #[serde(default, skip_serializing_if = "Vec::is_empty")] pub additional_directories: Vec, /// List of MCP (Model Context Protocol) servers the agent should connect to. + #[serde_as(deserialize_as = "DefaultOnError>")] + #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] pub mcp_servers: Vec, /// The _meta property is reserved by ACP to allow clients and agents to attach additional /// metadata to their interactions. Implementations MUST NOT make assumptions about values at diff --git a/schema/v1/schema.json b/schema/v1/schema.json index 6ca7c90c7..8654f488c 100644 --- a/schema/v1/schema.json +++ b/schema/v1/schema.json @@ -3456,14 +3456,18 @@ "type": "array", "items": { "type": "string" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "mcpServers": { "description": "List of MCP (Model Context Protocol) servers the agent should connect to.", "type": "array", "items": { "$ref": "#/$defs/McpServer" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", diff --git a/schema/v1/schema.unstable.json b/schema/v1/schema.unstable.json index ae9503e57..d0655f2d9 100644 --- a/schema/v1/schema.unstable.json +++ b/schema/v1/schema.unstable.json @@ -6289,14 +6289,18 @@ "type": "array", "items": { "type": "string" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "mcpServers": { "description": "List of MCP (Model Context Protocol) servers the agent should connect to.", "type": "array", "items": { "$ref": "#/$defs/McpServer" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", diff --git a/schema/v2/schema.json b/schema/v2/schema.json index 33ef489cd..68d2640e8 100644 --- a/schema/v2/schema.json +++ b/schema/v2/schema.json @@ -4036,14 +4036,18 @@ "type": "array", "items": { "type": "string" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "mcpServers": { "description": "List of MCP (Model Context Protocol) servers the agent should connect to.", "type": "array", "items": { "$ref": "#/$defs/McpServer" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", diff --git a/schema/v2/schema.unstable.json b/schema/v2/schema.unstable.json index 2c7e45151..73d69c923 100644 --- a/schema/v2/schema.unstable.json +++ b/schema/v2/schema.unstable.json @@ -6949,14 +6949,18 @@ "type": "array", "items": { "type": "string" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "mcpServers": { "description": "List of MCP (Model Context Protocol) servers the agent should connect to.", "type": "array", "items": { "$ref": "#/$defs/McpServer" - } + }, + "x-deserialize-default-on-error": true, + "x-deserialize-skip-invalid-items": true }, "_meta": { "description": "The _meta property is reserved by ACP to allow clients and agents to attach additional\nmetadata to their interactions. Implementations MUST NOT make assumptions about values at\nthese keys.\n\nSee protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/extensibility)", From 723645b179198fa14111ff6cf8cec9c23a6d143b Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Fri, 26 Jun 2026 12:16:21 +0200 Subject: [PATCH 2/3] fix(unstable-v2): make mcpServers optional in new sessions --- agent-client-protocol-schema/src/v2/agent.rs | 1 + docs/protocol/v2/draft/schema.mdx | 2 +- docs/protocol/v2/schema.mdx | 2 +- schema/v2/schema.json | 2 +- schema/v2/schema.unstable.json | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/agent-client-protocol-schema/src/v2/agent.rs b/agent-client-protocol-schema/src/v2/agent.rs index 070f8093c..0ffcaa085 100644 --- a/agent-client-protocol-schema/src/v2/agent.rs +++ b/agent-client-protocol-schema/src/v2/agent.rs @@ -1015,6 +1015,7 @@ pub struct NewSessionRequest { /// List of MCP (Model Context Protocol) servers the agent should connect to. #[serde_as(deserialize_as = "DefaultOnError>")] #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub mcp_servers: Vec, /// The _meta property is reserved by ACP to allow clients and agents to attach additional /// metadata to their interactions. Implementations MUST NOT make assumptions about values at diff --git a/docs/protocol/v2/draft/schema.mdx b/docs/protocol/v2/draft/schema.mdx index 7a6865821..6544c2cbd 100644 --- a/docs/protocol/v2/draft/schema.mdx +++ b/docs/protocol/v2/draft/schema.mdx @@ -1278,7 +1278,7 @@ additional roots are activated for the new session. The working directory for this session. Must be an absolute path. -McpServer[]} required> +McpServer[]} > List of MCP (Model Context Protocol) servers the agent should connect to. diff --git a/docs/protocol/v2/schema.mdx b/docs/protocol/v2/schema.mdx index a60230e2b..ea7b9cc59 100644 --- a/docs/protocol/v2/schema.mdx +++ b/docs/protocol/v2/schema.mdx @@ -520,7 +520,7 @@ additional roots are activated for the new session. The working directory for this session. Must be an absolute path. -McpServer[]} required> +McpServer[]} > List of MCP (Model Context Protocol) servers the agent should connect to. diff --git a/schema/v2/schema.json b/schema/v2/schema.json index 68d2640e8..e2e11e0de 100644 --- a/schema/v2/schema.json +++ b/schema/v2/schema.json @@ -4055,7 +4055,7 @@ "additionalProperties": true } }, - "required": ["cwd", "mcpServers"], + "required": ["cwd"], "x-side": "agent", "x-method": "session/new" }, diff --git a/schema/v2/schema.unstable.json b/schema/v2/schema.unstable.json index 73d69c923..eae95e0f8 100644 --- a/schema/v2/schema.unstable.json +++ b/schema/v2/schema.unstable.json @@ -6968,7 +6968,7 @@ "additionalProperties": true } }, - "required": ["cwd", "mcpServers"], + "required": ["cwd"], "x-side": "agent", "x-method": "session/new" }, From 8d6700c498c1614381079228afda862658148ec2 Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Fri, 26 Jun 2026 12:21:21 +0200 Subject: [PATCH 3/3] Update test assertions --- agent-client-protocol-schema/src/v2/agent.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/agent-client-protocol-schema/src/v2/agent.rs b/agent-client-protocol-schema/src/v2/agent.rs index 0ffcaa085..4c4ea8749 100644 --- a/agent-client-protocol-schema/src/v2/agent.rs +++ b/agent-client-protocol-schema/src/v2/agent.rs @@ -5655,7 +5655,6 @@ mod test_serialization { serde_json::to_value(NewSessionRequest::new("/home/user/project")).unwrap(), json!({ "cwd": "/home/user/project", - "mcpServers": [] }) ); assert_eq!( @@ -5672,7 +5671,6 @@ mod test_serialization { "/home/user/shared-lib", "/home/user/product-docs" ], - "mcpServers": [] }) ); assert_eq!(