Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrRegistryNotFound = errors.New("registry not found") ErrServerNotFound = errors.New("server not found in registry") )
Sentinel errors for single-server lookup. Surfaces map these to stable error codes (registry_not_found / server_not_found) for cross-surface consistency (CN-004).
var ErrRegistryKeyMissing = errors.New("registry requires an API key that is not configured")
ErrRegistryKeyMissing is returned when a registry declares RequiresKey but no API key is configured for it. Calling surfaces should treat this as "registry unavailable" and continue rather than failing the whole search (FR-008 / SC-006).
Functions ¶
func RegistryKeyEnvVar ¶ added in v0.35.0
RegistryKeyEnvVar returns the environment variable a key-requiring registry reads its API key from: MCPPROXY_REGISTRY_<ID>_API_KEY, with the ID upper-cased and any non-alphanumeric character replaced by an underscore. e.g. "azure-mcp-demo" -> "MCPPROXY_REGISTRY_AZURE_MCP_DEMO_API_KEY".
func SetRegistriesFromConfig ¶
SetRegistriesFromConfig builds the effective registry list by MERGING the built-in defaults with the user's configured registries, keyed by ID (FR-006). Built-in defaults come first (in their canonical order); a config entry with a new ID is appended, and a config entry whose ID collides with a default overrides it in place. This means adding one custom registry no longer drops the shipped defaults, and no rebuild is required.
Types ¶
type RegistryEntry ¶
type RegistryEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"`
ServersURL string `json:"servers_url,omitempty"`
Tags []string `json:"tags,omitempty"`
Protocol string `json:"protocol,omitempty"`
Count interface{} `json:"count,omitempty"` // number or string
// RequiresKey marks a registry that needs an API key to be queried. When
// true and no key is configured, SearchServers skips it with
// ErrRegistryKeyMissing so the calling surface can mark it unavailable
// instead of failing the whole search (FR-008).
RequiresKey bool `json:"requires_key,omitempty"`
}
RegistryEntry represents a registry in the embedded registry list
func FindRegistry ¶
func FindRegistry(idOrName string) *RegistryEntry
FindRegistry finds a registry by ID or name (case-insensitive)
func ListRegistries ¶
func ListRegistries() []RegistryEntry
ListRegistries returns a copy of all available registries
type RequiredInput ¶ added in v0.35.0
type RequiredInput struct {
Name string `json:"name"` // Env var name (e.g. GITHUB_TOKEN)
Description string `json:"description,omitempty"` // Optional human hint
Secret bool `json:"secret,omitempty"` // Mask in UI/logs when true
}
RequiredInput declares a single env var / key a server needs before it will work. Surfaces use this to prompt the user (FR-003).
func DetectRequiredInputs ¶ added in v0.35.0
func DetectRequiredInputs(entry *ServerEntry) []RequiredInput
DetectRequiredInputs returns the env vars / keys a server needs before it can run (FR-003 plumbing). It is best-effort and combines two sources:
(a) any RequiredInputs already declared on the entry (e.g. from a registry
payload that surfaced them explicitly), and
(b) a heuristic scan of the install command and URL for ${VAR} / $VAR
placeholders (decision O1 — no rich per-registry schema in this spec).
Results are de-duplicated by Name and returned in a stable (sorted) order so the same entry always yields the same list across surfaces (CN-004).
type ServerEntry ¶
type ServerEntry struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
URL string `json:"url"` // MCP endpoint for remote server connections only
SourceCodeURL string `json:"source_code_url,omitempty"` // URL to source code repository
InstallCmd string `json:"installCmd,omitempty"` // Command to install the server locally
ConnectURL string `json:"connectUrl,omitempty"` // Alternative connection URL for remote servers
UpdatedAt string `json:"updatedAt,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
Registry string `json:"registry,omitempty"` // Which registry this came from
// Repository detection information
RepositoryInfo *experiments.GuessResult `json:"repository_info,omitempty"` // Detected npm/pypi package info
// RequiredInputs are env vars / keys the user must supply before the server
// can run (FR-003 plumbing). Best-effort: populated either from explicit
// registry payload fields or via a heuristic scan of the install command for
// ${VAR} / $VAR placeholders (see DetectRequiredInputs). Empty for most
// servers in this spec — no rich per-registry schema yet (decision O1).
RequiredInputs []RequiredInput `json:"required_inputs,omitempty"`
}
ServerEntry represents an MCP server discovered via a registry
func FindServerByID ¶ added in v0.35.0
func FindServerByID(ctx context.Context, registryID, serverID string, guesser *experiments.Guesser) (*ServerEntry, error)
FindServerByID resolves a single server within a registry by its exact ID. It performs a live registry fetch and is the shared resolution path used by every add-from-registry surface (CN-001/CN-004). Returns ErrRegistryNotFound when registryID does not resolve and ErrServerNotFound when no server matches.
func SearchServers ¶
func SearchServers(ctx context.Context, registryID, tag, query string, limit int, guesser *experiments.Guesser) ([]ServerEntry, error)
SearchServers searches the given registry for servers matching optional tag and query with optional repository guessing and result limiting