diff --git a/agent-client-protocol-schema/src/v2/agent.rs b/agent-client-protocol-schema/src/v2/agent.rs index b6f81f03a..eabc119d9 100644 --- a/agent-client-protocol-schema/src/v2/agent.rs +++ b/agent-client-protocol-schema/src/v2/agent.rs @@ -134,7 +134,7 @@ pub struct InitializeResponse { /// Authentication methods supported by the agent. #[serde_as(deserialize_as = "DefaultOnError>")] #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] - #[serde(default)] + #[serde(default, skip_serializing_if = "Vec::is_empty")] pub auth_methods: 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 @@ -1804,7 +1804,7 @@ impl ListSessionsRequest { #[serde(rename_all = "camelCase")] #[non_exhaustive] pub struct ListSessionsResponse { - /// Array of session information objects + /// Array of session information objects. #[serde_as(deserialize_as = "DefaultOnError>")] #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] pub sessions: Vec, @@ -2994,6 +2994,7 @@ pub struct McpServerHttp { /// HTTP headers to set when making requests to the MCP server. #[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 headers: 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 @@ -3135,10 +3136,12 @@ pub struct McpServerStdio { /// Command-line arguments to pass to the MCP server. #[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 args: Vec, /// Environment variables to set when launching the MCP server. #[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 env: 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 @@ -5862,6 +5865,54 @@ mod test_serialization { } } + #[test] + fn test_mcp_server_empty_arrays_are_optional() { + let stdio = McpServer::Stdio(McpServerStdio::new("test-server", "/usr/bin/server")); + assert_eq!( + serde_json::to_value(&stdio).unwrap(), + json!({ + "type": "stdio", + "name": "test-server", + "command": "/usr/bin/server" + }) + ); + + let McpServer::Stdio(McpServerStdio { args, env, .. }) = + serde_json::from_value::(json!({ + "type": "stdio", + "name": "test-server", + "command": "/usr/bin/server" + })) + .unwrap() + else { + panic!("Expected Stdio variant"); + }; + assert!(args.is_empty()); + assert!(env.is_empty()); + + let http = McpServer::Http(McpServerHttp::new("http-server", "https://api.example.com")); + assert_eq!( + serde_json::to_value(&http).unwrap(), + json!({ + "type": "http", + "name": "http-server", + "url": "https://api.example.com" + }) + ); + + let McpServer::Http(McpServerHttp { headers, .. }) = + serde_json::from_value::(json!({ + "type": "http", + "name": "http-server", + "url": "https://api.example.com" + })) + .unwrap() + else { + panic!("Expected Http variant"); + }; + assert!(headers.is_empty()); + } + #[test] fn test_mcp_server_unknown_transport_serialization() { let json = json!({ diff --git a/agent-client-protocol-schema/src/v2/client.rs b/agent-client-protocol-schema/src/v2/client.rs index d05f11858..25d3a0050 100644 --- a/agent-client-protocol-schema/src/v2/client.rs +++ b/agent-client-protocol-schema/src/v2/client.rs @@ -1020,7 +1020,7 @@ impl MessageId { #[serde(rename_all = "camelCase")] #[non_exhaustive] pub struct AvailableCommandsUpdate { - /// Commands the agent can execute + /// Commands the agent can execute. #[serde_as(deserialize_as = "DefaultOnError>")] #[schemars(extend("x-deserialize-default-on-error" = true, "x-deserialize-skip-invalid-items" = true))] pub available_commands: Vec, diff --git a/agent-client-protocol-schema/src/v2/conversion.rs b/agent-client-protocol-schema/src/v2/conversion.rs index 8d4ef98cd..49ec99d24 100644 --- a/agent-client-protocol-schema/src/v2/conversion.rs +++ b/agent-client-protocol-schema/src/v2/conversion.rs @@ -9582,15 +9582,12 @@ mod tests { { "type": "stdio", "name": "local", - "command": "/usr/bin/mcp", - "args": [], - "env": [] + "command": "/usr/bin/mcp" }, { "type": "http", "name": "remote", - "url": "https://example.com", - "headers": [] + "url": "https://example.com" } ] }) diff --git a/docs/protocol/v2/draft/schema.mdx b/docs/protocol/v2/draft/schema.mdx index ab3f40685..aa8350631 100644 --- a/docs/protocol/v2/draft/schema.mdx +++ b/docs/protocol/v2/draft/schema.mdx @@ -356,9 +356,6 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d AuthMethod[]} > Authentication methods supported by the agent. - - - Default: `[]` - AgentCapabilities} > Capabilities supported by the agent. @@ -1155,7 +1152,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d to fetch the next page. If absent, there are no more results. SessionInfo[]} required> - Array of session information objects + Array of session information objects. @@ -2753,7 +2750,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d AvailableCommand[]} required> - Commands the agent can execute + Commands the agent can execute. ## BlobResourceContents @@ -4384,7 +4381,7 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility) -HttpHeader[]} required> +HttpHeader[]} > HTTP headers to set when making requests to the MCP server. @@ -4452,13 +4449,13 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility) -"string"[]} required> +"string"[]} > Command-line arguments to pass to the MCP server. Absolute path to the MCP server executable. -EnvVariable[]} required> +EnvVariable[]} > Environment variables to set when launching the MCP server. @@ -4560,7 +4557,7 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility) -HttpHeader[]} required> +HttpHeader[]} > HTTP headers to set when making requests to the MCP server. @@ -4586,13 +4583,13 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/draft/extensibility) -"string"[]} required> +"string"[]} > Command-line arguments to pass to the MCP server. Absolute path to the MCP server executable. -EnvVariable[]} required> +EnvVariable[]} > Environment variables to set when launching the MCP server. @@ -7588,7 +7585,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d AvailableCommand[]} required> - Commands the agent can execute + Commands the agent can execute. The discriminator value. Must be `"available_commands_update"`. diff --git a/docs/protocol/v2/draft/session-setup.mdx b/docs/protocol/v2/draft/session-setup.mdx index 6aa428c81..6a503c399 100644 --- a/docs/protocol/v2/draft/session-setup.mdx +++ b/docs/protocol/v2/draft/session-setup.mdx @@ -427,12 +427,14 @@ When the Agent supports `session.mcp.stdio`, Clients can specify MCP servers con The absolute path to the MCP server executable - - Command-line arguments to pass to the server + + Command-line arguments to pass to the server. Omitted and empty values are + equivalent. - Environment variables to set when launching the server + Environment variables to set when launching the server. Omitted and empty + values are equivalent. @@ -477,8 +479,9 @@ When the Agent supports `session.mcp.http`, Clients can specify MCP servers conf The URL of the MCP server - - HTTP headers to include in requests to the server + + HTTP headers to include in requests to the server. Omitted and empty values are + equivalent. diff --git a/docs/protocol/v2/schema.mdx b/docs/protocol/v2/schema.mdx index 9949350ee..ad8b3b8a4 100644 --- a/docs/protocol/v2/schema.mdx +++ b/docs/protocol/v2/schema.mdx @@ -182,9 +182,6 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e AuthMethod[]} > Authentication methods supported by the agent. - - - Default: `[]` - AgentCapabilities} > Capabilities supported by the agent. @@ -397,7 +394,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e to fetch the next page. If absent, there are no more results. SessionInfo[]} required> - Array of session information objects + Array of session information objects. @@ -1304,7 +1301,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e AvailableCommand[]} required> - Commands the agent can execute + Commands the agent can execute. ## BlobResourceContents @@ -2079,7 +2076,7 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) -HttpHeader[]} required> +HttpHeader[]} > HTTP headers to set when making requests to the MCP server. @@ -2110,13 +2107,13 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) -"string"[]} required> +"string"[]} > Command-line arguments to pass to the MCP server. Absolute path to the MCP server executable. -EnvVariable[]} required> +EnvVariable[]} > Environment variables to set when launching the MCP server. @@ -2170,7 +2167,7 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) -HttpHeader[]} required> +HttpHeader[]} > HTTP headers to set when making requests to the MCP server. @@ -2196,13 +2193,13 @@ these keys. See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/extensibility) -"string"[]} required> +"string"[]} > Command-line arguments to pass to the MCP server. Absolute path to the MCP server executable. -EnvVariable[]} required> +EnvVariable[]} > Environment variables to set when launching the MCP server. @@ -3643,7 +3640,7 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e AvailableCommand[]} required> - Commands the agent can execute + Commands the agent can execute. The discriminator value. Must be `"available_commands_update"`. diff --git a/docs/protocol/v2/session-setup.mdx b/docs/protocol/v2/session-setup.mdx index e6f951069..dc3d86591 100644 --- a/docs/protocol/v2/session-setup.mdx +++ b/docs/protocol/v2/session-setup.mdx @@ -403,12 +403,14 @@ When the Agent supports `session.mcp.stdio`, Clients can specify MCP servers con The absolute path to the MCP server executable - - Command-line arguments to pass to the server + + Command-line arguments to pass to the server. Omitted and empty values are + equivalent. - Environment variables to set when launching the server + Environment variables to set when launching the server. Omitted and empty + values are equivalent. @@ -453,8 +455,9 @@ When the Agent supports `session.mcp.http`, Clients can specify MCP servers conf The URL of the MCP server - - HTTP headers to include in requests to the server + + HTTP headers to include in requests to the server. Omitted and empty values are + equivalent. diff --git a/schema/v2/schema.json b/schema/v2/schema.json index 01b6b2e7e..d36b40487 100644 --- a/schema/v2/schema.json +++ b/schema/v2/schema.json @@ -1629,7 +1629,6 @@ "items": { "$ref": "#/$defs/AuthMethod" }, - "default": [], "x-deserialize-default-on-error": true, "x-deserialize-skip-invalid-items": true }, @@ -2482,7 +2481,7 @@ "type": "object", "properties": { "sessions": { - "description": "Array of session information objects", + "description": "Array of session information objects.", "type": "array", "items": { "$ref": "#/$defs/SessionInfo" @@ -3836,7 +3835,7 @@ "type": "object", "properties": { "availableCommands": { - "description": "Commands the agent can execute", + "description": "Commands the agent can execute.", "type": "array", "items": { "$ref": "#/$defs/AvailableCommand" @@ -4353,7 +4352,7 @@ "additionalProperties": true } }, - "required": ["name", "url", "headers"] + "required": ["name", "url"] }, "EnvVariable": { "description": "An environment variable to set when launching an MCP server.", @@ -4413,7 +4412,7 @@ "additionalProperties": true } }, - "required": ["name", "command", "args", "env"] + "required": ["name", "command"] }, "LoadSessionRequest": { "description": "Request parameters for loading an existing session.\n\nOnly available if the Agent supports the `session.load` capability.\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/v2/session-setup#loading-sessions)", diff --git a/schema/v2/schema.unstable.json b/schema/v2/schema.unstable.json index 01a3a2769..c7196cc1b 100644 --- a/schema/v2/schema.unstable.json +++ b/schema/v2/schema.unstable.json @@ -2630,7 +2630,6 @@ "items": { "$ref": "#/$defs/AuthMethod" }, - "default": [], "x-deserialize-default-on-error": true, "x-deserialize-skip-invalid-items": true }, @@ -4390,7 +4389,7 @@ "type": "object", "properties": { "sessions": { - "description": "Array of session information objects", + "description": "Array of session information objects.", "type": "array", "items": { "$ref": "#/$defs/SessionInfo" @@ -6434,7 +6433,7 @@ "type": "object", "properties": { "availableCommands": { - "description": "Commands the agent can execute", + "description": "Commands the agent can execute.", "type": "array", "items": { "$ref": "#/$defs/AvailableCommand" @@ -7410,7 +7409,7 @@ "additionalProperties": true } }, - "required": ["name", "url", "headers"] + "required": ["name", "url"] }, "McpServerAcp": { "description": "**UNSTABLE**\n\nThis capability is not part of the spec yet, and may be removed or changed at any point.\n\nACP transport configuration for MCP.\n\nThe MCP server is provided by an ACP component and communicates over the ACP channel\nusing `mcp/connect`, `mcp/message`, and `mcp/disconnect`.", @@ -7474,7 +7473,7 @@ "additionalProperties": true } }, - "required": ["name", "command", "args", "env"] + "required": ["name", "command"] }, "LoadSessionRequest": { "description": "Request parameters for loading an existing session.\n\nOnly available if the Agent supports the `session.load` capability.\n\nSee protocol docs: [Loading Sessions](https://agentclientprotocol.com/protocol/v2/draft/session-setup#loading-sessions)",