Documentation
¶
Overview ¶
Package probe implements the ephemeral MCP server probe used by the wizard to enumerate a server's tool list before it has been deployed.
The cache keeps successful probe results for 5 minutes keyed by a canonicalized hash of the server config so repeated "Discover tools" clicks on the same config short-circuit the spawn.
Index ¶
Constants ¶
const ( CodeProbeTimeout = "probe_timeout" CodeInitializeFailed = "initialize_failed" CodeToolsListFailed = "tools_list_failed" CodeUnsupportedTransport = "unsupported_transport" CodeInvalidConfig = "invalid_config" CodeRateLimited = "rate_limited" CodeInternal = "internal_error" )
Error codes surfaced to clients. Kept as constants so the frontend can map them to user-facing copy deterministically.
const DefaultTTL = 5 * time.Minute
DefaultTTL is how long a successful probe result is cached.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is a concurrency-safe TTL cache for probe results. The zero value is not usable — call NewCache.
func NewCache ¶
NewCache constructs a probe cache with the given TTL. Zero or negative TTLs fall back to DefaultTTL so callers can't accidentally disable caching.
func (*Cache) Get ¶
Get returns the entry for key if present and not expired. Expired entries are removed on access (lazy eviction).
type ClientFactory ¶
type ClientFactory interface {
NewHTTP(name, endpoint string) mcp.AgentClient
}
ClientFactory builds an MCP client for a given transport. The default implementation defers to the standard pkg/mcp constructors; tests override it to inject stubs.
type Error ¶
Error is a structured probe failure. Unlike a plain error, it carries a stable code for the UI and an optional hint. Secrets in Message / Hint are scrubbed by the handler before the response is serialized.
type Prober ¶
type Prober struct {
// contains filtered or unexported fields
}
Prober enumerates an MCP server's tools without registering it with the gateway. Scope: external URL transport only.
For every other transport (container HTTP/SSE, container stdio, local process, SSH, OpenAPI) the probe returns CodeUnsupportedTransport with a hint pointing users at the post-deploy tool editor. Running a server ephemerally before deploy is a niche workflow compared to the common deploy-then-curate flow that the topology editor supports.
func (*Prober) Probe ¶
Probe validates the config, short-circuits on cache hits, and otherwise connects to the external URL long enough to run initialize + tools/list. It is safe to call concurrently; the caller is responsible for enforcing concurrency caps.
func (*Prober) SetClientFactory ¶
func (p *Prober) SetClientFactory(f ClientFactory)
SetClientFactory overrides the MCP client constructor. Primarily for tests.