mcp

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONRPCNotification

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

JSONRPCNotification represents an outgoing JSON-RPC 2.0 notification (no id).

type JSONRPCRequest

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

JSONRPCRequest represents an incoming JSON-RPC 2.0 request.

type JSONRPCResponse

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

JSONRPCResponse represents an outgoing JSON-RPC 2.0 response.

type RPCError

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

RPCError represents a JSON-RPC 2.0 error object.

type Server

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

Server is a stdio-based MCP server that bridges JSON-RPC messages to the engine.

func NewServer

func NewServer(eng *engine.Engine, logger *slog.Logger) *Server

NewServer creates a new MCP server with the given engine.

func (*Server) Run

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

Run starts the server, reading from stdin and writing to stdout. It blocks until the input stream is closed or the context is cancelled.

type ToolDef

type ToolDef struct {
	Name        string
	Description string
	InputSchema map[string]any
	Handler     ToolHandler
}

ToolDef describes a single MCP tool.

type ToolHandler

type ToolHandler func(ctx context.Context, args json.RawMessage) (string, error)

ToolHandler processes a tool call and returns a text result or an error.

Jump to

Keyboard shortcuts

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