Protocol
Category: Mcp_client
Source: protocol.dart
MCP wire-protocol message types (Model Context Protocol).
MCP is layered on JSON-RPC 2.0. We reuse glue_server's [JsonRpcMessage]/[JsonRpcTransport] for framing and add MCP-specific param/result shapes here.
Pure data — no I/O. See client.dart for the dispatch logic and transport/stdio.dart for the subprocess transport.
Classes
McpClientInfo
Constructor
dart
const McpClientInfo({required this.name, required this.version})Properties
| Property | Type | Description |
|---|---|---|
name | String | |
version | String |
McpServerInfo
Constructor
dart
const McpServerInfo({required this.name, required this.version})dart
factory McpServerInfo.fromJson(Map<String, dynamic> json)Properties
| Property | Type | Description |
|---|---|---|
name | String | |
version | String |
McpClientCapabilities
Constructor
dart
const McpClientCapabilities({this.roots})Properties
| Property | Type | Description |
|---|---|---|
roots | McpRootsCapability? | We advertise roots so servers (e.g. filesystem) can scope access. |
McpRootsCapability
Constructor
dart
const McpRootsCapability({this.listChanged = false})Properties
| Property | Type | Description |
|---|---|---|
listChanged | bool |
McpServerCapabilities
Constructor
dart
const McpServerCapabilities({
this.tools,
this.prompts,
this.resources,
this.sampling,
this.logging,
this.experimental,
})dart
factory McpServerCapabilities.fromJson(Map<String, dynamic> json)Properties
| Property | Type | Description |
|---|---|---|
tools | McpToolsCapability? | |
prompts | Map<String, dynamic>? | |
resources | Map<String, dynamic>? | |
sampling | Map<String, dynamic>? | |
logging | Map<String, dynamic>? | |
experimental | Map<String, dynamic>? | |
supportsSampling | bool get | |
supportsSampling | bool get |
McpToolsCapability
Constructor
dart
const McpToolsCapability({this.listChanged = false})dart
factory McpToolsCapability.fromJson(Map<String, dynamic> json)dart
McpToolsCapability(listChanged: json['listChanged'] as bool? ?? false)Properties
| Property | Type | Description |
|---|---|---|
listChanged | bool |
McpInitializeResult
Constructor
dart
const McpInitializeResult({
required this.protocolVersion,
required this.serverInfo,
required this.capabilities,
this.instructions,
})dart
factory McpInitializeResult.fromJson(Map<String, dynamic> json)Properties
| Property | Type | Description |
|---|---|---|
protocolVersion | String | |
serverInfo | McpServerInfo | |
capabilities | McpServerCapabilities | |
instructions | String? |
McpToolDescriptor
Constructor
dart
const McpToolDescriptor({
required this.name,
required this.description,
required this.inputSchema,
})dart
factory McpToolDescriptor.fromJson(Map<String, dynamic> json)Properties
| Property | Type | Description |
|---|---|---|
name | String | |
description | String | |
inputSchema | Map<String, dynamic> |
sealed McpContent
One content item in a tool call result. MCP supports text, image, and embedded resource variants; we model only text directly and pass other kinds through as opaque maps so the agent loop can ignore them.
Constructor
dart
const McpContent()dart
factory McpContent.fromJson(Map<String, dynamic> json)McpTextContent
Constructor
dart
const McpTextContent(this.text)Properties
| Property | Type | Description |
|---|---|---|
text | String |
McpOpaqueContent
Constructor
dart
const McpOpaqueContent(this.type, this.raw)Properties
| Property | Type | Description |
|---|---|---|
type | String | |
raw | Map<String, dynamic> |
McpToolCallResult
Constructor
dart
const McpToolCallResult({required this.content, this.isError = false})dart
factory McpToolCallResult.fromJson(Map<String, dynamic> json)Properties
| Property | Type | Description |
|---|---|---|
content | List<McpContent> | |
isError | bool | |
textPayload | String get | Concatenates all text content into a single string. Non-text items are summarised as [<type>]. Used to build the LLM-facing payload. |
abstract McpErrorCode
MCP-specific JSON-RPC error codes. The standard JSON-RPC codes (-32700..-32603) come from [JsonRpcErrorCode] in glue_server.
Properties
| Property | Type | Description |
|---|---|---|
rateLimited | const int | Glue-reserved: the server is rate-limited. Honour Retry-After / data.retry_after_seconds and retry once. |
abstract McpMethod
Properties
| Property | Type | Description |
|---|---|---|
initialize | const | |
initialized | const | |
toolsList | const | |
toolsCall | const | |
toolsListChanged | const | |
ping | const |