mcpserver

package
v1.0.0-alpha.22 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mcpserver answers the Model Context Protocol over one connection, so an agent can ask what its run has cost while it works. Its four tools only read: the run's status file, the newest check run on a pull request, the policy over a rows file, and a ledger's view of a pull request. Every amount in an answer is a decimal string beside its currency.

Index

Constants

View Source
const (
	RunStatus   = "run_status"
	PullResult  = "pull_result"
	PolicyCheck = "policy_check"
	LedgerPull  = "ledger_pull"
)

The tools' names.

View Source
const Name = "costroid"

Name is the name the server gives itself when a client connects.

Variables

This section is empty.

Functions

func New

func New(options Options) *mcp.Server

New returns the server with its four tools.

func Serve

func Serve(ctx context.Context, options Options, in io.Reader, out io.Writer) error

Serve answers one client over in and out until the client closes in or ctx ends.

Types

type Ledger

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

Ledger is a costroid serve the person named when they started the server. The agent names a pull request, never the host, so the token goes nowhere else.

func NewLedger

func NewLedger(root, token, repository string) (*Ledger, error)

NewLedger checks the ledger's URL. It must be https, or http on a loopback address, because the token travels with every request.

func (*Ledger) Pull

func (l *Ledger) Pull(ctx context.Context, number int, repository string) (json.RawMessage, error)

Pull reads GET /v1/pulls/{number}?repo=repository. An empty repository is the ledger's own. The answer is returned as the ledger wrote it, once every amount in it is a string.

type Options

type Options struct {
	Version string
	// Getenv names the status file, as costroid run reads it.
	Getenv func(string) string
	// Result reads the newest result object on a pull request's head.
	Result func(ctx context.Context, number int) (history.Posted, error)
	// Policy gives the verdict costroid policy gives on the same request.
	Policy func(ctx context.Context, request PolicyRequest) (policy.Verdict, error)
	// Ledger is the costroid serve the person named, nil for none.
	Ledger *Ledger
}

Options are what the tools read through.

type PolicyRequest

type PolicyRequest struct {
	Rows          string `json:"rows" jsonschema:"the rows file costroid run wrote"`
	Config        string `` /* 127-byte string literal not displayed */
	WorkflowAdded string `` /* 146-byte string literal not displayed */
	At            string `json:"at,omitempty" jsonschema:"the time of the check, as RFC 3339; now when empty"`
}

PolicyRequest is costroid policy's flags, as policy_check takes them.

Jump to

Keyboard shortcuts

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