Documentation
¶
Index ¶
- func BytesHash(input []byte) string
- func ComputeToolHash(serverName, toolName, description string, inputSchema interface{}) string
- func ComputeToolHashWithOutputSchema(serverName, toolName, description string, inputSchema interface{}, ...) string
- func NormalizeJSON(s string) string
- func StringHash(input string) string
- func ToolContractDigest(description, schemaJSON, outputSchemaJSON string) string
- func ToolDefinitionDigest(description, schemaJSON string) string
- func ToolHash(serverName, toolName, description string, parametersSchema interface{}) (string, error)
- func ToolHashWithOutputSchema(serverName, toolName, description string, parametersSchema interface{}, ...) (string, error)
- func VerifyToolHash(serverName, toolName, description string, parametersSchema interface{}, ...) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeToolHash ¶
ComputeToolHash computes a SHA256 hash for a tool (alias for ToolHash that doesn't return error)
func ComputeToolHashWithOutputSchema ¶ added in v0.33.4
func ComputeToolHashWithOutputSchema(serverName, toolName, description string, inputSchema interface{}, outputSchemaJSON string) string
ComputeToolHashWithOutputSchema computes a SHA256 hash for a tool including output schema.
func NormalizeJSON ¶ added in v0.33.4
NormalizeJSON parses s and re-serializes it with object keys sorted, so that semantically identical JSON with different key order or whitespace produces a stable, comparable string. It also canonicalizes JSON Schema draft-07 local references (see canonicalizeSchemaRefs). Empty or non-JSON input is returned unchanged.
This is the single canonical JSON normalizer shared by the upstream tool capture (internal/upstream/core) and the tool-approval hash (internal/runtime), so a schema hashes identically no matter which path observed it — or which version of the MCP library decoded it.
func ToolContractDigest ¶ added in v0.71.0
ToolContractDigest is the output-aware successor of ToolDefinitionDigest: a stable digest of every part of a tool contract a security scan reads — description, input schema AND output schema (scanners analyse output schemas since RT-06). It is versioned so it can never equal a ToolDefinitionDigest, and an absent or null output schema counts as "".
func ToolDefinitionDigest ¶ added in v0.71.0
ToolDefinitionDigest returns a stable digest of the parts of a tool definition a security scan reads: its description and input schema. The tool name is the lookup key on both sides, and the output schema is not exported to scanners, so neither is folded in. A missing, null or empty schema counts as "{}" so every producer agrees.
func ToolHash ¶
func ToolHash(serverName, toolName, description string, parametersSchema interface{}) (string, error)
ToolHash computes SHA-256 hash for tool change detection. Format: sha256(canonical JSON of serverName, toolName, description, input schema)
func ToolHashWithOutputSchema ¶ added in v0.33.4
func ToolHashWithOutputSchema(serverName, toolName, description string, parametersSchema interface{}, outputSchemaJSON string) (string, error)
ToolHashWithOutputSchema computes SHA-256 hash for the full tool contract. Output schema is included because it describes the data shape returned to the agent and therefore belongs to the human-approved tool contract. Format: sha256(canonical JSON of serverName, toolName, description, input schema, output schema)
Types ¶
This section is empty.