|
| 1 | +--- |
| 2 | +title: Groups |
| 3 | +--- |
| 4 | + |
| 5 | +<div id="enable-section-numbers" /> |
| 6 | + |
| 7 | +<Info>**Protocol Revision**: draft</Info> |
| 8 | + |
| 9 | +The Model Context Protocol (MCP) allows servers to organize primitives (tools, prompts, resources, |
| 10 | +tasks, and groups themselves) into named collections called groups. Groups provide a natural |
| 11 | +abstraction for organizing primitives by functional areas, use cases, or access control boundaries. |
| 12 | + |
| 13 | +## User Interaction Model |
| 14 | + |
| 15 | +Groups in MCP are designed to be **application-controlled**, meaning that clients and hosts can |
| 16 | +use groups to filter and organize which primitives are presented to language models. |
| 17 | + |
| 18 | +Common use cases include: |
| 19 | + |
| 20 | +- **Client-side Filtering**: Present only relevant primitives based on user context |
| 21 | +- **Simplified Instructions**: Reduce cognitive load on LLMs by showing focused subsets |
| 22 | +- **Access Control**: Enable permission boundaries at the group level |
| 23 | +- **Progressive Disclosure**: Allow clients to present primitives in manageable subsets |
| 24 | + |
| 25 | +Implementations are free to use groups through any interface pattern that suits their |
| 26 | +needs—the protocol itself does not mandate any specific user interaction model. |
| 27 | + |
| 28 | +## Capabilities |
| 29 | + |
| 30 | +Servers that support groups **MUST** declare the `groups` capability: |
| 31 | + |
| 32 | +```json |
| 33 | +{ |
| 34 | + "capabilities": { |
| 35 | + "groups": { |
| 36 | + "listChanged": true |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +`listChanged` indicates whether the server will emit notifications when the list of |
| 43 | +available groups changes. |
| 44 | + |
| 45 | +## Protocol Messages |
| 46 | + |
| 47 | +### Listing Groups |
| 48 | + |
| 49 | +To discover available groups, clients send a `groups/list` request. This operation supports |
| 50 | +[pagination](/specification/draft/server/utilities/pagination). |
| 51 | + |
| 52 | +**Request:** |
| 53 | + |
| 54 | +```json |
| 55 | +{ |
| 56 | + "jsonrpc": "2.0", |
| 57 | + "id": 1, |
| 58 | + "method": "groups/list", |
| 59 | + "params": { |
| 60 | + "cursor": "optional-cursor-value" |
| 61 | + } |
| 62 | +} |
| 63 | +``` |
| 64 | + |
| 65 | +**Response:** |
| 66 | + |
| 67 | +```json |
| 68 | +{ |
| 69 | + "jsonrpc": "2.0", |
| 70 | + "id": 1, |
| 71 | + "result": { |
| 72 | + "groups": [ |
| 73 | + { |
| 74 | + "name": "user-management", |
| 75 | + "title": "User Management Tools", |
| 76 | + "description": "Tools used for managing user accounts within the system." |
| 77 | + }, |
| 78 | + { |
| 79 | + "name": "mapping", |
| 80 | + "title": "Geospatial Mapping Tools", |
| 81 | + "description": "Tools for map rendering and spatial analysis.", |
| 82 | + "icons": [ |
| 83 | + { |
| 84 | + "src": "https://example.com/mapping-icon.png", |
| 85 | + "mimeType": "image/png", |
| 86 | + "sizes": ["48x48"] |
| 87 | + } |
| 88 | + ] |
| 89 | + } |
| 90 | + ], |
| 91 | + "nextCursor": "next-page-cursor" |
| 92 | + } |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +### List Changed Notification |
| 97 | + |
| 98 | +When the list of available groups changes, or when any group's metadata (such as |
| 99 | +`title`, `description`, or `icons`) is modified, servers that declared the `listChanged` |
| 100 | +capability **SHOULD** send a notification: |
| 101 | + |
| 102 | +```json |
| 103 | +{ |
| 104 | + "jsonrpc": "2.0", |
| 105 | + "method": "notifications/groups/list_changed" |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +## Primitive Group Membership |
| 110 | + |
| 111 | +Primitives indicate their group membership using the reserved `_meta` key |
| 112 | +`io.modelcontextprotocol/groups`. The value is an array of group names: |
| 113 | + |
| 114 | +```json |
| 115 | +{ |
| 116 | + "name": "create_user", |
| 117 | + "description": "Creates a new user account", |
| 118 | + "inputSchema": { |
| 119 | + "type": "object", |
| 120 | + "properties": { |
| 121 | + "username": { "type": "string" } |
| 122 | + } |
| 123 | + }, |
| 124 | + "_meta": { |
| 125 | + "io.modelcontextprotocol/groups": ["user-management", "admin"] |
| 126 | + } |
| 127 | +} |
| 128 | +``` |
| 129 | + |
| 130 | +This approach allows: |
| 131 | + |
| 132 | +- **Multi-group Membership**: A primitive can belong to multiple groups |
| 133 | +- **Nested Groups**: Groups themselves can belong to other groups |
| 134 | +- **Flexible Organization**: Group structure is not limited to strict hierarchies |
| 135 | + |
| 136 | +### Nested Groups |
| 137 | + |
| 138 | +Groups can be nested by having a group reference other groups in its `_meta`: |
| 139 | + |
| 140 | +```json |
| 141 | +{ |
| 142 | + "name": "email", |
| 143 | + "title": "Email Tools", |
| 144 | + "description": "Tools for composing and sending emails.", |
| 145 | + "_meta": { |
| 146 | + "io.modelcontextprotocol/groups": ["productivity"] |
| 147 | + } |
| 148 | +} |
| 149 | +``` |
| 150 | + |
| 151 | +In this example, the `email` group is a member of the `productivity` group, |
| 152 | +creating a hierarchy. |
| 153 | + |
| 154 | +### Membership Changed Notifications |
| 155 | + |
| 156 | +When primitives change their group membership, servers **SHOULD** use the appropriate |
| 157 | +primitive-specific notification: |
| 158 | + |
| 159 | +- Tools: `notifications/tools/list_changed` |
| 160 | +- Prompts: `notifications/prompts/list_changed` |
| 161 | +- Resources: `notifications/resources/list_changed` |
| 162 | +- Tasks: `notifications/tasks/status` |
| 163 | +- Groups: `notifications/groups/list_changed` |
| 164 | + |
| 165 | +Clients receiving these notifications can re-fetch the primitive lists to discover |
| 166 | +updated group memberships. |
| 167 | + |
| 168 | +## Message Flow |
| 169 | + |
| 170 | +```mermaid |
| 171 | +sequenceDiagram |
| 172 | + participant Client |
| 173 | + participant Server |
| 174 | +
|
| 175 | + Note over Client,Server: Discovery |
| 176 | + Client->>Server: groups/list |
| 177 | + Server-->>Client: List of groups |
| 178 | +
|
| 179 | + Note over Client,Server: Primitive Discovery |
| 180 | + Client->>Server: tools/list |
| 181 | + Server-->>Client: Tools with _meta.groups |
| 182 | +
|
| 183 | + Note over Client: Client filters tools by group |
| 184 | +
|
| 185 | + Note over Client,Server: Updates |
| 186 | + Server--)Client: notifications/groups/list_changed |
| 187 | + Client->>Server: groups/list |
| 188 | + Server-->>Client: Updated groups |
| 189 | +``` |
| 190 | + |
| 191 | +## Data Types |
| 192 | + |
| 193 | +### Group |
| 194 | + |
| 195 | +A group definition includes: |
| 196 | + |
| 197 | +- `name`: Unique identifier for the group |
| 198 | +- `title`: Optional human-readable name of the group for display purposes |
| 199 | +- `description`: Human-readable description of the group's purpose |
| 200 | +- `icons`: Optional array of icons for display in user interfaces |
| 201 | +- `annotations`: Optional additional group information |
| 202 | +- `_meta`: Optional metadata, including group membership for nested groups |
| 203 | + |
| 204 | +#### Group Names |
| 205 | + |
| 206 | +TBD: Maybe similar to tool names? |
0 commit comments