Documentation
¶
Overview ¶
Package client is the wiring seam other packages depend on: it turns a model.Target into a live MCP connection (scanner.Preparer, analyzer.Dialer) or a replayed one (LoadSnapshotBytes), and implements analyzer.Session on top of the go-sdk client plus a minimal raw JSON-RPC channel for probes the typed SDK client will not build
Index ¶
- Variables
- func AllowPrivateNetworksForTesting()
- func LoadSnapshotBytes(data []byte, name string) (*model.Snapshot, error)
- func NewDialer(opts Options) analyzer.Dialer
- func NewPreparer(opts Options) scanner.Preparer
- func ValidateTransport(s string) error
- func WithoutContentFetch(d analyzer.Dialer) analyzer.Dialer
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrToolCallNotAllowed = errors.New("tool call not allowed")
ErrToolCallNotAllowed is returned by Session.CallTool when the scan's Options did not grant permission to call the named tool
Functions ¶
func AllowPrivateNetworksForTesting ¶
func AllowPrivateNetworksForTesting()
AllowPrivateNetworksForTesting disables the scanner's own SSRF guard (internal/mcp/transport.Policy) for the lifetime of the process, for tests that do not construct an Options value directly. Production callers must use Options.AllowPrivateNetworks; this process-wide escape hatch must never be enabled outside a test binary.
func LoadSnapshotBytes ¶
LoadSnapshotBytes parses a snapshot the caller has already read. Bounding that read is the caller's job: a snapshot file is somebody else's output, so reading it whole before parsing is an unbounded read of an attacker-adjacent file.
func NewDialer ¶
NewDialer returns an analyzer.Dialer that opens a fresh session to a target. Analyzers use it to reconnect with different credentials, or to recover after a probe kills the primary session.
func NewPreparer ¶
NewPreparer returns a scanner.Preparer that connects to a target, runs discovery, and hands back an AnalysisContext with Snapshot, Session and Dialer populated. A static target has nothing to connect to and is not accepted: its snapshot is read, and bounded, by the caller.
func ValidateTransport ¶
ValidateTransport rejects an unknown transport name before a connection attempt. The "auto" value is valid because only dialing can determine whether a remote server speaks Streamable HTTP or SSE.
func WithoutContentFetch ¶
WithoutContentFetch returns a Dialer equivalent to d but with resource and prompt content fetches (resources/read, prompts/get) turned off during discovery. Authentication probes need connection semantics, not dozens of repeated reads each time they open a fresh session.
Types ¶
type Options ¶
type Options struct {
Timeout time.Duration
Headers map[string]string
Transport string // auto | streamable | sse | stdio
ReadResources bool
GetPrompts bool
Logger *slog.Logger
// AllowPrivateNetworks opts into connecting to a loopback, link-local or
// private-range target. Off by default: most MCP servers people want to
// scan for real are on localhost, so this needs a real route rather than
// only AllowPrivateNetworksForTesting, but the guard still has to default
// closed for a caller who never asks for it.
AllowPrivateNetworks bool
// Probes and AllowedToolCalls are the scan's active-probe policy and tool allowlist
Probes analyzer.ProbeLevel
AllowedToolCalls []string
}
Options configures how the client connects and how much of a server's surface it reads