Add Support for SEP-2084: Primitive Grouping #1399
Draft
+627
−36
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.
Implemented the new
groupsprimitive across the MCP TypeScript SDK, allowing servers to organize primitives (tools, prompts, tasks, resources, and groups themselves) into logical groups. This change includes updates to the core protocol schemas, high-level server and client APIs, and comprehensive testing.PR Description: Implementation of Groups Primitive
This PR introduces the
groupsprimitive to the Model Context Protocol TypeScript SDK, enabling servers to categorize and organize their offerings.Core Changes (
@modelcontextprotocol/core)src/types/types.tsGROUPS_META_KEYconstant (io.modelcontextprotocol/groups).BaseMetadataSchemato includenameand optionaltitle.GroupSchemaandGrouptype for defining group objects.ServerCapabilitiesSchema.groupsto allow servers to advertise group support andlistChangednotifications.ListGroupsRequestSchema,ListGroupsResultSchema, andGroupListChangedNotificationSchemafor protocol-level group management.ToolSchema,PromptSchema,ResourceSchema, andTaskSchemato support thegroupskey in their_metaobjects.ListChangedHandlerssupport for groups in client-side configuration.src/shared/protocol.tslistGroupsmethod to the baseProtocolclass to handlegroups/listrequests.Server Changes (
@modelcontextprotocol/server)src/server/server.tssendGroupListChanged()method to theServerclass to emitnotifications/groups/list_changedto connected clients.src/server/mcp.tsregisterGroup()to the high-levelMcpServerAPI.groups/listrequests.registerTool,registerPrompt, andregisterResourceto correctly propagate_metainformation (including group memberships) to the client.list_changednotifications are sent if changes occur post-connection.update()methods for registered primitives to handle dynamic name changes and metadata updates.Client Changes (
@modelcontextprotocol/client)src/client/client.tslistGroups()method to fetch the list of groups from a server.groupsinto thelistChangednotification handling system, allowing clients to automatically refresh group lists when the server notifies of changes.Testing
packages/server/test/server/groups.test.ts(New)_meta.groupsis only present in listed primitives when they are actually assigned to a group.test/integration/test/client/client.test.tsgroups/listandnotifications/groups/list_changed.Motivation and Context
Reference implementation for SEP-2084: Primitive Grouping.
How Has This Been Tested?
Unit tests for client and server included in PR.
Breaking Changes
None.
Types of changes
Checklist
Additional context