mcp

package
v0.9.5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package mcp implements a minimal Model Context Protocol server: JSON-RPC 2.0 framed as one message per line over stdio. It knows nothing about Envault — callers register Tools whose handlers do the real work.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ObjectSchema

func ObjectSchema(properties map[string]Property, required []string) json.RawMessage

ObjectSchema builds a JSON Schema object (type: "object") from the given properties and required field names. Passing nil properties yields a schema for a tool that takes no arguments.

Types

type Property

type Property struct {
	Type        string // "string", "array", ...
	Items       string // element type, only used when Type == "array"
	Description string
}

Property describes one field of a tool's input JSON Schema.

type Server

type Server struct {
	Name    string
	Version string
	Tools   []Tool
}

Server dispatches JSON-RPC requests read from stdio to registered Tools.

func (*Server) PrintSchemas

func (s *Server) PrintSchemas(w io.Writer) error

PrintSchemas writes the JSON Schema of every registered tool to w, pretty printed as a single JSON array. Used by `envault mcp serve --dry-run` for debugging and for generating the plugin manifest's tool documentation.

func (*Server) Serve

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

Serve reads newline-delimited JSON-RPC requests from r and writes responses to w until r is exhausted or returns an error. Notifications (requests with no id) never produce a response, per JSON-RPC 2.0.

type Tool

type Tool struct {
	Name        string
	Description string
	InputSchema json.RawMessage
	Handler     func(arguments json.RawMessage) (interface{}, error)
}

Tool is a single MCP tool: its JSON Schema contract and the function that executes it. Handler receives the raw "arguments" object from the tools/call request and returns a JSON-serializable result or an error.

Jump to

Keyboard shortcuts

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