proto

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package proto defines JSON-RPC 2.0 message types and MCP protocol constants for the ctx MCP server.

Index

Constants

View Source
const (
	ErrCodeParse = -32700

	ErrCodeNotFound   = -32601
	ErrCodeInvalidArg = -32602
	ErrCodeInternal   = -32603
)

Standard JSON-RPC error codes.

View Source
const ProtocolVersion = "2024-11-05"

ProtocolVersion is the MCP protocol version.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInfo

type AppInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

AppInfo identifies a client or server application.

type CallToolParams

type CallToolParams struct {
	Name      string                 `json:"name"`
	Arguments map[string]interface{} `json:"arguments,omitempty"`
}

CallToolParams is sent with tools/call.

type CallToolResult

type CallToolResult struct {
	Content []ToolContent `json:"content"`
	IsError bool          `json:"isError,omitempty"`
}

CallToolResult is returned by tools/call.

type ClientCaps

type ClientCaps struct {
	Roots    *struct{} `json:"roots,omitempty"`
	Sampling *struct{} `json:"sampling,omitempty"`
}

ClientCaps describes client capabilities.

type GetPromptParams

type GetPromptParams struct {
	Name      string            `json:"name"`
	Arguments map[string]string `json:"arguments,omitempty"`
}

GetPromptParams is sent with prompts/get.

type GetPromptResult

type GetPromptResult struct {
	Description string          `json:"description,omitempty"`
	Messages    []PromptMessage `json:"messages"`
}

GetPromptResult is returned by prompts/get.

type InitializeParams

type InitializeParams struct {
	ProtocolVersion string     `json:"protocolVersion"`
	Capabilities    ClientCaps `json:"capabilities"`
	ClientInfo      AppInfo    `json:"clientInfo"`
}

InitializeParams contains client information sent during initialization.

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string     `json:"protocolVersion"`
	Capabilities    ServerCaps `json:"capabilities"`
	ServerInfo      AppInfo    `json:"serverInfo"`
}

InitializeResult is the server's response to initialize.

type InputSchema

type InputSchema struct {
	Type       string              `json:"type"`
	Properties map[string]Property `json:"properties,omitempty"`
	Required   []string            `json:"required,omitempty"`
}

InputSchema describes the JSON Schema for tool inputs.

type Notification

type Notification struct {
	JSONRPC string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params,omitempty"`
}

Notification represents a JSON-RPC 2.0 notification (no id).

type Prompt

type Prompt struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
}

Prompt describes a single MCP prompt template.

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required,omitempty"`
}

PromptArgument describes a single argument for a prompt.

type PromptListResult

type PromptListResult struct {
	Prompts []Prompt `json:"prompts"`
}

PromptListResult is returned by prompts/list.

type PromptMessage

type PromptMessage struct {
	Role    string      `json:"role"`
	Content ToolContent `json:"content"`
}

PromptMessage represents a message in a prompt response.

type PromptsCap

type PromptsCap struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

PromptsCap indicates the server supports prompts.

type Property

type Property struct {
	Type        string   `json:"type"`
	Description string   `json:"description,omitempty"`
	Enum        []string `json:"enum,omitempty"`
}

Property describes a single property in a JSON Schema.

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 object.

type ReadResourceParams

type ReadResourceParams struct {
	URI string `json:"uri"`
}

ReadResourceParams is sent with resources/read.

type ReadResourceResult

type ReadResourceResult struct {
	Contents []ResourceContent `json:"contents"`
}

ReadResourceResult is returned by resources/read.

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request represents a JSON-RPC 2.0 request message.

type Resource

type Resource struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

Resource describes a single MCP resource.

type ResourceContent

type ResourceContent struct {
	URI      string `json:"uri"`
	MimeType string `json:"mimeType,omitempty"`
	Text     string `json:"text,omitempty"`
}

ResourceContent represents the content of a resource.

type ResourceListResult

type ResourceListResult struct {
	Resources []Resource `json:"resources"`
}

ResourceListResult is returned by resources/list.

type ResourceUpdatedParams

type ResourceUpdatedParams struct {
	URI string `json:"uri"`
}

ResourceUpdatedParams is sent with notifications/resources/updated.

type ResourcesCap

type ResourcesCap struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourcesCap indicates the server supports resources.

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id,omitempty"`
	Result  interface{}     `json:"result,omitempty"`
	Error   *RPCError       `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response message.

type ServerCaps

type ServerCaps struct {
	Resources *ResourcesCap `json:"resources,omitempty"`
	Tools     *ToolsCap     `json:"tools,omitempty"`
	Prompts   *PromptsCap   `json:"prompts,omitempty"`
}

ServerCaps describes server capabilities.

type SubscribeParams

type SubscribeParams struct {
	URI string `json:"uri"`
}

SubscribeParams is sent with resources/subscribe.

type Tool

type Tool struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	InputSchema InputSchema      `json:"inputSchema"`
	Annotations *ToolAnnotations `json:"annotations,omitempty"`
}

Tool describes a single MCP tool.

type ToolAnnotations

type ToolAnnotations struct {
	ReadOnlyHint    bool `json:"readOnlyHint,omitempty"`
	DestructiveHint bool `json:"destructiveHint,omitempty"`
	IdempotentHint  bool `json:"idempotentHint,omitempty"`
}

ToolAnnotations provides hints about a tool's behavior.

type ToolContent

type ToolContent struct {
	Type string `json:"type"`
	Text string `json:"text,omitempty"`
}

ToolContent represents a piece of tool output.

type ToolListResult

type ToolListResult struct {
	Tools []Tool `json:"tools"`
}

ToolListResult is returned by tools/list.

type ToolsCap

type ToolsCap struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolsCap indicates the server supports tools.

type UnsubscribeParams

type UnsubscribeParams struct {
	URI string `json:"uri"`
}

UnsubscribeParams is sent with resources/unsubscribe.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL