client

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
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

func LoadSnapshotBytes(data []byte, name string) (*model.Snapshot, error)

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

func NewDialer(opts Options) analyzer.Dialer

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

func NewPreparer(opts Options) scanner.Preparer

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

func ValidateTransport(s string) error

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

func WithoutContentFetch(d analyzer.Dialer) analyzer.Dialer

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

Jump to

Keyboard shortcuts

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