pub struct ToolDigest(/* private fields */);Expand description
A stable digest of the discovered tool list (names, descriptions, and input/output schemas) at generation time, recorded so a later comparison can detect that the server’s tool surface changed.
Newtype over a 64-character lowercase-hex String — see ConfigFingerprint’s doc comment
for why this is a newtype rather than a bare String, and for the TryFrom<String>/
DigestFormatError validation its Deserialize is routed through.
§Examples
use mcp_execution_core::provenance::{ToolDigest, ToolDigestEntry};
use serde_json::json;
let schema = json!({"type": "object"});
let entries = vec![ToolDigestEntry {
name: "create_issue",
description: "Creates a new issue",
input_schema: &schema,
output_schema: None,
}];
let digest = ToolDigest::compute(&entries);
assert_eq!(digest.as_str().len(), 64);Implementations§
Source§impl ToolDigest
impl ToolDigest
Sourcepub fn compute(entries: &[ToolDigestEntry<'_>]) -> Self
pub fn compute(entries: &[ToolDigestEntry<'_>]) -> Self
Computes an aggregate digest of entries, insensitive to input order (including two
tools sharing the same name in swapped order) but sensitive to any schema/name/
description edit, tool addition, or tool removal.
Two-level construction: each entry is hashed on its own (domain tag, framed name,
framed description, then input_schema/output_schema via the recursive
hash_value_into walk — output_schema’s presence is tagged explicitly, so None
and Some(Value::Null) hash differently), the resulting 32-byte digests are sorted, and
the sorted sequence is hashed into the final aggregate. Sorting digests rather than tool
names gives a total order even for duplicate tool names, which name-sorting alone would
leave ambiguous.
§Examples
Reordering the input tool list does not change the digest:
use mcp_execution_core::provenance::{ToolDigest, ToolDigestEntry};
use serde_json::json;
let schema_a = json!({"type": "object"});
let schema_b = json!({"type": "string"});
let a = ToolDigestEntry { name: "a", description: "", input_schema: &schema_a, output_schema: None };
let b = ToolDigestEntry { name: "b", description: "", input_schema: &schema_b, output_schema: None };
assert_eq!(
ToolDigest::compute(&[a, b]),
ToolDigest::compute(&[b, a]),
);Trait Implementations§
Source§impl Clone for ToolDigest
impl Clone for ToolDigest
Source§fn clone(&self) -> ToolDigest
fn clone(&self) -> ToolDigest
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more