Documentation
¶
Overview ¶
Package schema turns a tool's raw parameters and body into the argument set the model sees, and builds the MCP input schema from it (SPEC §3.5 rules 3, 6 and 7). It is pure.
- Forbidden headers (auth, cookies, hop-by-hop, Host, X-Forwarded-*, Content-Length, Content-Type, ...) are removed: the model never sets them.
- Fixed parameters stay in Params (so the proxy can inject them) but are Hidden and never appear in the input schema.
- Object JSON bodies are flattened into InBody parameters. A field that collides becomes body_<name>; if that collides too, the whole body is nested under one InBodyRoot parameter instead. Fields are never dropped.
- Model-facing names are sanitized to [A-Za-z0-9_.-] (<= 64 bytes) and unique case-insensitively; UpstreamName keeps the original.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidArgs = errors.New("invalid arguments")
ErrInvalidArgs means tool-call arguments failed validation.
Functions ¶
func DecodeArgs ¶
func DecodeArgs(raw json.RawMessage) (map[string]any, error)
DecodeArgs decodes raw arguments into a map, keeping numbers as json.Number so large integers keep full precision.
func InputSchema ¶
func InputSchema(t model.Tool) json.RawMessage
InputSchema builds the MCP input schema from t's visible parameters. Unknown arguments are rejected (additionalProperties: false).
func IsForbiddenHeader ¶
IsForbiddenHeader reports whether a header may never be a tool parameter.
Types ¶
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator checks tool-call arguments against a tool's input schema (SPEC §3.7 step 4). The input schema sets additionalProperties: false, so unknown arguments (including attempts to set hidden fixed params) fail.
func NewValidator ¶
NewValidator compiles t's input schema. If that fails (for example, a spec uses an ECMA-262-only regex), it falls back to a minimal schema that still enforces required arguments and rejects unknown ones; Degraded then reports true. It never falls back to accepting anything.