Skip to main content

call_tool

Function call_tool 

Source
pub async fn call_tool(
    proxy_url: &str,
    tool_name: &str,
    args: &HashMap<String, Value>,
    raw_args: Option<&[String]>,
    token_env: Option<&str>,
    override_mcp_url: Option<&str>,
) -> Result<Value, ProxyError>
Expand description

Execute a tool call via the proxy server.

POST {proxy_url}/call with JSON body: { tool_name, args } Scopes are carried inside the JWT — not in the request body.

args carries key-value pairs for HTTP/MCP tools. raw_args, if provided, is sent as an array in the args field for CLI tools.

token_env selects which sandbox env var holds the bearer to send. None uses the default ATI_SESSION_TOKEN (back-compat with every caller before issue #121); Some("PARCHA_TOOLS_SESSION_TOKEN") reads that env var instead, falling back to the default if it’s unset. The caller normally derives this from the target provider’s auth_session_token_env field in the manifest.

override_mcp_url is sent as an X-Ati-Upstream-Url header for the proxy to honour as the MCP upstream URL for this request (issue #124). The proxy validates against an operator-declared glob allowlist before dialling. Caller normally derives this from the target provider’s mcp_url_env field — empty/unset stays None, falls through to the proxy’s static mcp_url resolution.