install

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: GPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package install puts agentgate between an MCP host and the servers it is configured with, and takes it out again.

Every host keeps its MCP servers in a JSON file. install reads the servers from it, writes an agentgate config with those servers as upstreams, and replaces them in the host's file with a single entry that runs agentgate. The original entries are kept in a manifest, so uninstall can put the file back exactly as it was — the rest of the host's settings are never touched.

Index

Constants

View Source
const EntryName = "agentgate"

EntryName is the name of the one server entry agentgate leaves in a host's config.

Variables

This section is empty.

Functions

func GenerateConfig

func GenerateConfig(c Candidate, opts Options) string

GenerateConfig writes the agentgate config for a host: its servers as upstreams, in shadow mode, with the packs that matter for any setup.

func GenerateTests

func GenerateTests(cfgPath string) string

GenerateTests writes starter policy tests for a config GenerateConfig wrote: what its packs must stop, and one thing they must let through.

Types

type Candidate

type Candidate struct {
	Host    Host
	Status  Status
	Servers []Server
	// Wrapped are the servers that will go behind agentgate; disabled ones
	// stay where they are.
	Wrapped []Server
}

Candidate is a host as init sees it.

func Scan

func Scan(env Env, manifest *Manifest) ([]Candidate, error)

Scan looks at every known host.

type Env

type Env struct {
	Home      string
	ConfigDir string
	Cwd       string
}

Env is where to look: the user's home and config directories, and the project directory for hosts with a per-project file.

func DefaultEnv

func DefaultEnv() (Env, error)

DefaultEnv is the real environment.

type Host

type Host struct {
	// Name is how the host is called on the command line.
	Name string `json:"name"`
	// Title is how it is called in prose.
	Title string `json:"title"`
	// Path is its config file.
	Path string `json:"path"`
	// Key is the member of the file that holds the servers.
	Key string `json:"key"`
	// TypedEntries is set for hosts whose entries carry "type": "stdio".
	TypedEntries bool `json:"typed_entries,omitempty"`
}

Host is an MCP host and where it keeps its servers.

func Hosts

func Hosts(env Env) []Host

Hosts lists every host agentgate knows how to install into, whether or not it is on this machine.

type Installed

type Installed struct {
	Host Host `json:"host"`
	// Servers is the host's servers member as it was, byte for byte.
	Servers json.RawMessage `json:"servers"`
	// Config is the agentgate config written for it.
	Config string `json:"config"`
	// Backup is a copy of the whole file as it was before.
	Backup      string    `json:"backup"`
	InstalledAt time.Time `json:"installed_at"`
}

Installed is one host agentgate was put in front of.

func Apply

func Apply(c Candidate, manifest *Manifest, opts Options) (*Installed, error)

Apply puts agentgate in front of one host: it writes the agentgate config, rewrites the host's servers member, and records both in the manifest.

func Uninstall

func Uninstall(name string, manifest *Manifest) (*Installed, error)

Uninstall puts a host's servers back the way they were before init. Every other part of the host's file keeps whatever it has now.

type Manifest

type Manifest struct {
	Hosts map[string]*Installed `json:"hosts"`
	// contains filtered or unexported fields
}

Manifest is ~/.agentgate/installed.json: what init changed, so uninstall can change it back.

func LoadManifest

func LoadManifest(dir string) (*Manifest, error)

LoadManifest reads the manifest in dir; a missing one is empty.

type Options

type Options struct {
	// Dir is agentgate's home, ~/.agentgate.
	Dir string
	// Binary is the absolute path of the agentgate executable the host
	// will run.
	Binary string
	// Now stamps the generated files.
	Now time.Time
}

Options control an install.

type Server

type Server struct {
	Name     string
	Command  string
	Args     []string
	Env      map[string]string
	Cwd      string
	URL      string
	Headers  map[string]string
	Disabled bool
	// Raw is the entry exactly as the host's file had it.
	Raw json.RawMessage
}

Server is one MCP server entry of a host's config.

func Servers

func Servers(h Host) ([]Server, error)

Servers reads the servers of a host, in the order the file lists them. A missing file has none.

func (Server) Stdio

func (s Server) Stdio() bool

Stdio reports whether the server is a local process.

type Status

type Status string

Status is where a host stands.

const (
	// StatusReady means the host has servers agentgate can be put in front of.
	StatusReady Status = "ready"
	// StatusInstalled means agentgate is already in front of it.
	StatusInstalled Status = "installed"
	// StatusEmpty means the host's config exists but lists no servers.
	StatusEmpty Status = "no servers"
	// StatusAbsent means there is no config file for the host.
	StatusAbsent Status = "not found"
)

Jump to

Keyboard shortcuts

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