Install each parsed [`ToolSpec`] into `session`. `mcp` specs are registered and connected via the existing `add_mcp_server` path, so their tools land as `mcp__ __ ` and are gated by the session's permission policy like any other tool. Connection is fallible and surfaces here (e.g. a missing `command` binary), so a misconfigured tool fails at serve startup rather than silently at first
(session: &AgentSession, specs: &[ToolSpec])
| 29 | /// bounded by the spec's pinned (fail-closed) allow-list and the QuickJS sandbox |
| 30 | /// rather than the session permission policy — see [`AgentDirScriptTool`]. |
| 31 | pub async fn install_agent_dir_tools(session: &AgentSession, specs: &[ToolSpec]) -> Result<()> { |
| 32 | for spec in specs { |
| 33 | match spec { |
| 34 | ToolSpec::Mcp(config) => { |
| 35 | session.add_mcp_server(config.clone()).await?; |
| 36 | } |
| 37 | ToolSpec::Script(script) => { |
| 38 | let registry = Arc::clone(session.tool_executor().registry()); |
| 39 | let tool = Arc::new(AgentDirScriptTool::new(script.clone(), registry)); |
| 40 | session.tool_executor().register_dynamic_tool(tool); |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | Ok(()) |
| 45 | } |
| 46 | |
| 47 | #[cfg(test)] |
| 48 | mod tests { |