mcp

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package mcp exposes Console over the Model Context Protocol (MCP), so an AI agent (Claude Desktop, Claude Code, or any MCP client) can operate a Console instance as a set of tools: list and evaluate feature flags, read component health, and — when writes are enabled — create, toggle, and delete flags and components.

MCP is a consumer surface, like the CLI and the dashboard — not one of Console's plugin seams (store/status/notify/llm). The server talks to Console through a Backend, which has two implementations: an in-process one over the flags/status engines (the default), and an HTTP one that targets a running `console serve` (selected with -addr). Handlers are written against Backend so they are identical in either mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewServer

func NewServer(b Backend, opts Options) *mcp.Server

NewServer builds an MCP server over the given Backend. Read and flag-evaluation tools are always registered; mutating tools are registered only when opts.AllowWrites is true. Two resources (console://health, console://flags) and an "onboard" prompt are always available.

func Run

func Run(ctx context.Context, b Backend, opts Options) error

Run builds the server and serves it over stdio until ctx is cancelled or the client disconnects.

Types

type Backend

type Backend interface {
	// Flags.
	ListFlags(ctx context.Context) ([]core.Flag, error)
	GetFlag(ctx context.Context, key string) (core.Flag, error)
	CreateFlag(ctx context.Context, f core.Flag) error
	UpdateFlag(ctx context.Context, f core.Flag) error
	DeleteFlag(ctx context.Context, key string) error
	EvaluateFlag(ctx context.Context, key string, subj core.Subject) (core.Evaluation, error)

	// Components and health.
	ListComponents(ctx context.Context) ([]core.Component, error)
	GetComponent(ctx context.Context, key string) (core.Component, error)
	CreateComponent(ctx context.Context, c core.Component) error
	UpdateComponent(ctx context.Context, c core.Component) error
	DeleteComponent(ctx context.Context, key string) error
	CheckComponent(ctx context.Context, key string) (core.Check, error)
	HealthSnapshot(ctx context.Context) (core.Health, error)
}

Backend is the set of Console operations the MCP tools need. Both the in-process engine backend and the HTTP-client backend satisfy it, so the tool handlers never depend on how Console is reached.

func NewEngineBackend

func NewEngineBackend(a *app.App) Backend

NewEngineBackend wraps an already-constructed App as a Backend. The caller retains ownership of the App (and its Close).

func NewHTTPBackend

func NewHTTPBackend(addr string) (Backend, error)

NewHTTPBackend builds a Backend that talks to the Console JSON API at addr. addr may be a bare host:port ("127.0.0.1:8080") or a full URL; a missing scheme defaults to http.

type Options

type Options struct {
	// Name and Version identify the server to the MCP client.
	Name, Version string
	// AllowWrites registers the mutating tools (create/toggle/delete flags and
	// components). It is off by default: without it the server exposes only
	// read and flag-evaluation tools. Console has no built-in auth, so writes
	// are opt-in.
	AllowWrites bool
}

Options configures an MCP server.

Jump to

Keyboard shortcuts

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