Documentation
¶
Index ¶
- Constants
- func SanitizeError(err error) string
- func SanitizeString(s string) string
- type Annotation
- type AnnotationType
- type Audience
- type ClientInfo
- type ContentBlock
- type ContentType
- type EmbeddedResource
- type InitializationResult
- type JSONRPCRequest
- type JSONRPCResponse
- type Priority
- type PromptsCapability
- type RPCError
- type RequestID
- type ResourceContents
- type ResourceLink
- type ResourcesCapability
- type Role
- type ServerCapabilities
- type ServerInfo
- type Tool
- type ToolCallResult
- type ToolsCapability
- type ToolsListResult
- type ValidationError
- type ValidationErrors
- type Validator
Constants ¶
const ( ErrorCodeParseError = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 )
Common JSON-RPC error codes
Variables ¶
This section is empty.
Functions ¶
func SanitizeError ¶
SanitizeError sanitizes error messages to prevent information disclosure
func SanitizeString ¶
SanitizeString sanitizes a string by removing/replacing dangerous characters
Types ¶
type Annotation ¶
type Annotation struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Audience string `json:"audience,omitempty"`
Priority string `json:"priority,omitempty"`
}
Annotation represents an annotation
func CreateAnnotation ¶
func CreateAnnotation(annoType AnnotationType, text string, audience Audience, priority Priority) Annotation
CreateAnnotation creates a new annotation
type AnnotationType ¶
type AnnotationType string
AnnotationType represents different annotation types
const ( AnnotationTypeInfo AnnotationType = "info" AnnotationTypeWarning AnnotationType = "warning" AnnotationTypeError AnnotationType = "error" )
type ClientInfo ¶
ClientInfo represents the client information
type ContentBlock ¶
type ContentBlock struct {
Type ContentType `json:"type"`
Text string `json:"text,omitempty"`
Data string `json:"data,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
ContentBlock represents a content block
func AudioContent ¶
func AudioContent(data, mimeType string) ContentBlock
AudioContent creates an audio content block
func ImageContent ¶
func ImageContent(data, mimeType string) ContentBlock
ImageContent creates an image content block
func TextContent ¶
func TextContent(text string) ContentBlock
TextContent creates a text content block
type ContentType ¶
type ContentType string
ContentType represents different content types
const ( ContentTypeText ContentType = "text" ContentTypeImage ContentType = "image" ContentTypeAudio ContentType = "audio" )
type EmbeddedResource ¶
type EmbeddedResource struct {
Type string `json:"type"`
Resource ResourceContents `json:"resource"`
}
EmbeddedResource represents an embedded resource
type InitializationResult ¶
type InitializationResult struct {
ProtocolVersion string `json:"protocolVersion"`
Capabilities ServerCapabilities `json:"capabilities"`
ServerInfo ServerInfo `json:"serverInfo"`
}
InitializationResult represents the initialization result
type JSONRPCRequest ¶
type JSONRPCRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params map[string]interface{} `json:"params,omitempty"`
ID RequestID `json:"id"`
}
JSONRPCRequest represents a JSON-RPC 2.0 request
type JSONRPCResponse ¶
type JSONRPCResponse struct {
JSONRPC string `json:"jsonrpc"`
Result interface{} `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
ID RequestID `json:"id"`
}
JSONRPCResponse represents a JSON-RPC 2.0 response
type PromptsCapability ¶
type PromptsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
PromptsCapability represents prompts capability
type RPCError ¶
type RPCError struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
RPCError represents a JSON-RPC 2.0 error
type RequestID ¶
type RequestID struct {
Value interface{}
}
RequestID can be either a string or a number
func (RequestID) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (*RequestID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler
type ResourceContents ¶
type ResourceContents struct {
URI string `json:"uri"`
MimeType string `json:"mimeType,omitempty"`
Text string `json:"text,omitempty"`
Blob string `json:"blob,omitempty"`
}
ResourceContents represents resource contents
type ResourceLink ¶
type ResourceLink struct {
URI string `json:"uri"`
Description string `json:"description,omitempty"`
}
ResourceLink represents a resource link
type ResourcesCapability ¶
type ResourcesCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ResourcesCapability represents resources capability
type ServerCapabilities ¶
type ServerCapabilities struct {
Tools *ToolsCapability `json:"tools,omitempty"`
Prompts *PromptsCapability `json:"prompts,omitempty"`
Resources *ResourcesCapability `json:"resources,omitempty"`
}
ServerCapabilities represents server capabilities
type ServerInfo ¶
ServerInfo represents the server information
type Tool ¶
type Tool struct {
Name string `json:"name"`
Description string `json:"description"`
InputSchema interface{} `json:"inputSchema"`
OutputSchema interface{} `json:"outputSchema,omitempty"`
}
Tool represents an MCP tool
type ToolCallResult ¶
type ToolCallResult struct {
Content []ContentBlock `json:"content"`
IsError bool `json:"isError,omitempty"`
}
ToolCallResult represents the result of a tool call
type ToolsCapability ¶
type ToolsCapability struct {
ListChanged bool `json:"listChanged,omitempty"`
}
ToolsCapability represents tools capability
type ToolsListResult ¶
type ToolsListResult struct {
Tools []Tool `json:"tools"`
}
ToolsListResult represents the result of listing tools
type ValidationError ¶
ValidationError represents a validation error
func (ValidationError) Error ¶
func (e ValidationError) Error() string
Error implements the error interface
type ValidationErrors ¶
type ValidationErrors []ValidationError
ValidationErrors represents multiple validation errors
func (*ValidationErrors) Add ¶
func (e *ValidationErrors) Add(field, message string)
Add adds a validation error
func (ValidationErrors) Error ¶
func (e ValidationErrors) Error() string
Error implements the error interface
func (ValidationErrors) HasErrors ¶
func (e ValidationErrors) HasErrors() bool
HasErrors returns true if there are validation errors
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator provides validation functionality
func NewValidator ¶
func NewValidator() *Validator
NewValidator creates a new validator with default settings
func (*Validator) ValidateRequest ¶
func (v *Validator) ValidateRequest(req *JSONRPCRequest) error
ValidateRequest validates a JSON-RPC request
func (*Validator) ValidateTool ¶
ValidateTool validates a tool definition
func (*Validator) ValidateToolCallParams ¶
ValidateToolCallParams validates tool call parameters