Tools & Integrations
Tools extend agent capabilities by providing access to external services, APIs, and operations. Hive uses the Model Context Protocol (MCP) for tool integration.Tool Discovery
Tools are discovered from three sources:- MCP Servers - External tool providers (recommended)
- Built-in Tools - Framework-provided tools
- Custom Tools - Agent-specific tools in
tools.py
MCP Server Configuration
Define MCP servers inmcp_servers.json:
Server Configuration
Required fields:name- Unique server identifiertransport-"stdio"or"http"command- Command to run (for stdio)
args- Command argumentsenv- Environment variablescwd- Working directorydescription- Human-readable description
Tool Registry
TheToolRegistry manages tool discovery and execution:
Built-in Framework Tools
The framework provides core tools:File Operations
Synthetic Tools
Framework-injected tools: set_output - Set output keys (auto-generated per node):Custom Tools
Create custom tools intools.py:
Method 1: Tool Dictionary
Method 2: Decorator Pattern
Tool Discovery in Agents
Session Context for Tools
Inject context into tool calls:Execution Context (Concurrency-Safe)
For per-execution overrides:MCP Credential Management
Some MCP tools require credentials:Credential Storage
Credentials are stored in:Automatic Credential Injection
The registry automatically injects credentials for known providers:Dynamic Credential Resync
When credentials change mid-session:Tool Filtering by Provider
Filter tools by OAuth provider:Async Tools
Tools can be async:Real-World Example
Complete tool setup for a research agent:Best Practices
Use MCP for External Integrations
Use MCP for External Integrations
Prefer MCP servers over custom tools for external services. MCP provides standardized interfaces and automatic credential management.
Keep Tool Names Descriptive
Keep Tool Names Descriptive
Use clear, action-oriented names:
web_search, fetch_url, save_data. Avoid abbreviations.Validate Tool Inputs
Validate Tool Inputs
Use JSON Schema in tool parameters to validate inputs before execution.
Handle Errors Gracefully
Handle Errors Gracefully
Return
ToolResult with is_error=True and descriptive error messages. Never raise unhandled exceptions.Use Session Context for Paths
Use Session Context for Paths
Inject
data_dir via session context instead of hardcoding paths. This makes tools work across different agent instances.Next Steps
Testing Agents
Test tool integrations and agent behavior
MCP Protocol
Learn more about the Model Context Protocol