mcp

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LauncherNPM     = "npm"
	LauncherPyPI    = "pypi"
	LauncherDocker  = "docker"
	LauncherRemote  = "remote"
	LauncherCommand = "command"
)

Variables

This section is empty.

Functions

func DecodeServers

func DecodeServers(raw map[string]json.RawMessage) (map[string]Server, []string)

DecodeServers decodes a name-to-server map one server at a time.

func Describe

func Describe(name string, entry Entry) lockfile.MCPServer

Describe classifies a server by what launches it and returns the lock record that can be written without network access. An npm registry package comes back with an empty Status: it still needs ResolveNPM.

func NPMRegistry

func NPMRegistry(server Server) string

NPMRegistry returns the registry a server's launcher will use as far as agentpack can see it: the server's own environment, then the process environment, then the public registry. Per-user .npmrc files are not read.

func NPMSpec

func NPMSpec(record lockfile.MCPServer) string

NPMSpec returns the version or dist-tag part of a record's requested spec.

func NotCarried

func NotCarried(agent, name string, settings ...string) string

NotCarried names, for a warning, the settings of a server that an agent's MCP format has no place for.

func ParseServers

func ParseServers(data []byte) (map[string]Server, []string, error)

ParseServers reads the MCP servers of a JSON (or JSONC) document in either published form: wrapped in "mcpServers", or the bare name-to-server map that Claude Code also accepts in a plugin's .mcp.json. A server that cannot be read is left out and named in the returned warnings; the others are kept.

func ResolveNPM

func ResolveNPM(ctx context.Context, client *http.Client, registry, name, spec string) (version, integrity string, err error)

ResolveNPM asks the registry which exact version a version or dist-tag names and returns that version with the registry's tarball integrity.

func Unrecorded

func Unrecorded(entries Entries, records []lockfile.MCPServer) []string

Unrecorded names the servers that have no lock record for their current definition.

Types

type Config

type Config struct {
	Servers map[string]Server `json:"mcpServers"`
}

type Entries

type Entries map[string]Entry

func ApplyPins

func ApplyPins(entries Entries, records []lockfile.MCPServer) Entries

ApplyPins rewrites each npm server that the lock pins so it launches the exact locked version. A record made for a different definition is ignored: the server then runs as written until `agentpack lock` records it again.

func (Entries) Bare

func (entries Entries) Bare() map[string]Server

func (Entries) Names

func (entries Entries) Names() []string

type Entry

type Entry struct {
	Server Server
	Source Source
	// Module and CacheKey name the package a plugin's server came from.
	Module   string
	CacheKey string
}

type OAuth

type OAuth struct {
	ClientID     string   `toml:"client_id,omitempty"`
	ClientSecret string   `toml:"client_secret,omitempty"`
	CallbackPort int      `toml:"callback_port,omitempty"`
	Scopes       []string `toml:"scopes,omitempty"`
	MetadataURL  string   `toml:"metadata_url,omitempty"`
}

OAuth is the OAuth client a remote MCP server is used with.

type Server

type Server struct {
	Type     *string           `toml:"type,omitempty" json:"type,omitempty"`
	Command  *string           `toml:"command,omitempty" json:"command,omitempty"`
	Args     []string          `toml:"args,omitempty" json:"args,omitempty"`
	Env      map[string]string `toml:"env,omitempty" json:"env,omitempty"`
	URL      *string           `toml:"url,omitempty" json:"url,omitempty"`
	Disabled *bool             `toml:"disabled,omitempty" json:"disabled,omitempty"`
	// Headers are sent with every request to a remote server. Like Env, they
	// may hold credentials and never reach pack.lock.
	Headers map[string]string `toml:"headers,omitempty" json:"headers,omitempty"`
	// Cwd is the directory a local server is started in.
	Cwd *string `toml:"cwd,omitempty" json:"cwd,omitempty"`
	// OAuth holds the client settings of a remote server. Each agent spells
	// them its own way, so the harness writers render them.
	OAuth *OAuth `toml:"oauth,omitempty" json:"-"`
}

Server is the canonical MCP server definition shared by manifest loading, source merging, and harness-specific renderers.

func (Server) Definition

func (server Server) Definition() string

Definition digests what a server definition runs: its type, command, arguments, and URL. Environment values are excluded so secrets never influence, or leak through, the lockfile.

func (Server) IsRemote

func (server Server) IsRemote() bool

func (Server) JSONObject

func (server Server) JSONObject() map[string]any

JSONObject is the server in the JSON shape Claude Code, Cursor and Antigravity share: type, command, args, env, url, headers, disabled. Each writer adds or renames what its agent spells differently.

type Source

type Source string
const (
	Plugin    Source = "plugin"
	Manifest  Source = "manifest"
	DotAgents Source = ".agents"
)

Jump to

Keyboard shortcuts

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