jsonrpc

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfoObj

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

ClientInfoObj defines the client information

type ContentItem

type ContentItem struct {
	Type     string      `json:"type"`
	Text     interface{} `json:"text,omitempty"`
	URL      string      `json:"url,omitempty"`
	AltText  string      `json:"altText,omitempty"`
	Code     string      `json:"code,omitempty"`
	Language string      `json:"language,omitempty"`
	Headers  []string    `json:"headers,omitempty"`
	Rows     [][]string  `json:"rows,omitempty"`
}

ContentItem defines a content item in a resource

type InitializeParams

type InitializeParams struct {
	ClientInfo ClientInfoObj `json:"clientInfo"`
	Versions   []string      `json:"versions"`
}

InitializeParams defines the parameters for an initialize request

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string                 `json:"protocolVersion"`
	ServerInfo      ServerInfoObj          `json:"serverInfo"`
	Capabilities    map[string]interface{} `json:"capabilities"`
}

InitializeResult defines the result of an initialize request

type JSONRPC

type JSONRPC struct {
	Version string      `json:"jsonrpc"`
	ID      interface{} `json:"id,omitempty"`
	Method  string      `json:"method,omitempty"`
	Params  interface{} `json:"params,omitempty"`
	Result  interface{} `json:"result,omitempty"`
	Error   *RPCError   `json:"error,omitempty"`
}

JSONRPC defines the basic structure of a JSON-RPC message

func NewEmptyResponse

func NewEmptyResponse(id interface{}) *JSONRPC

NewEmptyResponse creates an empty success response

func NewErrorResponse

func NewErrorResponse(id interface{}, code int, message string, data interface{}) *JSONRPC

NewErrorResponse creates an error response

func NewInitializeRequest

func NewInitializeRequest(id interface{}, clientName, clientVersion string, supportedVersions []string) *JSONRPC

NewInitializeRequest creates an initialize request

func NewNotificationRequest

func NewNotificationRequest(method string, params interface{}) *JSONRPC

NewNotificationRequest creates a notification (no ID) with the given method and params

func NewPromptRequest

func NewPromptRequest(id interface{}, name string, variables map[string]interface{}) *JSONRPC

NewPromptRequest creates a prompt request with the given name and variables

func NewPromptResponse

func NewPromptResponse(id interface{}, prompt, rendered string, metadata map[string]interface{}) *JSONRPC

NewPromptResponse creates a response for a prompt

func NewResourceRequest

func NewResourceRequest(id interface{}, path string) *JSONRPC

NewResourceRequest creates a resource request for the given path

func NewResourceRequestWithOptions

func NewResourceRequestWithOptions(id interface{}, path string, options map[string]interface{}) *JSONRPC

NewResourceRequestWithOptions creates a resource request with additional options

func NewRootAddRequest

func NewRootAddRequest(id interface{}, path, name string) *JSONRPC

NewRootAddRequest creates a request to add a root

func NewRootListRequest

func NewRootListRequest(id interface{}) *JSONRPC

NewRootListRequest creates a request to list roots

func NewRootRemoveRequest

func NewRootRemoveRequest(id interface{}, path string) *JSONRPC

NewRootRemoveRequest creates a request to remove a root

func NewRootsListResponse

func NewRootsListResponse(id interface{}, roots []RootItem) *JSONRPC

NewRootsListResponse creates a response for a roots/list request

func NewSamplingAudioResponse

func NewSamplingAudioResponse(id interface{}, data string, mimeType string, model string, stopReason string) *JSONRPC

NewSamplingAudioResponse creates an audio response for a sampling/createMessage request

func NewSamplingCreateMessageRequest

func NewSamplingCreateMessageRequest(id interface{}, params SamplingCreateMessageParams) *JSONRPC

NewSamplingCreateMessageRequest creates a sampling/createMessage request

func NewSamplingImageResponse

func NewSamplingImageResponse(id interface{}, data string, mimeType string, model string, stopReason string) *JSONRPC

NewSamplingImageResponse creates an image response for a sampling/createMessage request

func NewSamplingResponse

func NewSamplingResponse(id interface{}, role string, content SamplingMessageContent, model string, stopReason string) *JSONRPC

NewSamplingResponse creates a response for a sampling/createMessage request

func NewSamplingStreamingChunkResponse

func NewSamplingStreamingChunkResponse(id interface{}, chunkID string, role string, content SamplingMessageContent) *JSONRPC

NewSamplingStreamingChunkResponse creates a streaming chunk response

func NewSamplingStreamingCompletionResponse

func NewSamplingStreamingCompletionResponse(id interface{}, model string, stopReason string) *JSONRPC

NewSamplingStreamingCompletionResponse creates a streaming completion response

func NewSamplingStreamingResponse

func NewSamplingStreamingResponse(id interface{}, chunk *SamplingStreamingChunk, completion *SamplingStreamingCompletion) *JSONRPC

NewSamplingStreamingResponse creates a streaming response for a sampling/createStreamingMessage request

func NewSamplingStreamingTextChunk

func NewSamplingStreamingTextChunk(id interface{}, chunkID string, text string) *JSONRPC

NewSamplingStreamingTextChunk creates a streaming text chunk response

func NewSamplingTextResponse

func NewSamplingTextResponse(id interface{}, text string, model string, stopReason string) *JSONRPC

NewSamplingTextResponse creates a text response for a sampling/createMessage request

func NewToolRequest

func NewToolRequest(id interface{}, name string, args map[string]interface{}) *JSONRPC

NewToolRequest creates a tool request with the given name and arguments

func NewToolResponse

func NewToolResponse(id interface{}, output interface{}, metadata map[string]interface{}) *JSONRPC

NewToolResponse creates a response for a tool execution

type PromptParams

type PromptParams struct {
	Name      string                 `json:"name"`
	Variables map[string]interface{} `json:"variables"`
}

PromptParams defines parameters for prompt retrieval

type PromptResult

type PromptResult struct {
	Prompt   string                 `json:"prompt"`
	Rendered string                 `json:"rendered"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

PromptResult defines the result of a prompt retrieval

type RPCError

type RPCError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

RPCError defines the structure of a JSON-RPC error

type ResourceItem

type ResourceItem struct {
	URI      string                 `json:"uri"`
	Text     string                 `json:"text"`
	Content  []ContentItem          `json:"content"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

ResourceItem defines a single resource in a resource response

type ResourceParams

type ResourceParams struct {
	Path    string                 `json:"path"`
	Options map[string]interface{} `json:"options,omitempty"`
}

ResourceParams defines parameters for resource retrieval

type ResourceResult20241105

type ResourceResult20241105 struct {
	Content []ContentItem `json:"content"`
}

ResourceResult20241105 defines the result of a resource retrieval for v20241105

type ResourceResult20250326

type ResourceResult20250326 struct {
	Contents []ResourceItem `json:"contents"`
}

ResourceResult20250326 defines the result of a resource retrieval for v20250326

type RootAddParams

type RootAddParams struct {
	Path string `json:"path"`
	Name string `json:"name"`
}

RootAddParams defines parameters for adding a root

type RootItem

type RootItem struct {
	URI      string                 `json:"uri"`
	Name     string                 `json:"name"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

RootItem defines a root resource

type RootRemoveParams

type RootRemoveParams struct {
	Path string `json:"path"`
}

RootRemoveParams defines parameters for removing a root

type RootsListResult

type RootsListResult struct {
	Roots []RootItem `json:"roots"`
}

RootsListResult defines the result of a roots/list request

type SamplingCreateMessageParams

type SamplingCreateMessageParams struct {
	Messages         []SamplingMessage        `json:"messages"`
	ModelPreferences SamplingModelPreferences `json:"modelPreferences"`
	SystemPrompt     string                   `json:"systemPrompt,omitempty"`
	MaxTokens        int                      `json:"maxTokens,omitempty"`
}

SamplingCreateMessageParams represents the parameters for a sampling/createMessage request

func NewSamplingCreateMessageParams

func NewSamplingCreateMessageParams(messages []SamplingMessage, modelPreferences SamplingModelPreferences) SamplingCreateMessageParams

NewSamplingCreateMessageParams creates parameters for a sampling/createMessage request

type SamplingMessage

type SamplingMessage struct {
	Role    string                 `json:"role"`
	Content SamplingMessageContent `json:"content"`
}

SamplingMessage represents a message in a sampling conversation

type SamplingMessageContent

type SamplingMessageContent struct {
	Type     string `json:"type"`
	Text     string `json:"text,omitempty"`
	Data     string `json:"data,omitempty"`
	MimeType string `json:"mimeType,omitempty"`
}

SamplingMessageContent represents the content of a sampling message

type SamplingModelHint

type SamplingModelHint struct {
	Name string `json:"name"`
}

SamplingModelHint represents a hint for model selection

type SamplingModelPreferences

type SamplingModelPreferences struct {
	Hints                []SamplingModelHint `json:"hints,omitempty"`
	CostPriority         *float64            `json:"costPriority,omitempty"`
	SpeedPriority        *float64            `json:"speedPriority,omitempty"`
	IntelligencePriority *float64            `json:"intelligencePriority,omitempty"`
}

SamplingModelPreferences represents model preferences for a sampling request

type SamplingResponse

type SamplingResponse struct {
	Role       string                 `json:"role"`
	Content    SamplingMessageContent `json:"content"`
	Model      string                 `json:"model,omitempty"`
	StopReason string                 `json:"stopReason,omitempty"`
}

SamplingResponse represents the response to a sampling/createMessage request

type SamplingStreamingChunk

type SamplingStreamingChunk struct {
	ChunkID string                 `json:"chunkId"`
	Role    string                 `json:"role,omitempty"`
	Content SamplingMessageContent `json:"content"`
}

SamplingStreamingChunk represents a chunk of a streaming response

type SamplingStreamingCompletion

type SamplingStreamingCompletion struct {
	Model      string `json:"model,omitempty"`
	StopReason string `json:"stopReason,omitempty"`
}

SamplingStreamingCompletion represents the completion of a streaming response

type SamplingStreamingResponse

type SamplingStreamingResponse struct {
	Chunk      *SamplingStreamingChunk      `json:"chunk,omitempty"`
	Completion *SamplingStreamingCompletion `json:"completion,omitempty"`
}

SamplingStreamingResponse represents a streaming response to a sampling request

type ServerInfoObj

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

ServerInfoObj defines the server information

type ToolParams

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

ToolParams defines parameters for tool execution

type ToolResult

type ToolResult struct {
	Output   interface{}            `json:"output"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

ToolResult defines the result of a tool execution

Jump to

Keyboard shortcuts

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