assay_core/mcp/tool_call_handler/
mod.rs1mod emit;
8mod evaluate;
9mod evaluate_next;
10mod types;
11
12pub use types::{HandleResult, ToolCallHandler, ToolCallHandlerConfig};
13
14use super::decision::DecisionEmitter;
15use super::identity::ToolIdentity;
16use super::jsonrpc::JsonRpcRequest;
17use super::lifecycle::LifecycleEmitter;
18use super::policy::{McpPolicy, PolicyState};
19use crate::runtime::{Authorizer, MandateData};
20use serde_json::Value;
21use std::sync::Arc;
22
23impl ToolCallHandler {
24 pub fn new(
26 policy: McpPolicy,
27 authorizer: Option<Authorizer>,
28 emitter: Arc<dyn DecisionEmitter>,
29 config: ToolCallHandlerConfig,
30 ) -> Self {
31 types::new_handler(policy, authorizer, emitter, config)
32 }
33
34 pub fn with_lifecycle_emitter(self, emitter: Arc<dyn LifecycleEmitter>) -> Self {
36 types::with_lifecycle_emitter(self, emitter)
37 }
38
39 pub fn handle_tool_call(
44 &self,
45 request: &JsonRpcRequest,
46 state: &mut PolicyState,
47 runtime_identity: Option<&ToolIdentity>,
48 mandate: Option<&MandateData>,
49 transaction_object: Option<&Value>,
50 ) -> HandleResult {
51 evaluate::handle_tool_call(
52 self,
53 request,
54 state,
55 runtime_identity,
56 mandate,
57 transaction_object,
58 )
59 }
60}
61
62#[cfg(test)]
63mod tests;