Commit 59a898c
fix: Handle port-position template variables in URL validation
When validating URLs with template variables in the port position
(e.g., http://localhost:{--port}/mcp), the validator was incorrectly
replacing the template variable with the string "placeholder", which
caused URL parsing to fail since ports must be numeric.
This commit fixes the issue by:
- Detecting when a template variable appears in a port position
(after a colon and before a slash or end of string)
- Replacing port-position template variables with a numeric placeholder
"8080" instead of "placeholder"
- Adding a new error constant ErrInvalidPackageTransportURL to
distinguish package transport errors from remote transport errors
- Updating validatePackageTransport to use the correct error constant
The fix allows named arguments like "--port" to be properly referenced
in package transport URLs, enabling examples like:
```json
{
"transport": {
"type": "streamable-http",
"url": "http://localhost:{--port}/mcp"
},
"packageArguments": [
{
"type": "named",
"name": "--port",
"default": "3000"
}
]
}
```
Fixes validation of Example 15 in generic-server-json.md (line 732)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <[email protected]>1 parent 15cee49 commit 59a898c
3 files changed
+12
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
| 412 | + | |
413 | 413 | | |
414 | | - | |
| 414 | + | |
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| |||
0 commit comments