importer

package
v0.1.0-beta.15 Latest Latest
Warning

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

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

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

View Source
const (
	SkipGatewaySelfEntry = "gateway_self_entry"
	SkipUnsupported      = "unsupported_entry"
	SkipNameCollision    = "name_collision"
)

Skip reasons attached to candidates that will not be imported.

Variables

This section is empty.

Functions

func ClassifySecretKeys

func ClassifySecretKeys(env map[string]string) []string

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

func IsGatewaySelfEntry(entryName, linkServerName string, raw map[string]any) bool

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

func IsReferenceValue(v string) bool

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.

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)
	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

func Dedupe(candidates []Candidate) []Candidate

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.

Jump to

Keyboard shortcuts

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