mcp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package mcp serves the agent surface of an application over stdio, S16.

`avero mcp` speaks the Model Context Protocol: JSON-RPC 2.0 over the standard input and the standard output. The server holds seven tools. Every tool except scaffold_slice reads and writes nothing, and the server never runs a command that a caller names. It runs the fixed steps of the gate and the inspection of the application, and nothing else.

Index

Constants

View Source
const (
	// KindCompile is a fault of the Go compiler or of go vet.
	KindCompile = "compile"
	// KindAvero is a fault that Avero printed, with its repair.
	KindAvero = "avero"
	// KindUnknown is a line that names no position.
	KindUnknown = "unknown"
)

The kinds of fault.

View Source
const (
	// ProtocolVersion is the version of the Model Context Protocol.
	ProtocolVersion = "2025-06-18"
	// ServerName names the server in the handshake.
	ServerName = "avero"
	// JSONRPCVersion is the version of the transport.
	JSONRPCVersion = "2.0"
)

The protocol that the server speaks.

View Source
const SchemaID = "https://avero.dev/schema/mcp-results/v1"

SchemaID names the schema of the tool results. See mcp/schema.json.

Variables

View Source
var Schema []byte

Schema holds mcp/schema.json. The structured result of each tool follows the definition of its name. See AN-3.

View Source
var Version = "dev"

Version is the version of the server. The release build sets it.

Functions

func Explain

func Explain(dir, message string) map[string]any

Explain maps a build fault or a run-time fault to the position in the code of the person and to the repair.

A fault that a generated file raised maps back to the input type that the person wrote, because an error must never point into generated code. See DX-6.

Types

type Fault

type Fault struct {
	// Kind is compile, avero or unknown.
	Kind string `json:"kind"`
	// File names the file of the fault.
	File string `json:"file"`
	// Line names the line of the fault.
	Line int `json:"line"`
	// Column names the column of the fault.
	Column int `json:"column"`
	// Message states the fault.
	Message string `json:"message"`
	// Repair states what to do. It is one sentence.
	Repair string `json:"repair"`
	// Generated reports a fault that a generated file raised.
	Generated bool `json:"generated"`
	// SourceFile names the file that the person wrote, for a fault of a
	// generated file. See DX-6.
	SourceFile string `json:"source_file"`
	// SourceLine names the line that the person wrote.
	SourceLine int `json:"source_line"`
}

Fault is one fault that explain_error found.

type Server

type Server struct {
	// Dir is the root of the application.
	Dir string
	// Slice writes one feature slice. scaffold_slice calls it, and the CLI
	// supplies the same function that `avero slice` runs.
	Slice func(dir, name string) (files []string, registered bool, err error)
	// Generate proves that every generated file of the application is
	// current. The gate step of run_verify calls it.
	Generate func(dir string) error
}

Server answers the Model Context Protocol for one application.

The two functions are fields, because the scaffolder and the generators live in packages that this one does not import. `avero mcp` supplies them. See design rule 3.

func (*Server) Serve

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

Serve reads requests from in and writes answers to out. It returns when the caller closes the input or cancels the context.

Each line holds one JSON document, which is the line form of the transport.

type Tool

type Tool struct {
	// Name is the name that a caller sends.
	Name string `json:"name"`
	// Description states what the tool returns, in one line.
	Description string `json:"description"`
	// InputSchema states the arguments of the tool.
	InputSchema map[string]any `json:"inputSchema"`
	// contains filtered or unexported fields
}

Tool is one tool of the server.

func Tools

func Tools() []Tool

Tools returns every tool, in name order. See AN-4.

Jump to

Keyboard shortcuts

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