Skip to content

Commit 1222f93

Browse files
authored
docs(schema): reject duplicate stdio env names (#2693)
* docs(schema): reject duplicate stdio env names * docs(schema): document unique stdio env names in the Rust doc * docs(schema): let Agents accept duplicate env names, last one wins
1 parent be862da commit 1222f93

7 files changed

Lines changed: 16 additions & 10 deletions

File tree

‎agent-client-protocol-schema/src/v2/agent.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3170,7 +3170,8 @@ pub struct McpServerStdio {
31703170
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-null" = true)))]
31713171
#[serde(default, skip_serializing_if = "Vec::is_empty")]
31723172
pub args: Vec<String>,
3173-
/// Environment variables to set when launching the MCP server.
3173+
/// Environment variables to set when launching the MCP server. Names SHOULD be unique;
3174+
/// Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
31743175
#[serde_as(deserialize_as = "DefaultOnNull")]
31753176
#[cfg_attr(feature = "schemars", schemars(extend("x-deserialize-default-on-null" = true)))]
31763177
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@@ -3207,7 +3208,8 @@ impl McpServerStdio {
32073208
self
32083209
}
32093210

3210-
/// Environment variables to set when launching the MCP server.
3211+
/// Environment variables to set when launching the MCP server. Names SHOULD be unique;
3212+
/// Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
32113213
#[must_use]
32123214
pub fn env(mut self, env: Vec<EnvVariable>) -> Self {
32133215
self.env = env;

‎docs/protocol/v2/draft/schema.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5060,7 +5060,8 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d
50605060
Absolute path to the MCP server executable.
50615061
</ResponseField>
50625062
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
5063-
Environment variables to set when launching the MCP server.
5063+
Environment variables to set when launching the MCP server. Names SHOULD be unique;
5064+
Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
50645065
</ResponseField>
50655066
<ResponseField name="name" type={"string"} required>
50665067
Human-readable name identifying this MCP server.
@@ -5198,7 +5199,8 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/d
51985199
Absolute path to the MCP server executable.
51995200
</ResponseField>
52005201
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
5201-
Environment variables to set when launching the MCP server.
5202+
Environment variables to set when launching the MCP server. Names SHOULD be unique;
5203+
Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
52025204
</ResponseField>
52035205
<ResponseField name="name" type={"string"} required>
52045206
Human-readable name identifying this MCP server.

‎docs/protocol/v2/draft/session-setup.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ Example stdio transport configuration:
601601
}
602602
```
603603

604-
Agents **SHOULD** launch stdio servers with the session's `cwd` as the working directory. `env` entries are added to the environment the Agent would otherwise give the process, replacing variables with the same name. Each `env` entry **MUST** have a unique `name`.
604+
Agents **SHOULD** launch stdio servers with the session's `cwd` as the working directory. `env` entries are added to the environment the Agent would otherwise give the process, replacing variables with the same name. Each `env` entry **SHOULD** have a unique `name`. Agents **MAY** reject duplicates with `-32602`; otherwise the last entry with a given name wins.
605605

606606
#### HTTP Transport
607607

‎docs/protocol/v2/schema.mdx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4431,7 +4431,8 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e
44314431
Absolute path to the MCP server executable.
44324432
</ResponseField>
44334433
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
4434-
Environment variables to set when launching the MCP server.
4434+
Environment variables to set when launching the MCP server. Names SHOULD be unique;
4435+
Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
44354436
</ResponseField>
44364437
<ResponseField name="name" type={"string"} required>
44374438
Human-readable name identifying this MCP server.
@@ -4522,7 +4523,8 @@ See protocol docs: [Extensibility](https://agentclientprotocol.com/protocol/v2/e
45224523
Absolute path to the MCP server executable.
45234524
</ResponseField>
45244525
<ResponseField name="env" type={<a href="#envvariable">EnvVariable[]</a>} >
4525-
Environment variables to set when launching the MCP server.
4526+
Environment variables to set when launching the MCP server. Names SHOULD be unique;
4527+
Agents MAY reject duplicates with `-32602`, and otherwise the last entry wins.
45264528
</ResponseField>
45274529
<ResponseField name="name" type={"string"} required>
45284530
Human-readable name identifying this MCP server.

‎docs/protocol/v2/session-setup.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ Example stdio transport configuration:
533533
}
534534
```
535535

536-
Agents **SHOULD** launch stdio servers with the session's `cwd` as the working directory. `env` entries are added to the environment the Agent would otherwise give the process, replacing variables with the same name. Each `env` entry **MUST** have a unique `name`.
536+
Agents **SHOULD** launch stdio servers with the session's `cwd` as the working directory. `env` entries are added to the environment the Agent would otherwise give the process, replacing variables with the same name. Each `env` entry **SHOULD** have a unique `name`. Agents **MAY** reject duplicates with `-32602`; otherwise the last entry with a given name wins.
537537

538538
#### HTTP Transport
539539

‎schema/v2/schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6416,7 +6416,7 @@
64166416
"x-deserialize-default-on-null": true
64176417
},
64186418
"env": {
6419-
"description": "Environment variables to set when launching the MCP server.",
6419+
"description": "Environment variables to set when launching the MCP server. Names SHOULD be unique;\nAgents MAY reject duplicates with `-32602`, and otherwise the last entry wins.",
64206420
"type": "array",
64216421
"items": {
64226422
"$ref": "#/$defs/EnvVariable"

‎schema/v2/schema.unstable.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7578,7 +7578,7 @@
75787578
"x-deserialize-default-on-null": true
75797579
},
75807580
"env": {
7581-
"description": "Environment variables to set when launching the MCP server.",
7581+
"description": "Environment variables to set when launching the MCP server. Names SHOULD be unique;\nAgents MAY reject duplicates with `-32602`, and otherwise the last entry wins.",
75827582
"type": "array",
75837583
"items": {
75847584
"$ref": "#/$defs/EnvVariable"

0 commit comments

Comments
 (0)