mcp

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mcp owns the `da mcp` subcommand tree. Resources live under ~/.agents/mcp/<scope>/ and feed the list/show/remove triplet shared by the rules and settings resource families via cmdutil.RunCanonical*.

The package mirrors the file convention used by commands/agents and commands/skills: cmd.go assembles the cobra tree, list.go/show.go/ remove.go hold each handler, seams.go owns the cmdutil.CanonicalFileSpec wiring + findMCPSpec lookup. Tests are split across mcp_test.go (the testutil-consuming flow tests, transplanted verbatim from commands/mcp_test.go), seams_test.go (findMCPSpec coverage), and coverage_test.go (RunE wiring coverage).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCmd

func NewCmd(deps Deps) *cobra.Command

NewCmd builds the `da mcp` command tree from injected dependencies. Mirrors agents.NewAgentsCmd / skills.NewSkillsCmd: helpers come from Deps so the subpackage stays independent of the parent commands/ package. The cobra-tree assembly lives in cmdutil so mcp/settings/rules share one implementation; the per-resource description lives in a single CanonicalFileSpec built by canonicalSpec (see seams.go).

func NewListCmd

func NewListCmd(deps Deps) *cobra.Command

NewListCmd / NewShowCmd / NewRemoveCmd build each subcommand standalone — retained for parity with the historical surface and for the parent shim's cross-cutting RunE coverage tests.

func NewRemoveCmd

func NewRemoveCmd(deps Deps) *cobra.Command

func NewShowCmd

func NewShowCmd(deps Deps) *cobra.Command

func RunList

func RunList(scope string) error

RunList prints canonical MCP files under ~/.agents/mcp/<scope>/. Does not invoke the Resolve callback so a zero-value Deps is sufficient for the spec construction.

func RunRemove

func RunRemove(deps Deps, scope, name string) error

RunRemove removes an MCP file from ~/.agents/mcp/<scope>/, with the dry-run + confirm gates handled inside cmdutil.RunCanonicalRemove. deps.Flags carries the resolved global DryRun/Yes/Force; deps is also threaded into canonicalSpec so the Resolve callback's findMCPSpec errors can flow through the parent ErrorWithHints/UsageError helpers.

func RunShow

func RunShow(deps Deps, scope, name string) error

RunShow prints metadata for one canonical MCP file. The resolve path goes through findMCPSpec; deps is threaded in so the parent commands shim can wire its commands.ErrorWithHints / commands.UsageError helpers and keep the user-facing CLIError shape unchanged.

For ergonomic intra-package use the zero-value Deps is accepted (errors fall back to fmt.Errorf) — that path is exercised by mcp_test.go which only asserts on the wrapped message text.

Types

type Deps

type Deps struct {
	Flags              cmdutil.CanonicalCmdFlags
	MaxArgsWithHints   func(n int, hints ...string) cobra.PositionalArgs
	ExactArgsWithHints func(n int, hints ...string) cobra.PositionalArgs

	// ErrorWithHints / UsageError let findMCPSpec produce the same
	// user-facing errors the parent commands.* helpers emit. Both
	// fields may be nil; findMCPSpec falls back to fmt.Errorf-style
	// errors in that case.
	ErrorWithHints func(message string, hints ...string) error
	UsageError     func(message string, hints ...string) error
}

Deps carries UX helpers from the parent commands/ package without an import cycle. Mirrors agents.Deps / skills.Deps but uses cmdutil.CanonicalCmdFlags directly because the three canonical resource subpackages (mcp, settings, rules) share that flag struct.

MaxArgsWithHints and ExactArgsWithHints are exported so the parent shim in commands/mcp.go can populate them from commands.MaximumNArgsWithHints / commands.ExactArgsWithHints without reaching into unexported fields.

Jump to

Keyboard shortcuts

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