-
Notifications
You must be signed in to change notification settings - Fork 425
feat: Add LocalTransport/RemoteTransport with URL template variables #570
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tadasant
wants to merge
8
commits into
main
Choose a base branch
from
tadasant/support-remotes-in-json
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+350
−49
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4335162
docs: update download link of mcp-publisher in GitHub Actions to 1.1.…
yuna0x0 2500a7b
feat: Add LocalTransport and RemoteTransport definitions with variabl…
tadasant e17043d
docs: Remove deprecated server example that was removed in main
tadasant c9cd1d0
test: Add test coverage for remote transport URL variable validation
tadasant 9f127fe
fix: Add URL pattern validation for StreamableHttp and SSE transports
tadasant e1de336
refactor: Replace schema pattern test with SSE template validation ex…
tadasant 2219838
refactor: Make RemoteTransport schema more DRY using nested composition
tadasant 112442f
refactor: Remove unused allowTemplates parameter from IsValidTemplate…
tadasant File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -672,3 +672,91 @@ For MCP servers that follow a custom installation path or are embedded in applic | |||||
} | ||||||
``` | ||||||
|
||||||
|
||||||
### Remote Server with URL Templating | ||||||
|
||||||
This example demonstrates URL templating for remote servers, useful for multi-tenant deployments where each instance has its own endpoint. Unlike Package transports (which reference parent arguments/environment variables), Remote transports define their own variables: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json", | ||||||
"name": "io.modelcontextprotocol.anonymous/multi-tenant-server", | ||||||
"description": "MCP server with configurable remote endpoint", | ||||||
"title": "Multi-Tenant Server", | ||||||
"version": "1.0.0", | ||||||
"remotes": [ | ||||||
{ | ||||||
"type": "streamable-http", | ||||||
"url": "https://anonymous.modelcontextprotocol.io/mcp/{tenant_id}", | ||||||
"variables": { | ||||||
"tenant_id": { | ||||||
"description": "Tenant identifier (e.g., 'us-cell1', 'emea-cell1')", | ||||||
"isRequired": true | ||||||
} | ||||||
} | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
Clients configure the tenant identifier, and the `{tenant_id}` variable in the URL gets replaced with the provided variable value to connect to the appropriate tenant endpoint (e.g., `https://anonymous.modelcontextprotocol.io/mcp/us-cell1` or `https://anonymous.modelcontextprotocol.io/mcp/emea-cell1`). | ||||||
|
||||||
The same URL templating works with SSE transport: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json", | ||||||
"name": "io.modelcontextprotocol.anonymous/events-server", | ||||||
"description": "MCP server using SSE with tenant-specific endpoints", | ||||||
"version": "1.0.0", | ||||||
"remotes": [ | ||||||
{ | ||||||
"type": "sse", | ||||||
"url": "https://events.anonymous.modelcontextprotocol.io/sse/{tenant_id}", | ||||||
"variables": { | ||||||
"tenant_id": { | ||||||
"description": "Tenant identifier", | ||||||
"isRequired": true | ||||||
} | ||||||
} | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
### Local Server with URL Templating | ||||||
|
||||||
This example demonstrates URL templating for local/package servers, where variables reference parent Package arguments or environment variables: | ||||||
|
||||||
```json | ||||||
{ | ||||||
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json", | ||||||
"name": "io.github.example/configurable-server", | ||||||
"description": "Local MCP server with configurable port", | ||||||
"title": "Configurable Server", | ||||||
"version": "1.0.0", | ||||||
"packages": [ | ||||||
{ | ||||||
"registryType": "npm", | ||||||
"registryBaseUrl": "https://registry.npmjs.org", | ||||||
"identifier": "@example/mcp-server", | ||||||
"version": "1.0.0", | ||||||
"transport": { | ||||||
"type": "streamable-http", | ||||||
"url": "http://localhost:{port}/mcp" | ||||||
}, | ||||||
"packageArguments": [ | ||||||
{ | ||||||
"type": "named", | ||||||
"name": "--port", | ||||||
"description": "Port for the server to listen on", | ||||||
"default": "3000", | ||||||
"valueHint": "port" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
} | ||||||
] | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
|
||||||
The `{port}` variable in the URL references either the `--port` argument name or the `port` valueHint from packageArguments. When the package runs with `--port 8080`, the URL becomes `http://localhost:8080/mcp`. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As things are specified currently we take the
name
literally