Skip to content

Commit d56d3c5

Browse files
committed
Added simulated discrimintated union for transports and arguments to avoid "anyOf" fan out schema validation errors (where all templates fail when none match)
1 parent a09ae89 commit d56d3c5

File tree

1 file changed

+37
-26
lines changed

1 file changed

+37
-26
lines changed

docs/reference/server-json/server.schema.json

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,21 @@
8787
]
8888
},
8989
"transport": {
90-
"anyOf": [
91-
{
92-
"$ref": "#/definitions/StdioTransport"
93-
},
94-
{
95-
"$ref": "#/definitions/StreamableHttpTransport"
96-
},
97-
{
98-
"$ref": "#/definitions/SseTransport"
90+
"type": "object",
91+
"properties": {
92+
"type": {
93+
"type": "string",
94+
"enum": ["stdio", "streamable-http", "sse"]
9995
}
100-
],
96+
},
97+
"required": ["type"],
98+
"if": {"properties": {"type": {"const": "stdio"}}},
99+
"then": {"$ref": "#/definitions/StdioTransport"},
100+
"else": {
101+
"if": {"properties": {"type": {"const": "streamable-http"}}},
102+
"then": {"$ref": "#/definitions/StreamableHttpTransport"},
103+
"else": {"$ref": "#/definitions/SseTransport"}
104+
},
101105
"description": "Transport protocol configuration for the package"
102106
},
103107
"runtimeArguments": {
@@ -292,14 +296,17 @@
292296
},
293297
"Argument": {
294298
"description": "Warning: Arguments construct command-line parameters that may contain user-provided input. This creates potential command injection risks if clients execute commands in a shell environment. For example, a malicious argument value like ';rm -rf ~/Development' could execute dangerous commands. Clients should prefer non-shell execution methods (e.g., posix_spawn) when possible to eliminate injection risks entirely. Where not possible, clients should obtain consent from users or agents to run the resolved command before execution.",
295-
"anyOf": [
296-
{
297-
"$ref": "#/definitions/PositionalArgument"
298-
},
299-
{
300-
"$ref": "#/definitions/NamedArgument"
299+
"type": "object",
300+
"properties": {
301+
"type": {
302+
"type": "string",
303+
"enum": ["positional", "named"]
301304
}
302-
]
305+
},
306+
"required": ["type"],
307+
"if": {"properties": {"type": {"const": "positional"}}},
308+
"then": {"$ref": "#/definitions/PositionalArgument"},
309+
"else": {"$ref": "#/definitions/NamedArgument"}
303310
},
304311
"StdioTransport": {
305312
"type": "object",
@@ -334,6 +341,7 @@
334341
},
335342
"url": {
336343
"type": "string",
344+
"pattern": "^https?://[^\\s]+$",
337345
"description": "URL template for the streamable-http transport. Variables in {curly_braces} reference argument valueHints, argument names, or environment variable names. After variable substitution, this should produce a valid URI.",
338346
"example": "https://api.example.com/mcp"
339347
},
@@ -363,8 +371,8 @@
363371
},
364372
"url": {
365373
"type": "string",
366-
"format": "uri",
367-
"description": "Server-Sent Events endpoint URL",
374+
"pattern": "^https?://[^\\s]+$",
375+
"description": "URL template for the sse transport. Variables in {curly_braces} reference argument valueHints, argument names, or environment variable names. After variable substitution, this should produce a valid URI.",
368376
"example": "https://mcp-fs.example.com/sse"
369377
},
370378
"headers": {
@@ -490,14 +498,17 @@
490498
"remotes": {
491499
"type": "array",
492500
"items": {
493-
"anyOf": [
494-
{
495-
"$ref": "#/definitions/StreamableHttpTransport"
496-
},
497-
{
498-
"$ref": "#/definitions/SseTransport"
501+
"type": "object",
502+
"properties": {
503+
"type": {
504+
"type": "string",
505+
"enum": ["streamable-http", "sse"]
499506
}
500-
]
507+
},
508+
"required": ["type"],
509+
"if": {"properties": {"type": {"const": "streamable-http"}}},
510+
"then": {"$ref": "#/definitions/StreamableHttpTransport"},
511+
"else": {"$ref": "#/definitions/SseTransport"}
501512
}
502513
},
503514
"_meta": {

0 commit comments

Comments
 (0)