Skip to main content

ParamDecl

Struct ParamDecl 

Source
pub struct ParamDecl {
Show 15 fields pub name: String, pub param_type: Option<String>, pub description: Option<String>, pub required: bool, pub default: Option<Value>, pub max_length: Option<u64>, pub minimum: Option<f64>, pub maximum: Option<f64>, pub enum_values: Option<Vec<Value>>, pub pattern: Option<String>, pub min_length: Option<u64>, pub format: Option<String>, pub items: Option<ItemsDecl>, pub max_items: Option<u64>, pub allow_slash: bool,
}
Expand description

Single [[tools.parameters]] entry.

The default and enum fields use toml::Value because they are heterogeneous in the reference configs (a default may be an integer, a string, or a boolean depending on the parameter type).

§Forward incompatibility (Phase 128, D-15)

This struct carries #[serde(deny_unknown_fields)], so a config declaring any of the Phase 128 D2 keys — pattern, min_length, format, max_items, allow_slash, or an [tools.parameters.items] table — fails to PARSE on toolkit 0.1.3 rather than degrading to “the key was ignored”. That is deliberate (a silently-ignored validation rule is the class this phase closes) but it means a config written for this release cannot be loaded by an older toolkit. The same applies to the [server.validation] section. Named in the CHANGELOG.

Fields§

§name: String

Parameter name (the :param token used in the tool’s sql).

§param_type: Option<String>

JSON-schema type ("string", "integer", "number", "boolean").

§description: Option<String>

Human-readable parameter description.

§required: bool

Whether the parameter is required.

§default: Option<Value>

Optional default value (any TOML type).

§max_length: Option<u64>

Maximum string length (string parameters only).

§minimum: Option<f64>

Inclusive minimum (integer / number parameters only).

Stored as f64. See Self::maximum for the precision limit that applies to both bounds.

§maximum: Option<f64>

Inclusive maximum (integer / number parameters only).

§Not a safe way to bound a 64-bit integer ID

Both bounds are stored as f64, so an integer magnitude above 2^53 (9007199254740992) cannot be represented exactly. 9007199254740993 written in TOML has ALREADY become 9007199254740992 by the time any code in this crate sees it, and no post-parse check can recover the fact that it was rounded. ServerConfig::validate therefore refuses a bound that is non-finite or whose magnitude EXCEEDS 2^53 (ConfigValidationError::NonFiniteParamBound) — which catches the wildly out-of-range case, and deliberately does not claim to catch a value sitting one unit past the boundary.

If you need to bound a u64 identifier, express the rule as a Self::pattern over its string form instead. This limitation is a documented one, not an oversight: adding an i64-typed bound vocabulary is out of scope for D2.

§enum_values: Option<Vec<Value>>

Closed set of allowed values (any TOML scalar).

§pattern: Option<String>

Regular expression the value must match, emitted as JSON Schema pattern (string parameters only).

§It is UNANCHORED

JSON Schema pattern is a SUBSTRING search, exactly as ECMA-262 RegExp.prototype.test is. A rule written as a bare character class such as [A-Z]{3} matches "../../etc/passwd-ABC" and therefore buys no enforcement whatsoever. Anchor every rule you mean as a whole-value rule: ^[A-Z]{3}$.

§\s and \S do not mean one thing here

Two regex engines are live inside one jsonschema 0.49.2 process, and which one evaluates your pattern depends on the pattern’s own syntax:

  • A plain pattern takes the linear-time engine, whose \s is a PARTIAL ECMA-262 set — measured as {U+0009, U+000A, U+000B, U+000C, U+000D, U+0020, U+00A0, U+2029, U+FEFF}. It does NOT include U+3000 IDEOGRAPHIC SPACE, U+0085 NEL, U+1680, U+2000, U+2007, U+2028 or U+202F, and it DOES include the byte-order mark.
  • A pattern containing a lookaround or a backreference takes the backtracking engine, where \s is exactly \p{White_Space} — so it DOES match U+3000, and does NOT match U+FEFF.

Adding a lookahead to a pattern therefore silently changes what \s means in it. For anything security-relevant, spell out an explicit character class (e.g. [^\p{White_Space}]) rather than using the shorthand.

§min_length: Option<u64>

Minimum string length in Unicode code points, emitted as JSON Schema minLength (string parameters only).

Counted in code points — not bytes and not grapheme clusters — matching maxLength’s unit so a min_length == max_length pair names exactly one length.

§format: Option<String>

JSON Schema format assertion, e.g. "uuid", "email", "date-time".

§It IS enforced on inputs in this SDK

format is ANNOTATIVE by default in jsonschema 0.49 — a bare draft202012 validator accepts "!!!not-a-uuid!!!" against format = "uuid". Declared inputs do not take that path: core pmcp compiles a tool’s inputSchema through a format-ASSERTING builder (Phase 128, Q1), so a declared format refuses a non-conforming value at tools/call time.

Measured under this workspace’s pinned jsonschema configuration (0.49, default-features = false), all NINETEEN standard Draft 2020-12 format names assert: date-time, date, time, duration, email, idn-email, hostname, idn-hostname, ipv4, ipv6, uri, uri-reference, iri, iri-reference, uuid, uri-template, json-pointer, relative-json-pointer, regex. A format name OUTSIDE that list is accepted-and-ignored, per JSON Schema’s own rule that an unknown format is an annotation — so a typo such as "uid" for "uuid" silently enforces nothing.

format is NOT enforced on OUTPUTS: structuredContent validation is deliberately annotative there, and only warns.

§items: Option<ItemsDecl>

[tools.parameters.items] — the element schema for an array parameter, emitted as JSON Schema items.

Emitted in OBJECT form only. Array-form items (the draft-07 tuple construct) does not compile under the Draft 2020-12 pin and would take the whole tool’s validator down with it.

§max_items: Option<u64>

Maximum number of array elements, emitted as JSON Schema maxItems (array parameters only).

§allow_slash: bool

Permit / inside this parameter’s value when it is interpolated into a single-call tool’s path template (Phase 128, D-11).

Path-placeholder values are refused for path separators by default, because a / in a {segment} lets a caller reshape the request target. This per-parameter opt-in is the ONLY legitimate source of that permission — it exists for the genuine case of a parameter that names a multi-segment resource path.

An OpenAPI spec’s allowReserved must NEVER be wired to this field. That keyword describes URL percent-encoding latitude in the spec author’s serialization rules; it is not a statement that the value may restructure the path, and treating it as one would turn a routine spec detail into a silent path-traversal opening.

Trait Implementations§

Source§

impl Clone for ParamDecl

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParamDecl

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ParamDecl

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ParamDecl

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ParamDecl

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ParamDecl

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ParamDecl

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Send for T
where T: ?Sized,

Source§

impl<T> Sync for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more