Creates a callback function that validates tool calls against workflow job definitions. The validation tool tracks which jobs have been completed and warns (or rejects) when tools are called out of expected order or when job dependencies are not met.
Arguments
- workflow
A MCP workflow object
- strict
Logical. If
TRUE, reject out-of-order tool calls viatool_reject. IfFALSE(default), only warn viacli_warn.- verbose
Logical. If
TRUE(default), print progress messages when jobs and steps are detected.
Value
A list with two callback functions:
on_tool_requestCallback for
chat$on_tool_request()on_tool_resultCallback for
chat$on_tool_result()stateAn environment containing execution state (for inspection)
Details
The validation tool maintains state about which jobs have been started/completed based on tool calls observed. It checks:
Whether the tool being called matches expected job steps
Whether job dependencies (
needs) are satisfiedStep execution order within jobs
Examples
wf <- mcpflow_read("ravepipeline::rave_pipeline_class_guide")
validator <- mcpflow_job_validator(wf, strict = FALSE)
if (FALSE) { # \dontrun{
chat <- ellmer::chat_ollama()
chat$on_tool_request(validator$on_tool_request)
chat$on_tool_result(validator$on_tool_result)
} # }