mcp

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrToolDisappeared = errors.New("MCP tool disappeared without a recorded decision")
	ErrToolChanged     = errors.New("MCP tool changed its annotation or tool sets without a recorded decision")
)

Errors for a change to the MCP tools with no recorded decision.

View Source
var Decisions = ToolDecisions{
	Removed: map[string]string{
		"list_escalations": "GET /manager/escalations is gone from prod (#5596), so the tool only returned errors. list_action_items returns a different schema, so it is not an alias.",
	},
}

Decisions holds the recorded decisions for the MCP tools.

Functions

func CheckToolSurface added in v0.27.0

func CheckToolSurface(base, live []ToolEntry, decisions ToolDecisions) error

CheckToolSurface reports every tool in base that live does not have, or that has another annotation or other tool sets in live, unless decisions records it.

func FormatToolSurface added in v0.27.0

func FormatToolSurface(entries []ToolEntry) string

FormatToolSurface renders entries as the tab-separated snapshot text.

func NewServer added in v0.27.0

func NewServer(apiClient *api.Client, toolSet ToolSet, orgs Orgs) *server.MCPServer

NewServer builds the MCP server: the tool set, list_organizations, an optional org argument on every other tool, and the resources and prompts.

func ScopeTransport added in v0.27.0

func ScopeTransport(next http.RoundTripper) http.RoundTripper

ScopeTransport sets the org scope a call resolved onto every request that call makes, over the client's default parameters. Scope travels in the request context, never in shared state, so concurrent calls for different orgs cannot cross.

func ServeWithClient added in v0.13.0

func ServeWithClient(ctx context.Context, apiClient *api.Client, toolSet ToolSet, orgs Orgs) error

ServeWithClient runs the MCP server over stdio, driving the generated api.Client. The client's default query params carry fixed scope such as --repo; each call's org comes from orgs and travels in the request context, so apiClient's HTTP client must route through ScopeTransport.

func ValidToolSets added in v0.13.0

func ValidToolSets() []string

ValidToolSets returns all valid tool set names for flag validation.

Types

type Orgs added in v0.27.0

type Orgs struct {
	// Resolve returns the query parameters that scope one call and a label
	// naming the org they select. org is the call's org argument, empty when
	// it named none; Resolve then uses the default the server started with,
	// and errors with the choices when there is none.
	Resolve func(ctx context.Context, org string) (map[string]string, string, error)
	// List backs the list_organizations tool. Its result is returned as JSON.
	List func(ctx context.Context) (any, error)
}

Orgs is how the server scopes each call to an organization. The server starts without one: a login can cover several orgs, and each tool call or resource read picks its own.

type ToolDecisions added in v0.27.0

type ToolDecisions struct {
	// Removed are tools that left.
	Removed map[string]string
	// Changed are tools that changed their annotation or their tool sets.
	Changed map[string]string
}

ToolDecisions records each deliberate break of the MCP tool surface, with the evidence.

type ToolEntry added in v0.27.0

type ToolEntry struct {
	Name string
	// Annotation is read-only, destructive, or write for a tool that changes state
	// but is not marked destructive.
	Annotation string
	Sets       []string
}

ToolEntry is one line of the MCP tool snapshot.

func ParseToolSurface added in v0.27.0

func ParseToolSurface(text string) ([]ToolEntry, error)

ParseToolSurface reads the snapshot text. An empty text has no tools.

func ToolSurface added in v0.27.0

func ToolSurface() []ToolEntry

ToolSurface returns every MCP tool with its access and its tool sets, sorted by name.

type ToolSet added in v0.13.0

type ToolSet string

ToolSet controls which MCP tools are registered.

const (
	ToolSetDefault  ToolSet = "default"
	ToolSetAll      ToolSet = "all"
	ToolSetMinimal  ToolSet = "minimal"
	ToolSetFindings ToolSet = "findings"
	ToolSetAdmin    ToolSet = "admin"
	// ToolSetFindingsWrite adds the finding tools that are kept out of the default
	// set: archive, unarchive, mark and unmark false positive, and delete ticket.
	ToolSetFindingsWrite ToolSet = "findings-write"
)

Jump to

Keyboard shortcuts

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