MCPcopy Index your code
hub / github.com/AI45Lab/Code / install_agent_dir_tools

Function install_agent_dir_tools

core/src/serve/tools.rs:31–45  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

29/// bounded by the spec's pinned (fail-closed) allow-list and the QuickJS sandbox
30/// rather than the session permission policy — see [`AgentDirScriptTool`].
31pub 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)]
48mod tests {

Calls 5

registryMethod · 0.80
tool_executorMethod · 0.80
register_dynamic_toolMethod · 0.80
add_mcp_serverMethod · 0.45
cloneMethod · 0.45