mcpproto

package
v0.0.0-...-e3ccff7 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadFrame

func ReadFrame(r *bufio.Reader) ([]byte, error)

func WriteFrame

func WriteFrame(w io.Writer, resp Response) error

Types

type ErrorBody

type ErrorBody struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Provider

type Provider interface {
	Tools(ctx context.Context) []Tool
	CallTool(ctx context.Context, name string, args map[string]any) ToolResult
}

type ProviderFunc

type ProviderFunc struct {
	ToolsFn    func(ctx context.Context) []Tool
	CallToolFn func(ctx context.Context, name string, args map[string]any) ToolResult
}

func (ProviderFunc) CallTool

func (p ProviderFunc) CallTool(ctx context.Context, name string, args map[string]any) ToolResult

func (ProviderFunc) Tools

func (p ProviderFunc) Tools(ctx context.Context) []Tool

type Request

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

type Response

type Response struct {
	JSONRPC string     `json:"jsonrpc"`
	ID      any        `json:"id,omitempty"`
	Result  any        `json:"result,omitempty"`
	Error   *ErrorBody `json:"error,omitempty"`
}

type Server

type Server struct {
	ProtocolVersion string
	Name            string
	Version         string
	Instructions    string
	Provider        Provider
}

func (*Server) HandleRequest

func (s *Server) HandleRequest(ctx context.Context, req Request) *Response

func (*Server) Serve

func (s *Server) Serve(ctx context.Context, r io.Reader, w io.Writer) error

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type TextContent

type TextContent struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

type Tool

type Tool struct {
	Name        string         `json:"name"`
	Description string         `json:"description"`
	InputSchema map[string]any `json:"inputSchema"`
}

type ToolCallParams

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

type ToolResult

type ToolResult struct {
	Content           []TextContent `json:"content"`
	StructuredContent any           `json:"structuredContent,omitempty"`
	IsError           bool          `json:"isError,omitempty"`
}

func StructuredResult

func StructuredResult(value any) ToolResult

Jump to

Keyboard shortcuts

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