Skip to main content

Overview

DeerFlow’s tool system is fully extensible. You can add custom tools by:
  1. Configuring built-in tools - Customize existing tools in config.yaml
  2. Creating Python tools - Write custom tool functions
  3. Using MCP servers - Integrate external tools via Model Context Protocol
Tools are the atomic actions the agent can perform. Skills provide higher-level workflows that use these tools.

Tool Architecture

Built-in Tools

DeerFlow includes several built-in tools that are always available:

present_file

Present files to the user as downloadable artifacts

ask_clarification

Ask user for clarification when information is missing

view_image

View and analyze images using vision models

skill

Load additional skills dynamically

Configuring Tools in config.yaml

Tool Groups

Organize tools into logical groups:
config.yaml

Adding Tools

Define tools using the use reflection system:
config.yaml

The use Reflection System

The use field uses Python’s reflection to dynamically load tools: Format: module.path:function_or_class_name
1

Module Path

Python module path using dot notation:
2

Separator

Colon (:) separates module from function/class:
3

Function/Class

The function or class to import:

Creating Custom Python Tools

1

Create Tool File

Create a Python file for your tool:
backend/src/tools/custom/calculator.py
Using eval() can be dangerous. This example restricts it to mathematical operations only. For production use, consider using ast.literal_eval() or a proper expression parser.
2

Add to config.yaml

Register your tool in the configuration:
config.yaml
3

Test the Tool

Restart DeerFlow and test your tool:
Ask the agent:
  • “Calculate 25 * 4”
  • “What is 100 divided by 5?”

Tool with Configuration

Create tools that accept configuration parameters:
backend/src/tools/custom/weather.py
Configure in config.yaml:
config.yaml

Sandbox-Aware Tools

Tools that interact with the filesystem should use the sandbox:
backend/src/tools/custom/file_analyzer.py
Always use sandbox methods for file operations to ensure compatibility with both local and Docker sandbox modes.

Tool Parameters and Type Hints

LangChain uses type hints and docstrings to generate tool schemas:

Environment Variables in Tools

Access environment variables securely:
Set in .env:
.env

Tool Visibility and Access Control

Control which tools are available:

Tool Groups

Restrict tools by group in skills:
SKILL.md

Conditional Tool Loading

Load tools based on configuration:
backend/src/tools/__init__.py

Testing Custom Tools

backend/tests/test_custom_tools.py
Run tests:

Debugging Tools

1

Add Logging

2

Check Tool Registration

3

Test Tool Directly

Best Practices

Write detailed docstrings explaining:
  • What the tool does
  • When to use it
  • Parameter requirements
  • Return format
The LLM uses these to decide when to call your tool.
Always handle errors gracefully:
Use type hints and validation:
  • Cache expensive operations
  • Set reasonable timeouts
  • Return early for invalid inputs
  • Use async for I/O-bound operations

Next Steps

MCP Servers

Integrate external tools via Model Context Protocol

Creating Skills

Combine tools into higher-level workflows

Configuration

Learn about tool configuration options

Examples

Browse built-in tools for reference