Types in pkg/mcp that model the protocol. Most code uses the client and never builds these directly. They matter when you write a transport or a server-side bridge.
JSON-RPC messages
mcp.MCPMessage is a generic JSON-RPC 2.0 message.
| Field | Type | Description |
|---|
JSONRpc | string | |
ID | interface{} | |
Method | string | |
Params | json.RawMessage | |
Result | json.RawMessage | |
Error | *MCPError | |
| Function | Description |
|---|
mcp.CreateRequest(id, method, params) (*MCPMessage, error) | Builds a request. |
mcp.CreateNotification(method, params) (*MCPMessage, error) | Builds a notification (no ID). |
mcp.CreateResponse(id, result) (*MCPMessage, error) | Builds a success response. |
mcp.CreateErrorResponse(id, code, message, data) *MCPMessage | Builds an error response. |
mcp.ValidateJSONRPCMessage(raw []byte) (*MCPMessage, error) | Checks that raw is a well-formed request, notification or response. |
mcp.IsRequest(msg), mcp.IsNotification(msg), mcp.IsResponse(msg), mcp.IsError(msg) | Classify a message. |
mcp.GetError(msg) error | Returns the error from an error response. |
mcp.ParseParams(msg, target), mcp.ParseResult(msg, target) | Decode params or result into target. |
mcp.NewIDGenerator() *IDGenerator | Creates a generator. Next() returns a new request ID. |
Initialize and discover
| Type | Description |
|---|
mcp.InitializeParams | Parameters of the initialize request. |
mcp.InitializeResult | Result of initialize. |
mcp.ClientInfo, mcp.ServerInfo | Name and version of each side. |
mcp.ClientCapabilities | What the client supports. |
mcp.ServerCapabilities | What the server supports. |
mcp.DiscoverResult | Result of server/discover. |
| Field | Type | Description |
|---|
Experimental | map[string]interface{} | |
Extensions | map[string]interface{} | |
Roots | *RootsCapability | |
Sampling | *SamplingCapability | |
Elicitation | map[string]interface{} | |
| Field | Type | Description |
|---|
Experimental | map[string]interface{} | |
Logging | *LoggingCapability | |
Completions | *CompletionsCapability | Completions advertises support for the completion/complete method (hash 68a739a). See (*MCPClient).Complete. |
Prompts | *PromptsCapability | |
Resources | *ResourcesCapability | |
Tools | *ToolsCapability | |
The capability types are mcp.RootsCapability, mcp.SamplingCapability, mcp.ToolsCapability, mcp.ResourcesCapability, mcp.PromptsCapability, mcp.LoggingCapability and mcp.CompletionsCapability.
| Field | Type | Description |
|---|
Name | string | |
Title | string | |
Description | string | |
InputSchema | map[string]interface{} | |
OutputSchema | map[string]interface{} | |
Annotations | map[string]interface{} | |
Meta | map[string]interface{} | |
| Type | Description |
|---|
mcp.ListToolsParams, mcp.ListToolsResult | Parameters and result of tools/list, including pagination. |
mcp.CallToolParams, mcp.CallToolResult | Parameters and result of tools/call. |
mcp.ToolResultContent | One content item in a tool result. |
| Field | Type | Description |
|---|
Content | []ToolResultContent | |
StructuredContent | interface{} | |
ToolResult | interface{} | |
IsError | bool | |
Metadata | map[string]interface{} | |
Resources, prompts and completions
See MCP client for MCPResource, MCPResourceTemplate, ReadResourceParams, ReadResourceResult, ResourceContent, MCPPrompt, PromptMessage, CompleteRequestParams and related types.
Logging
A client can set the server's log level and receive log messages.
| Constant | Value | Description |
|---|
LoggingLevelDebug | "debug" | |
LoggingLevelInfo | "info" | |
LoggingLevelNotice | "notice" | |
LoggingLevelWarning | "warning" | |
LoggingLevelError | "error" | |
LoggingLevelCritical | "critical" | |
LoggingLevelAlert | "alert" | |
LoggingLevelEmergency | "emergency" | |
| Field | Type | Description |
|---|
Level | LoggingLevel | |
| Field | Type | Description |
|---|
Level | LoggingLevel | |
Logger | string | |
Data | interface{} | |