toolhelp

package
v1.170.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 14 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 toolhelp answers, from a tool's advertised input schema, what the tool takes: the refusal of a call whose arguments do not match it (#2811), help on every tool that chooses its operation by a command or an action (#2815), and one example call fitting what a caller said it wants to do (#2809). Everything here reads the schema the server shows a client, so no answer can drift from what the tool accepts.

It is its own package rather than more of pkg/middleware, which is at its file and exported-surface budgets.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Example

func Example(schema map[string]any, intent string) map[string]any

Example is one call of a tool that fits what a caller said it wants to do, read from the tool's input schema (#2809): for a tool that chooses its operation by a command or action enum, the value whose words best match the intent, every parameter that value requires (a placeholder naming its type), and any enum parameter whose value the intent names ("assets shared with me" gives manage_asset's action list with scope shared). A tool with no such enum gets its required parameters. Nil when the schema declares nothing.

func HelpField added in v1.169.1

func HelpField(schema map[string]any) (field string, ok bool)

HelpField is the argument help is answered on for a tool with this input schema: its command or action field, when that is an enum. ok is false for a tool help does not apply to.

func HelpMiddleware

func HelpMiddleware(lookup SchemaLookup) mcp.Middleware

HelpMiddleware answers `help` on every tool that takes a command or an action (#2815), from the tool's advertised input schema, so the answer is what the tool accepts and cannot drift from it. A tool whose command enum lists help itself (manage_script) answers its own and is passed through, as is a call to any tool whose schema the lookup cannot read or that chooses no command by an enum.

The answer lists each command with the parameters whose description names it (the schemas write "publish: ..." or "grant, revoke: ..."), the parameters every command shares, and an example call per command.

Placement: inner to authorization and the gates, so a persona that may not call the tool is refused as for any other command, and inner to the error contract.

func RefusalMiddleware

func RefusalMiddleware(lookup SchemaLookup) mcp.Middleware

RefusalMiddleware rewrites an argument refusal so it names what the call got wrong and what the tool accepts (#2811): each property the schema does not declare with the accepted name it most likely meant, each value of the wrong type or outside an enum, and every accepted parameter with its type. The code and category are unchanged. Any other result, or a refusal whose tool schema cannot be read, is returned as it was.

Placement: outer to the error contract, whose normalized refusal it reads, and inner to audit, which records the same code and category either way.

func RepeatMiddleware

func RepeatMiddleware(session func(ctx context.Context) string) mcp.Middleware

RepeatMiddleware tells an agent, the second time one session's call to a tool is refused with the same code, how to report what the platform could not do (#2820): at that point the refusal is no longer a mistake to correct. A refusal of a session-less call, a refusal of manage_feedback itself, and a managed script's call are left as they are: a script reads the refusal's structured error to classify its failure, and reads no advice.

Types

type SchemaLookup

type SchemaLookup func(ctx context.Context, tool string) map[string]any

SchemaLookup returns a registered tool's advertised input schema as decoded JSON, or nil when it is not known. internal/toolschema answers it from the server's own tools/list.

Jump to

Keyboard shortcuts

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