Documentation
¶
Overview ¶
Package mcp is a drop-in compatibility shim for github.com/mark3labs/mcp-go/mcp.
It exists so that ToolHive and its sibling projects can migrate off mcp-go and onto the official Model Context Protocol Go SDK (github.com/modelcontextprotocol/go-sdk) by swapping imports rather than rewriting call sites: replace
github.com/mark3labs/mcp-go/mcp
with
github.com/stacklok/toolhive-core/mcpcompat/mcp
while keeping the existing import alias. The companion packages mcpcompat/server, mcpcompat/client and mcpcompat/client/transport reimplement mcp-go's protocol machinery on top of the official SDK; this package supplies the data types those APIs exchange.
Migration strategy ¶
The types and helpers below are currently re-exported from mcp-go via type aliases and value assignments. This guarantees byte-for-byte wire and source compatibility during the transition: the aliased symbols ARE mcp-go's, so existing struct-literal construction, field access and custom JSON marshaling behave identically.
This file is the single chokepoint that still references mcp-go. The end goal is to remove the mcp-go dependency from the tree entirely. To get there, each alias here is replaced by a standalone definition (copied from the mcp-go source, same JSON tags and marshaling). Because consumers only ever see the symbols in this package, that swap is transparent to them. The wire-format golden tests in this package pin the exact JSON shape of every re-exported type and are what make the alias-to-standalone conversion safe.
Scope ¶
Only the subset of mcp-go's mcp package that ToolHive actually uses is re-exported. Unused surface (sampling, roots, completion, tasks, logging-level control, the fluent schema builder beyond WithDescription/WithString/Required, etc.) is intentionally omitted and can be added on demand.
Stability: Alpha.
Index ¶
- Constants
- Variables
- type Annotated
- type Annotations
- type AudioContent
- type BlobResourceContents
- type CallToolParams
- type CallToolRequest
- type CallToolResult
- type ClientCapabilities
- type Content
- type ElicitationParams
- type ElicitationRequest
- type ElicitationResponse
- type ElicitationResponseAction
- type ElicitationResult
- type EmbeddedResource
- type EmptyResult
- type GetPromptParams
- type GetPromptRequest
- type GetPromptResult
- type ImageContent
- type Implementation
- type InitializeParams
- type InitializeRequest
- type InitializeResult
- type JSONRPCError
- type JSONRPCErrorDetails
- type JSONRPCMessage
- type JSONRPCNotification
- type JSONRPCResponse
- type ListPromptsRequest
- type ListPromptsResult
- type ListResourceTemplatesRequest
- type ListResourceTemplatesResult
- type ListResourcesRequest
- type ListResourcesResult
- type ListToolsRequest
- type ListToolsResult
- type MCPMethod
- type Meta
- type Notification
- type NotificationParams
- type PingRequest
- type Prompt
- type PromptArgument
- type PromptMessage
- type PromptOption
- type PropertyOption
- type ReadResourceParams
- type ReadResourceRequest
- type ReadResourceResult
- type Request
- type RequestId
- type RequestParams
- type Resource
- type ResourceContents
- type ResourceLink
- type ResourceTemplate
- type Result
- type Role
- type ServerCapabilities
- type TextContent
- type TextResourceContents
- type Tool
- type ToolAnnotation
- type ToolInputSchema
- type ToolOption
- type ToolOutputSchema
Constants ¶
const ( MethodInitialize = mcpgo.MethodInitialize MethodToolsList = mcpgo.MethodToolsList MethodToolsCall = mcpgo.MethodToolsCall MethodResourcesList = mcpgo.MethodResourcesList MethodResourcesTemplatesList = mcpgo.MethodResourcesTemplatesList MethodResourcesRead = mcpgo.MethodResourcesRead MethodPromptsList = mcpgo.MethodPromptsList MethodPromptsGet = mcpgo.MethodPromptsGet MethodListRoots = mcpgo.MethodListRoots MethodSetLogLevel = mcpgo.MethodSetLogLevel MethodPing = mcpgo.MethodPing MethodElicitationCreate = mcpgo.MethodElicitationCreate // MethodNotificationInitialized indicates the client finished initialization. MethodNotificationInitialized = mcpgo.MethodNotificationInitialized )
MCP method names.
const ( PARSE_ERROR = mcpgo.PARSE_ERROR INVALID_REQUEST = mcpgo.INVALID_REQUEST METHOD_NOT_FOUND = mcpgo.METHOD_NOT_FOUND INVALID_PARAMS = mcpgo.INVALID_PARAMS INTERNAL_ERROR = mcpgo.INTERNAL_ERROR RESOURCE_NOT_FOUND = mcpgo.RESOURCE_NOT_FOUND )
JSON-RPC / MCP error codes.
const ( RoleUser = mcpgo.RoleUser RoleAssistant = mcpgo.RoleAssistant )
Message roles.
const ( ElicitationResponseActionAccept = mcpgo.ElicitationResponseActionAccept ElicitationResponseActionDecline = mcpgo.ElicitationResponseActionDecline ElicitationResponseActionCancel = mcpgo.ElicitationResponseActionCancel )
Elicitation response actions.
const JSONRPC_VERSION = mcpgo.JSONRPC_VERSION
JSONRPC_VERSION is the JSON-RPC version used by MCP ("2.0").
const LATEST_PROTOCOL_VERSION = mcpgo.LATEST_PROTOCOL_VERSION
LATEST_PROTOCOL_VERSION mirrors mcp-go's latest supported protocol version.
Variables ¶
var ( // NewRequestId wraps a raw id value in a RequestId. NewRequestId = mcpgo.NewRequestId //nolint:revive // name intentionally matches mcp-go for drop-in compatibility. // NewJSONRPCErrorDetails builds a JSONRPCErrorDetails value. NewJSONRPCErrorDetails = mcpgo.NewJSONRPCErrorDetails // NewJSONRPCResultResponse builds a successful JSONRPCResponse. NewJSONRPCResultResponse = mcpgo.NewJSONRPCResultResponse )
JSON-RPC message constructors.
var ( NewTextContent = mcpgo.NewTextContent NewImageContent = mcpgo.NewImageContent NewAudioContent = mcpgo.NewAudioContent NewEmbeddedResource = mcpgo.NewEmbeddedResource NewResourceLink = mcpgo.NewResourceLink )
Content constructors.
var ( AsTextContent = mcpgo.AsTextContent AsImageContent = mcpgo.AsImageContent AsAudioContent = mcpgo.AsAudioContent AsEmbeddedResource = mcpgo.AsEmbeddedResource AsTextResourceContents = mcpgo.AsTextResourceContents AsBlobResourceContents = mcpgo.AsBlobResourceContents )
Content type-assertion helpers.
var ( NewTool = mcpgo.NewTool NewToolWithRawSchema = mcpgo.NewToolWithRawSchema WithDescription = mcpgo.WithDescription WithString = mcpgo.WithString Required = mcpgo.Required Description = mcpgo.Description NewToolResultText = mcpgo.NewToolResultText NewToolResultError = mcpgo.NewToolResultError NewToolResultStructuredOnly = mcpgo.NewToolResultStructuredOnly )
Tool builders and result constructors.
var ( NewPrompt = mcpgo.NewPrompt WithPromptDescription = mcpgo.WithPromptDescription )
Prompt builders.
var ErrMethodNotFound = mcpgo.ErrMethodNotFound
ErrMethodNotFound indicates the requested method does not exist.
var GetTextFromContent = mcpgo.GetTextFromContent
GetTextFromContent extracts text from a content value, if any.
var NewMetaFromMap = mcpgo.NewMetaFromMap
NewMetaFromMap builds a *Meta from a raw map.
var UnmarshalContent = mcpgo.UnmarshalContent
UnmarshalContent decodes a single JSON content object into the concrete mcp.Content implementation (TextContent, ImageContent, ...). It is used by the client shim to populate the Content interface fields of PromptMessage, which mcp-go cannot unmarshal generically.
Functions ¶
This section is empty.
Types ¶
type Annotations ¶
type Annotations = mcpgo.Annotations
Annotations describe audience/priority/lastModified for content.
type AudioContent ¶
type AudioContent = mcpgo.AudioContent
AudioContent is base64-encoded audio content.
type BlobResourceContents ¶
type BlobResourceContents = mcpgo.BlobResourceContents
BlobResourceContents is base64 blob resource contents.
type CallToolParams ¶
type CallToolParams = mcpgo.CallToolParams
CallToolParams are the params of a tool call.
type CallToolRequest ¶
type CallToolRequest = mcpgo.CallToolRequest
CallToolRequest is a request to invoke a tool.
type CallToolResult ¶
type CallToolResult = mcpgo.CallToolResult
CallToolResult is the result of a tool call.
type ClientCapabilities ¶
type ClientCapabilities = mcpgo.ClientCapabilities
ClientCapabilities represents capabilities a client may support.
type ElicitationParams ¶
type ElicitationParams = mcpgo.ElicitationParams
ElicitationParams are the params of an elicitation.
type ElicitationRequest ¶
type ElicitationRequest = mcpgo.ElicitationRequest
ElicitationRequest is a server->client elicitation request.
type ElicitationResponse ¶
type ElicitationResponse = mcpgo.ElicitationResponse
ElicitationResponse is the user's response payload.
type ElicitationResponseAction ¶
type ElicitationResponseAction = mcpgo.ElicitationResponseAction
ElicitationResponseAction indicates accept/decline/cancel.
type ElicitationResult ¶
type ElicitationResult = mcpgo.ElicitationResult
ElicitationResult is the result of an elicitation.
type EmbeddedResource ¶
type EmbeddedResource = mcpgo.EmbeddedResource
EmbeddedResource embeds a resource in content.
type EmptyResult ¶
type EmptyResult = mcpgo.EmptyResult
EmptyResult is an empty MCP result (e.g. the response to ping).
type GetPromptParams ¶
type GetPromptParams = mcpgo.GetPromptParams
GetPromptParams are the params of a get.
type GetPromptRequest ¶
type GetPromptRequest = mcpgo.GetPromptRequest
GetPromptRequest gets a prompt.
type GetPromptResult ¶
type GetPromptResult = mcpgo.GetPromptResult
GetPromptResult is the get response.
type ImageContent ¶
type ImageContent = mcpgo.ImageContent
ImageContent is base64-encoded image content.
type Implementation ¶
type Implementation = mcpgo.Implementation
Implementation describes the name and version of an MCP implementation.
type InitializeParams ¶
type InitializeParams = mcpgo.InitializeParams
InitializeParams are the params of an initialize request.
type InitializeRequest ¶
type InitializeRequest = mcpgo.InitializeRequest
InitializeRequest is sent by the client to begin initialization.
type InitializeResult ¶
type InitializeResult = mcpgo.InitializeResult
InitializeResult is the server's response to initialize.
type JSONRPCError ¶
type JSONRPCError = mcpgo.JSONRPCError
JSONRPCError is a JSON-RPC error response.
type JSONRPCErrorDetails ¶
type JSONRPCErrorDetails = mcpgo.JSONRPCErrorDetails
JSONRPCErrorDetails carries the code/message/data of a JSON-RPC error.
type JSONRPCMessage ¶
type JSONRPCMessage = mcpgo.JSONRPCMessage
JSONRPCMessage is any JSON-RPC request/response/notification/error.
type JSONRPCNotification ¶
type JSONRPCNotification = mcpgo.JSONRPCNotification
JSONRPCNotification is a JSON-RPC notification (no response expected).
type JSONRPCResponse ¶
type JSONRPCResponse = mcpgo.JSONRPCResponse
JSONRPCResponse is a successful JSON-RPC response.
type ListPromptsRequest ¶
type ListPromptsRequest = mcpgo.ListPromptsRequest
ListPromptsRequest requests the prompt list.
type ListPromptsResult ¶
type ListPromptsResult = mcpgo.ListPromptsResult
ListPromptsResult is the prompt list response.
type ListResourceTemplatesRequest ¶
type ListResourceTemplatesRequest = mcpgo.ListResourceTemplatesRequest
ListResourceTemplatesRequest requests the resource-template list.
type ListResourceTemplatesResult ¶
type ListResourceTemplatesResult = mcpgo.ListResourceTemplatesResult
ListResourceTemplatesResult is the resource-template list response.
type ListResourcesRequest ¶
type ListResourcesRequest = mcpgo.ListResourcesRequest
ListResourcesRequest requests the resource list.
type ListResourcesResult ¶
type ListResourcesResult = mcpgo.ListResourcesResult
ListResourcesResult is the resource list response.
type ListToolsRequest ¶
type ListToolsRequest = mcpgo.ListToolsRequest
ListToolsRequest requests the tool list.
type ListToolsResult ¶
type ListToolsResult = mcpgo.ListToolsResult
ListToolsResult is the tool list response.
type Notification ¶
type Notification = mcpgo.Notification
Notification is the base of a JSON-RPC notification (method + params).
type NotificationParams ¶
type NotificationParams = mcpgo.NotificationParams
NotificationParams carries a notification's params.
type PromptArgument ¶
type PromptArgument = mcpgo.PromptArgument
PromptArgument is a prompt template argument.
type PromptMessage ¶
type PromptMessage = mcpgo.PromptMessage
PromptMessage is a message within a prompt result.
type PromptOption ¶
type PromptOption = mcpgo.PromptOption
PromptOption configures a Prompt built via NewPrompt.
type PropertyOption ¶
type PropertyOption = mcpgo.PropertyOption
PropertyOption configures a schema property.
type ReadResourceParams ¶
type ReadResourceParams = mcpgo.ReadResourceParams
ReadResourceParams are the params of a read.
type ReadResourceRequest ¶
type ReadResourceRequest = mcpgo.ReadResourceRequest
ReadResourceRequest reads a resource by URI.
type ReadResourceResult ¶
type ReadResourceResult = mcpgo.ReadResourceResult
ReadResourceResult is the read response.
type RequestId ¶
type RequestId = mcpgo.RequestId //nolint:revive // name intentionally matches mcp-go for drop-in compatibility.
RequestId is a JSON-RPC request identifier.
type RequestParams ¶
type RequestParams = mcpgo.RequestParams
RequestParams is the base params type carrying _meta.
type ResourceContents ¶
type ResourceContents = mcpgo.ResourceContents
ResourceContents is the contents of a resource (text or blob).
type ResourceTemplate ¶
type ResourceTemplate = mcpgo.ResourceTemplate
ResourceTemplate is a URI-templated resource description.
type ServerCapabilities ¶
type ServerCapabilities = mcpgo.ServerCapabilities
ServerCapabilities represents capabilities a server may support.
type TextResourceContents ¶
type TextResourceContents = mcpgo.TextResourceContents
TextResourceContents is text resource contents.
type ToolAnnotation ¶
type ToolAnnotation = mcpgo.ToolAnnotation
ToolAnnotation carries tool behavior hints.
type ToolInputSchema ¶
type ToolInputSchema = mcpgo.ToolInputSchema
ToolInputSchema is a tool's input JSON schema.
type ToolOption ¶
type ToolOption = mcpgo.ToolOption
ToolOption configures a Tool built via NewTool.
type ToolOutputSchema ¶
type ToolOutputSchema = mcpgo.ToolOutputSchema
ToolOutputSchema is a tool's output JSON schema.