Documentation
¶
Overview ¶
Package importer converts MCP server entries found in client configs into gridctl stack entries. It is pure logic: callers (the import CLI) do all file I/O. The package normalizes the client dialect matrix (key spellings, transport names, command shapes), unwraps bridge entries, dedupes servers found in several clients, filters gridctl's own gateway entries, and classifies plaintext secrets so the CLI can offer vault moves.
Index ¶
- Constants
- func ClassifySecretKeys(env map[string]string) []string
- func IsGatewaySelfEntry(entryName, linkServerName string, raw map[string]any) bool
- func IsReferenceValue(v string) bool
- func MapEntry(slug string, entry provisioner.ServerEntry) (config.MCPServer, []string, error)
- func MapEntryWithOptions(slug string, entry provisioner.ServerEntry, opts MapOptions) (config.MCPServer, []string, error)
- type Candidate
- type MapError
- type MapOptions
- type Origin
Constants ¶
const ( SkipGatewaySelfEntry = "gateway_self_entry" SkipUnsupported = "unsupported_entry" SkipNameCollision = "name_collision" // SkipDisabled means an OpenCode entry set enabled to false. Other clients // ignore the field. SkipDisabled = "disabled" // SkipUntransferredOption means dropping the option would change execution. // OpenCode skips a working directory on every shape, and skips oauth or // local headers on a command array. SkipUntransferredOption = "untransferred_option" // SkipNativeExpression means a newly supported native value used an // OpenCode expression Gridctl cannot represent without reading it. SkipNativeExpression = "unsupported_native_expression" // SkipAmbiguous means two native forms conflict and were not merged. SkipAmbiguous = "ambiguous_entry" )
Skip reasons attached to candidates that will not be imported.
Variables ¶
This section is empty.
Functions ¶
func ClassifySecretKeys ¶
ClassifySecretKeys returns the env keys whose values are literal secrets: non-empty, not a recognized reference, with a secret-suggestive key name. Sorted for deterministic prompts and output.
func IsGatewaySelfEntry ¶
IsGatewaySelfEntry reports whether a scanned entry is gridctl's own gateway connection. The entry key matching the link server name is the primary signal; a localhost URL pointing at the gateway's /sse or /mcp endpoints (directly or through an mcp-remote bridge) is the secondary one. A user's own localhost server under a different name and path is NOT flagged.
func IsReferenceValue ¶
IsReferenceValue reports whether an env value is a reference that must be preserved verbatim rather than treated as a secret literal: interpolation dialects (${env:VAR}, ${input:id}, ${file:...}, ${VAR}, ${{ secrets.X }}), bare $VAR and %VAR%, 1Password op:// URIs, and gridctl's own ${var:KEY}.
func MapEntry ¶
func MapEntry(slug string, entry provisioner.ServerEntry) (config.MCPServer, []string, error)
MapEntry converts one raw client entry into a config.MCPServer plus warnings. An error means the entry cannot be represented (for example a websocket transport) and should surface as a skipped candidate.
func MapEntryWithOptions ¶
func MapEntryWithOptions(slug string, entry provisioner.ServerEntry, opts MapOptions) (config.MCPServer, []string, error)
MapEntryWithOptions is MapEntry with project placeholder substitution and scope-dependent working-directory handling. Empty options match MapEntry.
Types ¶
type Candidate ¶
type Candidate struct {
Name string
Server config.MCPServer
FoundIn []string // client slugs the server was found in, sorted
Source string // canonical slug (first client in registry order)
SourcePath string // canonical config file path; not a client slug
SourcePaths []string // config file paths retained through dedupe
Origins []Origin // client, scope, and path triples in append order
Warnings []string
SkipReason string // empty means importable
SecretKeys []string // env keys whose literal values look like secrets
}
Candidate is one importable server assembled from client config entries.
func Dedupe ¶
Dedupe collapses candidates with the same identity (name plus URL or command line) into one, merging provenance. Candidates arrive in registry order, so the first occurrence is the canonical source. A same-name, different-definition candidate stays separate and is flagged for review.
func (Candidate) ProvenanceLabel ¶
ProvenanceLabel groups origins by client in FoundIn order and renders slug (scope) pairs. Several scopes for one client join with +.
type MapError ¶
MapError is a value-free reason an entry cannot be imported. Detail must not include config values, expression text, or referenced file contents.
type MapOptions ¶
MapOptions carries project-import context. Empty options keep MapEntry behavior unchanged.