Overview
When an LLM returns tool calls in its response, Bifrost does not automatically execute them. Instead, your application explicitly calls the tool execution API, giving you full control over:- Which tool calls to execute
- User approval workflows
- Security validation
- Audit logging
Authentication
The/v1/mcp/tool/execute endpoint uses the same authentication as other inference endpoints like /v1/chat/completions:
Virtual keys and authentication are independent layers that work together. For details on how to use virtual keys with authentication, see Authentication and Virtual Keys.
End-to-End Example
- Gateway
- Go SDK
Step 1: Send Chat Request
Tool names are prefixed with the MCP client name (e.g.,
filesystem_list_directory). This ensures uniqueness across multiple MCP clients.Step 2: Execute the Tool
The request body matches the tool call object from the response:Step 3: Continue the Conversation
Assemble the full conversation history and continue:Response Formats
Bifrost supports two API formats for tool execution:Chat Format (Default)
Use?format=chat or omit the parameter:
Responses Format
Use?format=responses for the Responses API format:
Multiple Tool Calls
LLMs often request multiple tools in a single response. Execute them in sequence or parallel:- Sequential
- Parallel
Error Handling
Tool execution can fail for various reasons:Auth failure recovery
Inline auth-failure retry is available in Bifrost v2.0.0 and above.
- Per-user clients (
per_user_oauth,per_user_headers): Bifrost force-refreshes the caller’s credential, re-acquires a connection, and retries the same call inline, exactly once. If the retry succeeds, the caller just sees a normal success. - Shared clients (
oauth,headers): Bifrost immediately force-refreshes the credential and starts reconnecting in the background. The failing call waits briefly for that reconnect (capped by its own deadline) and retries once on the healed connection; the caller usually sees a normal success. If the reconnect doesn’t finish in time, the original error surfaces and later calls succeed once the background reconnect completes. - Safety opt-out: tools annotated as destructive and not idempotent are never retried; the reconnect still happens, but the original error always surfaces so a side effect cannot run twice.
POST /v1/mcp/tool/execute, Agent Mode tool calls, and tool calls over the MCP Gateway alike.
Copy-Pastable Responses
Tool execution responses are designed to be directly appended to your conversation history:- Correct
rolefield ("tool") - Matching
tool_call_idfor correlation - Properly formatted
content
Next Steps
Agent Mode
Enable autonomous tool execution with auto-approval
Tool Filtering
Control which tools are available per request

