mcp

package
v0.20.4 Latest Latest
Warning

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

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

Documentation

Overview

Package mcp is a Model Context Protocol server that exposes a Miabi control panel to AI agents (Claude Desktop, Claude Code, Cursor, …). It is a thin protocol wrapper over internal/api: every tool call is one authenticated request to the panel's public /api/v1, so the agent inherits the operator's token, workspace scoping, and RBAC. No model inference happens here.

The server speaks JSON-RPC 2.0 over stdio (newline-delimited messages) or over the Streamable HTTP transport (see http.go). It implements the initialize handshake plus tools, resources, and prompts. Kept dependency-free — only the standard library — to match the CLI's thin footprint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Client *api.Client
	// FallbackWorkspace is the workspace name used when a call omits the
	// "workspace" argument (typically the CLI's active/bound workspace). May be
	// empty, in which case calls require an explicit workspace unless the token
	// can see exactly one.
	FallbackWorkspace string
	// AllowWrite enables the mutating tools (deploy, restart, rollback, …). When
	// false the server is strictly read-only and those tools are not advertised.
	AllowWrite bool
	Version    string
	// Logf sinks diagnostics. On stdio the protocol owns stdout, so logs must go
	// to stderr (or nowhere); never to stdout.
	Logf func(format string, args ...any)
}

Options configures a Server.

type Server

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

Server serves MCP over a stdio pair or HTTP. It holds one API client and a resolved fallback workspace (the CLI's active/bound workspace, used when a tool or resource omits a workspace).

func New

func New(o Options) *Server

New builds a Server with the standard tool and prompt catalogs registered.

func (*Server) Serve

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

Serve runs the stdio read-dispatch-reply loop until in reaches EOF or ctx is cancelled. Each JSON value on in is one JSON-RPC message; each reply is one on out. Returns nil on a clean EOF (the client closed the pipe).

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(ctx context.Context, addr string) error

ServeHTTP runs the server over the MCP Streamable HTTP transport at addr, exposing a single JSON-RPC endpoint at /mcp.

Jump to

Keyboard shortcuts

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