Documentation
¶
Index ¶
- Constants
- type CallToolRequest
- type CallToolResponse
- type CallToolsBatchRequest
- type CallToolsBatchResponsedeprecated
- type CallToolsResponse
- type CancelRequest
- type ClientCapabilities
- type ClientDSL
- func (client *ClientDSL) GetAuthorizationToken() string
- func (client *ClientDSL) GetClientCapabilities() ClientCapabilities
- func (client *ClientDSL) GetEnvs() []string
- func (client *ClientDSL) GetImplementation() Implementation
- func (client *ClientDSL) GetTimeout() time.Duration
- func (client *ClientDSL) GetVersion() string
- type ClientInfo
- type Config
- type ConnectionOptions
- type ConnectionState
- type ElicitationCapability
- type EmbeddedResource
- type Error
- type ErrorHandler
- type Event
- type GetPromptRequest
- type GetPromptResponse
- type Implementation
- type InitializeRequest
- type InitializeResponse
- type ListPromptsRequest
- type ListPromptsResponse
- type ListResourcesRequest
- type ListResourcesResponse
- type ListSamplesResponse
- type ListToolsRequest
- type ListToolsResponse
- type LogLevel
- type LogMessage
- type LoggingCapability
- type MappingData
- type Message
- type NotificationHandler
- type Progress
- type ProgressNotification
- type Prompt
- type PromptArgument
- type PromptContent
- type PromptContentType
- type PromptMessage
- type PromptRole
- type PromptSchema
- type PromptsCapability
- type ReadResourceRequest
- type ReadResourceResponse
- type RequestHandler
- type Resource
- type ResourceContent
- type ResourceParameter
- type ResourceSchema
- type ResourceUpdatedNotification
- type ResourcesCapability
- type RootsCapability
- type SampleData
- type SampleItemType
- type SamplingCapability
- type SamplingContent
- type SamplingMessage
- type SamplingRequest
- type SamplingResponse
- type ServerCapabilities
- type ServerInfo
- type SetLogLevelRequest
- type Tool
- type ToolCall
- type ToolContent
- type ToolContentType
- type ToolSchema
- type ToolsCapability
- type Transport
- type TransportType
Constants ¶
const ( TypeRequest = "request" TypeResponse = "response" TypeNotification = "notification" )
Message types
const ( ErrorCodeParseError = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 )
Standard error codes
const ( EventTypeConnected = "connected" EventTypeDisconnected = "disconnected" EventTypeError = "error" EventTypeMessage = "message" )
const (
ProtocolVersion = "2025-06-18"
)
Protocol version
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallToolRequest ¶
type CallToolRequest struct {
Name string `json:"name"`
Arguments interface{} `json:"arguments,omitempty"`
}
type CallToolResponse ¶
type CallToolResponse struct {
Content []ToolContent `json:"content"`
IsError bool `json:"isError,omitempty"`
}
type CallToolsBatchRequest ¶
type CallToolsBatchRequest struct {
Tools []ToolCall `json:"tools"`
}
type CallToolsBatchResponse
deprecated
type CallToolsBatchResponse = CallToolsResponse
Deprecated: Use CallToolsResponse instead
type CallToolsResponse ¶
type CallToolsResponse struct {
Results []CallToolResponse `json:"results"`
}
type CancelRequest ¶
type CancelRequest struct {
RequestID interface{} `json:"requestId"`
}
Cancellation types
type ClientCapabilities ¶
type ClientCapabilities struct {
Sampling *SamplingCapability `json:"sampling,omitempty"`
Roots *RootsCapability `json:"roots,omitempty"`
Elicitation *ElicitationCapability `json:"elicitation,omitempty"`
Experimental map[string]interface{} `json:"experimental,omitempty"`
}
Capabilities
type ClientDSL ¶
type ClientDSL struct {
ID string `json:"id,omitempty"` // The ID of the MCP Client (required)
Name string `json:"name"` // The name of the MCP Client (required)
Version string `json:"version,omitempty"` // The version of the MCP Client
Type string `json:"type,omitempty"` // The type of the MCP Client (e.g., "standard", "agent", "system")
Transport TransportType `json:"transport"` // One of the TransportType (required)
types.MetaInfo
Dependencies map[string]string `json:"dependencies,omitempty"` // Dependencies on other MCP Clients (name -> version constraint)
// Client capabilities configuration
EnableSampling bool `json:"enable_sampling,omitempty"` // Enable sampling capability
EnableRoots bool `json:"enable_roots,omitempty"` // Enable roots capability
RootsListChanged bool `json:"roots_list_changed,omitempty"` // Whether to be notified of root changes
EnableElicitation bool `json:"enable_elicitation,omitempty"` // Enable elicitation capability
// For HTTP, SSE transport
URL string `json:"url,omitempty"` // For HTTP、SSE transport (optional)
Endpoint string `json:"endpoint,omitempty"` // API endpoint path (e.g., "/api/mcp")
AuthorizationToken string `json:"authorization_token,omitempty"` // For HTTP、SSE transport
// For stdio transport
Command string `json:"command,omitempty"` // for stdio transport
Arguments []string `json:"arguments,omitempty"` // for stdio transport
Env map[string]string `json:"env,omitempty"` // for stdio transport
Timeout string `json:"timeout,omitempty"` // for HTTP、SSE transport (1s, 1m, 1h, 1d)
// For process transport - mapping data (tools, prompts, resources)
Tools map[string]string `json:"tools,omitempty"` // tool_name -> process_name mapping
Resources map[string]string `json:"resources,omitempty"` // resource_name -> process_name mapping
Prompts map[string]string `json:"prompts,omitempty"` // prompt_name -> process_name mapping
}
ClientDSL the MCP Client DSL
func (*ClientDSL) GetAuthorizationToken ¶
GetAuthorizationToken get the authorization token
func (*ClientDSL) GetClientCapabilities ¶
func (client *ClientDSL) GetClientCapabilities() ClientCapabilities
GetClientCapabilities get the default client capabilities
func (*ClientDSL) GetImplementation ¶
func (client *ClientDSL) GetImplementation() Implementation
GetImplementation get the implementation info
func (*ClientDSL) GetTimeout ¶
GetTimeout get the timeout
func (*ClientDSL) GetVersion ¶
GetVersion get the version, default to "1.0.0" if not set
type ClientInfo ¶
type ClientInfo struct {
ID string `json:"id,omitempty"` // Client ID
Name string `json:"name"` // Client name
Version string `json:"version,omitempty"` // Client version
Type string `json:"type,omitempty"` // Client type (standard, agent, system)
Transport TransportType `json:"transport,omitempty"` // Transport type
Label string `json:"label,omitempty"` // Display label
Description string `json:"description,omitempty"` // Description
Tags []string `json:"tags,omitempty"` // Tags for search and filtering
Dependencies map[string]string `json:"dependencies,omitempty"` // Dependencies (name -> version constraint)
}
Client and Server info
type Config ¶
type Config struct {
ServerCommand []string `json:"serverCommand,omitempty"`
ServerEnv map[string]string `json:"serverEnv,omitempty"`
InitOptions map[string]interface{} `json:"initOptions,omitempty"`
Timeout time.Duration `json:"timeout,omitempty"`
}
Configuration
type ConnectionOptions ¶
type ConnectionOptions struct {
// Headers for HTTP/SSE transports (e.g., Mcp-Session-Id, Custom-Auth, etc.)
Headers map[string]string `json:"headers,omitempty"`
// Timeout for connection establishment
Timeout time.Duration `json:"timeout,omitempty"`
// Retry configuration
MaxRetries int `json:"max_retries,omitempty"`
RetryDelay time.Duration `json:"retry_delay,omitempty"`
}
ConnectionOptions provides options for establishing connection
type ConnectionState ¶
type ConnectionState string
Connection state
const ( StateDisconnected ConnectionState = "disconnected" StateConnecting ConnectionState = "connecting" StateConnected ConnectionState = "connected" StateInitialized ConnectionState = "initialized" StateError ConnectionState = "error" )
type ElicitationCapability ¶
type ElicitationCapability struct{}
type EmbeddedResource ¶
type EmbeddedResource struct {
URI string `json:"uri"`
MimeType string `json:"mimeType"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"` // base64-encoded binary data
}
EmbeddedResource represents an embedded resource in prompt content
type Error ¶
type Error struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
Error represents a JSON-RPC error
type Event ¶
type Event struct {
Type string `json:"type"`
Data interface{} `json:"data"`
}
Event types
type GetPromptRequest ¶
type GetPromptResponse ¶
type GetPromptResponse struct {
Description string `json:"description,omitempty"`
Messages []PromptMessage `json:"messages"`
}
type Implementation ¶
Implementation describes the name and version of an MCP implementation
type InitializeRequest ¶
type InitializeRequest struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ClientCapabilities `json:"capabilities"`
ClientInfo ClientInfo `json:"clientInfo"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
Initialize request and response
type InitializeResponse ¶
type InitializeResponse struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
type ListPromptsRequest ¶
type ListPromptsRequest struct {
Cursor string `json:"cursor,omitempty"`
}
type ListPromptsResponse ¶
type ListResourcesRequest ¶
type ListResourcesRequest struct {
Cursor string `json:"cursor,omitempty"`
}
type ListResourcesResponse ¶
type ListSamplesResponse ¶
type ListSamplesResponse struct {
Samples []SampleData `json:"samples"`
Total int `json:"total"`
}
type ListToolsRequest ¶
type ListToolsRequest struct {
Cursor string `json:"cursor,omitempty"`
}
type ListToolsResponse ¶
type LogMessage ¶
type LoggingCapability ¶
type LoggingCapability struct{}
type MappingData ¶
type MappingData struct {
Tools map[string]*ToolSchema `json:"tools"` // tool_name -> ToolSchema
Resources map[string]*ResourceSchema `json:"resources"` // resource_name -> ResourceSchema
Prompts map[string]*PromptSchema `json:"prompts"` // prompt_name -> PromptSchema
}
MappingData contains all loaded schemas for a process-based MCP client
type Message ¶
type Message struct {
JSONRPC string `json:"jsonrpc"`
ID interface{} `json:"id,omitempty"`
Method string `json:"method,omitempty"`
Params interface{} `json:"params,omitempty"`
Result interface{} `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
}
Message JSON-RPC 2.0 message structure
type NotificationHandler ¶
type ProgressNotification ¶
type Prompt ¶
type Prompt struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Arguments []PromptArgument `json:"arguments,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
Prompt types
type PromptArgument ¶
type PromptContent ¶
type PromptContent struct {
Type PromptContentType `json:"type"`
// Text content
Text string `json:"text,omitempty"`
// Image content
Data string `json:"data,omitempty"` // base64-encoded data for image/audio
MimeType string `json:"mimeType,omitempty"` // MIME type for image/audio
// Resource content
Resource *EmbeddedResource `json:"resource,omitempty"`
}
type PromptContentType ¶
type PromptContentType string
PromptContentType represents the type of prompt content
const ( PromptContentTypeText PromptContentType = "text" PromptContentTypeImage PromptContentType = "image" PromptContentTypeAudio PromptContentType = "audio" PromptContentTypeResource PromptContentType = "resource" )
type PromptMessage ¶
type PromptMessage struct {
Role PromptRole `json:"role"`
Content PromptContent `json:"content"`
}
type PromptRole ¶
type PromptRole string
PromptRole represents the role of a prompt message
const ( PromptRoleUser PromptRole = "user" PromptRoleAssistant PromptRole = "assistant" )
type PromptSchema ¶
type PromptSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Template string `json:"template"` // Prompt template content
Arguments []PromptArgument `json:"arguments,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
PromptSchema represents a prompt template definition
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
type ReadResourceRequest ¶
type ReadResourceRequest struct {
URI string `json:"uri"`
}
type ReadResourceResponse ¶
type ReadResourceResponse struct {
Contents []ResourceContent `json:"contents"`
}
type RequestHandler ¶
Handler function types
type Resource ¶
type Resource struct {
URI string `json:"uri"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
Resource types
type ResourceContent ¶
type ResourceParameter ¶
type ResourceParameter struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Required bool `json:"required,omitempty"`
}
ResourceParameter defines a parameter for a resource URI
type ResourceSchema ¶
type ResourceSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Process string `json:"process"` // Yao process name
URI string `json:"uri"` // URI template (e.g., "customer://{id}")
MimeType string `json:"mimeType,omitempty"`
Parameters []ResourceParameter `json:"parameters,omitempty"` // URI parameters
Meta map[string]interface{} `json:"meta,omitempty"`
ProcessArgs []string `json:"x-process-args,omitempty"` // Mapping from URI/parameters to Process positional args
}
ResourceSchema represents a resource definition
type ResourceUpdatedNotification ¶
type ResourceUpdatedNotification struct {
URI string `json:"uri"`
}
type ResourcesCapability ¶
type RootsCapability ¶
type RootsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
type SampleData ¶
type SampleData struct {
Index int `json:"index"` // Auto-generated index (set by loader)
Name string `json:"name,omitempty"` // Optional sample name
ItemName string `json:"item_name,omitempty"` // Tool/Resource name (set by loader)
// Multi-purpose fields (semantics depend on item type)
Input map[string]interface{} `json:"input,omitempty"` // For tools: input args; For resources: parsed from URI
Output interface{} `json:"output,omitempty"` // For tools: expected output; Not used for resources
URI string `json:"uri,omitempty"` // For resources: full URI with params
Data interface{} `json:"data,omitempty"` // For resources: response data
Metadata map[string]interface{} `json:"metadata,omitempty"` // Optional metadata (e.g., description)
Timestamp string `json:"timestamp,omitempty"` // Optional timestamp
}
Sample types - for training/example data from .jsonl files
type SampleItemType ¶
type SampleItemType string
SampleItemType represents the type of item for samples
const ( SampleTool SampleItemType = "tool" SampleResource SampleItemType = "resource" )
Sample item types
type SamplingCapability ¶
type SamplingCapability struct{}
type SamplingContent ¶
type SamplingMessage ¶
type SamplingMessage struct {
Role string `json:"role"`
Content SamplingContent `json:"content"`
}
type SamplingRequest ¶
type SamplingRequest struct {
Model string `json:"model"`
Messages []SamplingMessage `json:"messages"`
SystemPrompt string `json:"systemPrompt,omitempty"`
IncludeContext string `json:"includeContext,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"maxTokens,omitempty"`
StopSequences []string `json:"stopSequences,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
Sampling types (LLM text generation - MCP protocol standard)
type SamplingResponse ¶
type SamplingResponse struct {
Model string `json:"model"`
Role string `json:"role"`
Content SamplingContent `json:"content"`
StopReason string `json:"stopReason,omitempty"`
}
type ServerCapabilities ¶
type ServerCapabilities struct {
Resources *ResourcesCapability `json:"resources,omitempty"`
Tools *ToolsCapability `json:"tools,omitempty"`
Prompts *PromptsCapability `json:"prompts,omitempty"`
Logging *LoggingCapability `json:"logging,omitempty"`
Experimental map[string]interface{} `json:"experimental,omitempty"`
}
type ServerInfo ¶
type SetLogLevelRequest ¶
type SetLogLevelRequest struct {
Level LogLevel `json:"level"`
}
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema json.RawMessage `json:"inputSchema"`
Meta map[string]interface{} `json:"meta,omitempty"`
}
Tool types
type ToolCall ¶
type ToolCall struct {
Name string `json:"name"`
Arguments interface{} `json:"arguments,omitempty"`
}
Batch tool call types
type ToolContent ¶
type ToolContent struct {
Type ToolContentType `json:"type"`
// Text content
Text string `json:"text,omitempty"`
// Image content (base64 encoded)
Data string `json:"data,omitempty"` // base64-encoded image data
MimeType string `json:"mimeType,omitempty"` // MIME type for image
// Resource content
Resource *EmbeddedResource `json:"resource,omitempty"`
}
type ToolContentType ¶
type ToolContentType string
ToolContentType represents the type of tool content
const ( ToolContentTypeText ToolContentType = "text" ToolContentTypeImage ToolContentType = "image" ToolContentTypeResource ToolContentType = "resource" )
type ToolSchema ¶
type ToolSchema struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Process string `json:"process"` // Yao process name
InputSchema json.RawMessage `json:"inputSchema"` // JSON Schema for input
OutputSchema json.RawMessage `json:"outputSchema,omitempty"` // Optional JSON Schema for output
ProcessArgs []string `json:"x-process-args,omitempty"` // Mapping from MCP arguments to Process positional args
}
ToolSchema represents a tool's input/output schema
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
type Transport ¶
type Transport interface {
Start(ctx context.Context) error
Stop() error
Send(message Message) error
Receive() (<-chan Message, error)
Close() error
}
Transport interface
type TransportType ¶
type TransportType string
TransportType the transport type
const ( // TransportHTTP the HTTP transport TransportHTTP TransportType = "http" // TransportSSE the SSE transport TransportSSE TransportType = "sse" // TransportStdio the Stdio transport TransportStdio TransportType = "stdio" // TransportProcess the Yao transport ( For Yao internal processes) TransportProcess TransportType = "process" )