surface

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: 4 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 surface renders a snapshot's declared MCP capability surface - instructions, tools, prompts, resources, resource templates - as text for something that judges it (a model, a third-party classifier), stopping once a caller-supplied character budget is used. Keeping every capability kind here prevents callers from counting declarations they forgot to render.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(snap *model.Snapshot, budget int, f Formatters) (text string, included, skipped int)

Build renders snap's declared surface, adding entries first-fit until budget characters have been used: an entry that does not fit is skipped, but a later, shorter entry can still fit, so included/skipped is not "the first N" or "the last N" - just a count of what did and did not make it in

func CompactJSON

func CompactJSON(v map[string]any) string

CompactJSON renders v as single-line JSON for embedding in a surface entry, or "{}" for an empty or unmarshalable value. Every formatter that puts a schema, annotations or _meta block into an entry goes through this, so the two do not drift into rendering the same map differently.

func Locator

func Locator(capKind, capability, field string) string

Locator is the pointer a finding on declared text carries instead of a file path: the capability kind, the capability's name unless it is the server itself, and the field

func PromptArguments

func PromptArguments(args []model.PromptArgument) string

PromptArguments renders one line per declared prompt argument (name, whether it is required, and its description). An argument description is as much attacker-writable declared text as the prompt's own description or rendered body, so it belongs in the same surface.

func ResourceIdentity

func ResourceIdentity(r model.ResourceInfo) string

ResourceIdentity renders a resource or template's URI (or URI template) and declared MIME type. The URI is often the most security-relevant field and must not disappear behind a friendly name or title.

func ToolExtras

func ToolExtras(t model.ToolInfo) string

ToolExtras renders the parts of a tool declaration beyond name, description and input schema: output schema, annotations and _meta. These maps are as attacker-controlled as the description, so omitting them would judge less content than coverage claims was analyzed.

Types

type Formatters

type Formatters struct {
	Instructions func(text string) string
	Tool         func(t model.ToolInfo) string
	Prompt       func(p model.PromptInfo) string
	Resource     func(r model.ResourceInfo) string
	Template     func(t model.ResourceInfo) string
}

Formatters renders one capability of each kind as a surface entry. Every field must be set: Build calls whichever formatter a declared item needs, so a nil formatter panics on the first snapshot that declares that kind rather than silently skipping it.

Jump to

Keyboard shortcuts

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