mcp

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mcp serves the platform over the Model Context Protocol.

It is a presentation layer and nothing else, in the same sense that the cobra command tree and an HTTP handler are: it translates one wire protocol into calls on pkg/leaflow and translates the answers back. What an operation is, what it accepts, whether an argument is valid, where the request goes — none of that is decided here, so a tool cannot drift from a command.

The one thing this layer does decide is shape, and it is the reason MCP is worth having over the command line: a tool call is already JSON. A shell spends real effort flattening a request body into one flag per field; here the contract's schema is handed to the client as it stands, nesting intact, under the contract's own names.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownMode = errors.New("unknown tool mode")

Functions

This section is empty.

Types

type Mode

type Mode string

Mode decides how the two hundred operations are presented.

This is the one question this surface has that a command line does not. A shell can hold every command because nobody reads them all; a model is sent the whole tool list on every turn, and a list that large crowds out the conversation it is meant to serve.

const (
	// ModeMeta exposes four fixed tools and lets the client walk the contracts
	// through them. Context cost does not grow with the platform.
	ModeMeta Mode = "meta"

	// ModeOperations exposes one tool per operation, which is what clients are
	// built for — names complete, schemas visible without a call — and is usable
	// once Services narrows it to a service or two.
	ModeOperations Mode = "operations"
)

type Options

type Options struct {
	// Client is the platform. Its credentials, services and read-only setting
	// are already decided; this server does not second-guess any of them.
	Client *leaflow.Client

	// Version is reported to the client as the server's.
	Version string

	Mode Mode
}

Options is one server's configuration.

type Server

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

func New

func New(opts Options) (*Server, error)

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler serves the same server over HTTP.

One sdk.Server backs every session rather than one per request: the tools come from contracts that do not change while the process runs.

func (*Server) Run

func (s *Server) Run(ctx context.Context, in io.Reader, out io.Writer) error

Run serves one client over the given streams, which in practice are stdin and stdout.

Nothing else may write to out while this runs: the stream is the protocol. Everything that would normally be printed goes to stderr, which the client shows in its logs.

func (*Server) Tools

func (s *Server) Tools() int

Tools reports how many this server will advertise, so whoever starts it can say so before it goes quiet.

Jump to

Keyboard shortcuts

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