-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[RFC] Namespaces #334
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
Closed
Closed
[RFC] Namespaces #334
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3d1f087
Namespace v0.0.1
patwhite 910f508
WIP
patwhite 4557caa
Straw Man
patwhite ce91e2c
WIP
patwhite 638edd7
Typo
patwhite 789f834
Merge branch 'modelcontextprotocol:main' into namespaces
patwhite 99514f8
Merge branch 'namespaces' of github.com:Traego/modelcontextprotocol-s…
patwhite fe2bf9a
Moving spec against draft
patwhite d36ff79
Fix
patwhite b79da96
typo fix
patwhite 7e6ee53
Schema Updates
patwhite bfde7c6
Namespaced Tool List
patwhite 41a17ff
Clarified dots as acceptable namespace character
patwhite af1b76e
Schema documentation update
patwhite e7b5bcf
Merge branch 'modelcontextprotocol:main' into namespaces
patwhite dda22db
Merge branch 'modelcontextprotocol:main' into namespaces
patwhite 8b91012
WIP
patwhite 7390f37
Merge branch 'namespaces' of github.com:Traego/modelcontextprotocol-s…
patwhite 7b41874
Tweaked naming requirements slightly
patwhite 6faa464
Nit Fix on Namespace page
patwhite 355ba48
Linted and removed @ signed
patwhite 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 |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| --- | ||
| title: Namespaces | ||
| --- | ||
|
|
||
| <Info>**Protocol Revision**: 2025-03-26</Info> | ||
|
|
||
| As MCP servers grow in complexity and number of tools, resources, and prompts, it may | ||
| be necessary to logically separate feature areas by namespace. MCP implements namespaces | ||
| using a single hierarchy model, where a specially annotated single preceding identifier is used to group related tools, | ||
| prompts, and resources. | ||
|
|
||
| ## Overview | ||
|
|
||
| Namespacing functionality is implemented through a simple, single depth hierarchy, e.g. `weather`. | ||
| This namespace is then optionally included in method calls and name parameters. | ||
|
|
||
| ## Capability | ||
|
|
||
| To indicate support for feature level advanced filtering, i.e. `<namespace>/tools/list`, the server **MAY** expose a | ||
| namespace capability: | ||
|
|
||
| ```json | ||
| { | ||
| "capabilities": { | ||
| "namespaces": {} | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Namespace Format | ||
|
|
||
| A namespace must be a string of is any of alphanumeric characters (A-Z, a-z, 0-9), underscores, and hyphens. | ||
| For instance, com_github would be an acceptable namespace. | ||
|
|
||
| ### Tool, Resource, and Prompt Names | ||
|
|
||
| As part of being in a namespace, a tool name or prompt name **MUST** begin with the namespace, e.g. | ||
| `weather__get_weather_forecast_by_location`. | ||
|
|
||
| ## Namespace Prefixing | ||
|
|
||
| ### Listing | ||
|
|
||
| As an optional capability (for backwards compatibility), the server **MAY** expose a namespace list feature. | ||
|
|
||
| ```json | ||
| { | ||
| "capabilities": { | ||
| "namespaces": { | ||
| "list": true | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| **Request:** | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 3, | ||
| "method": "namespaces/list" | ||
| } | ||
| ``` | ||
|
|
||
| **Response:** | ||
|
|
||
| ```json | ||
| { | ||
| "jsonrpc": "2.0", | ||
| "id": 3, | ||
| "result": { | ||
| "namespaces": [ | ||
| { | ||
| "name": "weather", | ||
| "description": "Collection of tools, resources, and prompts to help with weather based queries. Includes tools to retrieve current weather by location, weather forecasts by location, and more." | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 2. List commands can be invoked by prepending a namespace prefix to the method name `weather/namespaces/list`, which | ||
|
|
||
| ### Filtering | ||
|
|
||
| 1. List commands can be invoked by prepending a namespace prefix to the method name `weather/tools/list`, which will | ||
| return a paginated list of tools within the `weather` namespace. | ||
|
|
||
| ## Usage Patterns | ||
|
|
||
| ```mermaid | ||
| sequenceDiagram | ||
| participant Client | ||
| participant Server | ||
|
|
||
| Note over Client,Server: Discovery | ||
| Client->>Server: namespaces/list | ||
| Server-->>Client: List of namespaces | ||
|
|
||
| Note over Client,Server: Tool Listing | ||
| Client->>Server: namespace/tools/list | ||
| Server-->>Client: Tool list | ||
|
|
||
| Note over Client,Server: Prompt Listing | ||
| Client->>Server: namespace/prompts/list | ||
| Server-->>Client: Tool list | ||
|
|
||
| Note over Client,Server: Resource Listing | ||
| Client->>Server: namespace/resources/list | ||
| Server-->>Client: Resource list | ||
|
|
||
| Note over Client,Server: Resource Template Listing | ||
| Client->>Server: namespace/resources/templates/list | ||
| Server-->>Client: Resource Template list | ||
| ``` | ||
|
|
||
| ## Implementation Considerations | ||
|
|
||
| - Namespace registration and requirement enforcement is an implementation detail - in shared environments, it may be | ||
| necessary to require tools have an approved namespaces, but this spec offers no guidance on this. | ||
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
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.
I think this should add a brief note on the possibility of namespace conflicts across different connected servers, from a client application or proxy standpoint. Essentially just something to mirror #701, acknowledging that namespaces aren't necessarily be globally-unique. I think we don't need suggestions on how exactly to handle that in the spec, but it's useful to note that it is something to handle.
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.
Ya, thinking through my comment above to cliff, I think it's reasonable to codify that clients can rename namespaces to avoid collisions, but should never rename tools (since that might break different flows)