-
Notifications
You must be signed in to change notification settings - Fork 459
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
base: main
Are you sure you want to change the base?
Changes from 8 commits
4335162
2500a7b
e17043d
c9cd1d0
9f127fe
e1de336
2219838
112442f
d948cb5
15cee49
59a898c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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" | ||
|
||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| 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`. | ||
tadasant marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Uh oh!
There was an error while loading. Please reload this page.