Files
archie/modules/connectors/internal/egress/dialer.go
T
sam cf249d7643 feat(connectors): MCP servers as a fourth accepted package, with their declared tools offered to agents (archie #2005)
An investigation needs Prometheus's own metrics, and Prometheus publishes an
MCP server, so the connectors module now runs MCP servers as published instead
of wrapping them: a stdio binary in its own user and network namespace with an
egress allow-list, or an HTTP endpoint dialled through declared egress.

Acceptance names the transport, the tools it permits, and the credential slots
that resolve into the server's environment (stdio) or Authorization header
(HTTP). Each permitted tool is declared as a lookup, or as an action with its
effect; a tool the server lists but the acceptance doesn't name is never
offered, and a declared tool the server doesn't list fails the start rather
than going silently missing. Declared tools reach agents beside connector
lookups through the same declaration and the same call path, with the server's
own input schema, under a name no connector can take: an accepted name runs one
package.

A server that fails to start, exits or stops answering is reported by readiness
and reconnected with backoff. Tool calls carry a deadline, results are capped,
and an error result fails its call with the server's own text rather than the
run.

The investigate prompt now asks for a time-until-full figure from
`predict_linear` through the metrics server instead of an estimate from raw
points.

The old core MCP path stays for now: the legacy gateway and task containers
still read config.Tools.MCPServers, so it goes with them.
2026-11-15 23:43:39 +11:00

29 lines
920 B
Go

package egress
import (
"context"
"fmt"
"net"
"strconv"
)
// Dialer returns a DialContext that reaches only the hosts allow names, for a
// client in this process that dials out itself rather than through the tunnel.
// The same rules hold as for the tunnel: a host named exactly may resolve to a
// private address, a wildcard match may not, and loopback is always refused.
func Dialer(allow []string) func(ctx context.Context, network, addr string) (net.Conn, error) {
r := rules{allow: compilePatterns(allow)}
t := &Tunnel{rules: r}
t.dial = t.dialGuarded
return func(ctx context.Context, network, addr string) (net.Conn, error) {
host, port, err := splitTarget(addr, 443)
if err != nil {
return nil, err
}
if !r.allows(host, port) {
return nil, fmt.Errorf("egress to %s:%d is not allowed", host, port)
}
return t.dialGuarded(ctx, network, net.JoinHostPort(host, strconv.Itoa(port)))
}
}