mcp

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mcp is a minimal Model Context Protocol server over stdio: enough of the protocol (initialize, ping, tools/list, tools/call as newline-delimited JSON-RPC 2.0) for an agent to call notenv's tools, and nothing more. Hand-rolled deliberately: like internal/ui, it adds zero new supply-chain surface, which matters more than protocol breadth while the server is a prototype.

Requests are handled sequentially in arrival order; there is no cancellation and no server-initiated traffic. Handlers' results travel as text content. The transport's stdin/stdout belong to the protocol; prompts and logging elsewhere in notenv already go to /dev/tty and stderr, so a handler can run the full app stack without corrupting the stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server serves a fixed tool set over one stdio session.

func (*Server) Serve

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

Serve runs the session until in closes (the client hanging up) or ctx is canceled between messages. Malformed lines get a parse error where an ID is recoverable and are dropped otherwise; unknown notifications are ignored, per JSON-RPC.

type Tool

type Tool struct {
	Name        string
	Description string
	InputSchema map[string]any
	Handler     func(ctx context.Context, args json.RawMessage) (string, error)
}

Tool is one callable tool: a name, the description an agent picks it by, a JSON-Schema input declaration, and the handler. A handler error becomes a tool-level error result (isError), not a protocol error: the agent gets to read it and adapt.

Jump to

Keyboard shortcuts

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