Skip to main content
This feature is only available when using Bifrost as a Go SDK. It is not available in the Gateway deployment.

Overview

Tool Hosting allows you to register custom tools directly within your Go application. These tools run in-process with zero network overhead, making them ideal for:
  • Application-specific business logic
  • High-performance operations
  • Testing and development
  • Tools that need access to application state
Bifrost automatically creates an internal MCP server (bifrostInternal) when you register your first tool.

Basic Usage

Step 1: Define Your Tool Schema

Create a schema that describes your tool’s parameters:

Step 2: Implement the Handler

Create a function that handles tool execution:

Step 3: Register the Tool

Register your tool with Bifrost:

Complete Example

Here’s a complete example with multiple tools:

Typed Handlers

For better type safety, use typed structs with JSON marshaling:

Tool Naming

Tool names from RegisterMCPTool are prefixed with bifrostInternal_ when exposed to LLMs: This prevents naming conflicts with tools from external MCP servers.

Error Handling

Return errors from your handler to indicate tool execution failures:
Errors are returned to the LLM as tool error messages, allowing it to handle the failure gracefully.

Accessing Application State

Since tools run in-process, they can access your application’s state:

Best Practices

Always validate arguments before processing:
Return JSON for complex responses:
Use context for long-running operations:
Add logging for troubleshooting:

Comparison with External MCP Servers


Next Steps

Tool Execution

Learn how tool execution works

Agent Mode

Enable auto-execution for hosted tools