discovery

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 7 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 discovery drives the standard MCP discovery methods against an initialized session and converts the result into a model.Snapshot

Index

Constants

View Source
const LimitHitReason = "hit the scanner's own "

LimitHitReason prefixes a Truncation.Reason produced by one of paginate's own caps (page, item or byte) - the scanner protecting itself - as opposed to a stop caused by the server's own behavior (a repeated cursor, a failed page)

Variables

This section is empty.

Functions

func Discover

func Discover(ctx context.Context, cs *mcp.ClientSession, opts Options) (*model.Snapshot, error)

Discover reads the server's declared surface - tools, prompts, resources, resource templates, instructions and capabilities - from an initialized session and returns the scanner's own view of it

func PromptInfo

func PromptInfo(p *mcp.Prompt) model.PromptInfo

PromptInfo converts an SDK prompt declaration into the scanner's own shape

func ResourceInfo

func ResourceInfo(r *mcp.Resource) model.ResourceInfo

ResourceInfo converts an SDK resource declaration into the scanner's own shape

func TemplateInfo

func TemplateInfo(t *mcp.ResourceTemplate) model.ResourceInfo

TemplateInfo converts an SDK resource template declaration into the scanner's own shape

func ToMap

func ToMap(v any) map[string]any

ToMap round-trips v through JSON into a map[string]any, respecting whatever json tags v's type declares. Used to convert SDK-typed structs (capabilities, annotations) into the loosely-typed shape model.Snapshot stores them in.

func ToSchema

func ToSchema(v any) map[string]any

ToSchema handles the client-side shape of Tool.InputSchema/OutputSchema, which is already a map[string]any once decoded from the wire

func ToolInfo

func ToolInfo(t *mcp.Tool) model.ToolInfo

ToolInfo converts an SDK tool declaration into the scanner's own shape. Exported so client.LoadSnapshotBytes can reuse it when converting a plain MCP-shaped document that was never discovered through a live session.

Types

type Options

type Options struct {
	// ReadResources, when set, fetches the content of every declared
	// resource (not template) via resources/read
	ReadResources bool
	// GetPrompts, when set, fetches the rendered text of every declared
	// prompt via prompts/get
	GetPrompts bool
	// MaxResourceBytes bounds how much of each resource's content discovery
	// keeps. Zero uses defaultMaxResourceBytes.
	MaxResourceBytes int
	// MaxTotalResourceBytes bounds the combined content kept across every
	// resource read in one discovery pass. Zero uses
	// defaultMaxTotalResourceBytes. The per-resource cap alone does not
	// bound this: a server with enough declared resources, each individually
	// within MaxResourceBytes, still adds up to an unbounded amount held in
	// the snapshot and then serialized into the report.
	MaxTotalResourceBytes int
	// MaxPromptBytes bounds how much of each prompt's rendered text
	// discovery keeps. Zero uses defaultMaxPromptBytes.
	MaxPromptBytes int
	// MaxTotalPromptBytes bounds the combined rendered text kept across
	// every prompt fetched in one discovery pass, for the same reason
	// MaxTotalResourceBytes exists: a server with enough declared prompts,
	// each individually within MaxPromptBytes, still adds up to an unbounded
	// amount held in the snapshot and then serialized into the report
	MaxTotalPromptBytes int
}

Options controls how much of the server's surface discovery reads beyond the declarations themselves. Discovery never calls a tool.

Jump to

Keyboard shortcuts

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