mcp

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capability

type Capability struct {
	Name        string      `json:"name"`
	Type        string      `json:"type"` // tool, resource, or prompt
	Description string      `json:"description"`
	Schema      interface{} `json:"schema,omitempty"`
}

Capability represents a server capability

type CapabilityRegistry

type CapabilityRegistry struct {
	// contains filtered or unexported fields
}

CapabilityRegistry manages server capabilities

func NewCapabilityRegistry

func NewCapabilityRegistry() *CapabilityRegistry

NewCapabilityRegistry creates a new capability registry

func (*CapabilityRegistry) GetCapabilities

func (r *CapabilityRegistry) GetCapabilities() []Capability

GetCapabilities returns all registered capabilities

func (*CapabilityRegistry) HandleCapabilityRequest

func (r *CapabilityRegistry) HandleCapabilityRequest(msg *JSONRPCMessage) *JSONRPCMessage

HandleCapabilityRequest processes a capability request

func (*CapabilityRegistry) RegisterPrompt

func (r *CapabilityRegistry) RegisterPrompt(name string, content string) error

RegisterPrompt registers a new prompt capability

func (*CapabilityRegistry) RegisterResource

func (r *CapabilityRegistry) RegisterResource(name string, handler ResourceHandler) error

RegisterResource registers a new resource capability

func (*CapabilityRegistry) RegisterTool

func (r *CapabilityRegistry) RegisterTool(name string, handler ToolHandler, schema interface{}) error

RegisterTool registers a new tool capability

type JSONRPCError

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

JSONRPCError represents a JSON-RPC 2.0 error

type JSONRPCMessage

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

JSONRPCMessage represents a JSON-RPC 2.0 message

type ResourceHandler

type ResourceHandler func() (interface{}, error)

ResourceHandler provides resource content

type STDIOTransport

type STDIOTransport struct {
	// contains filtered or unexported fields
}

STDIOTransport handles STDIO-based JSON-RPC communication

func NewSTDIOTransport

func NewSTDIOTransport() *STDIOTransport

NewSTDIOTransport creates a new STDIO transport

func (*STDIOTransport) HandleMessages

func (t *STDIOTransport) HandleMessages(ctx context.Context, handler func(*JSONRPCMessage) *JSONRPCMessage) error

HandleMessages processes incoming messages until context is canceled

func (*STDIOTransport) ReadMessage

func (t *STDIOTransport) ReadMessage() (*JSONRPCMessage, error)

ReadMessage reads a JSON-RPC message from STDIN

func (*STDIOTransport) WriteMessage

func (t *STDIOTransport) WriteMessage(msg *JSONRPCMessage) error

WriteMessage writes a JSON-RPC message to STDOUT

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements the MCP server

func NewServer

func NewServer(manager *db.Manager) (*Server, error)

NewServer creates a new MCP server instance

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the MCP server

type ToolHandler

type ToolHandler func(params json.RawMessage) (interface{}, error)

ToolHandler handles tool invocations

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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