MCPcopy Create free account
hub / github.com/MetapriseAI/OrgKernel / BoundedParam

Class BoundedParam

src/orgkernel/schemas/execution_token.py:51–81  ·  view source on GitHub ↗

A named tool call parameter with numeric bounds. Calls exceeding bounds are blocked at the Tool Gateway.

Source from the content-addressed store, hash-verified

49
50
51class BoundedParam(BaseModel):
52 """
53 A named tool call parameter with numeric bounds.
54 Calls exceeding bounds are blocked at the Tool Gateway.
55 """
56 model_config = {"frozen": True}
57
58 param_name: str
59 upper_bound: float | None = None
60 lower_bound: float | None = None
61 unit: str | None = None
62
63 @model_validator(mode="after")
64 def _validate_bounds(self) -> BoundedParam:
65 if (
66 self.upper_bound is not None
67 and self.lower_bound is not None
68 and self.upper_bound < self.lower_bound
69 ):
70 raise ValueError(
71 f"upper_bound ({self.upper_bound}) must be >= lower_bound ({self.lower_bound})."
72 )
73 return self
74
75 def check(self, value: float) -> bool:
76 """Return True if value is within bounds."""
77 if self.upper_bound is not None and value > self.upper_bound:
78 return False
79 if self.lower_bound is not None and value < self.lower_bound:
80 return False
81 return True
82
83
84class ScopeCheckResult(BaseModel):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected