Overview
Grip AI’s tool system provides a unified abstraction for both built-in tools and MCP (Model Context Protocol) tools. Every tool implements theTool ABC and is registered in a central ToolRegistry.
The registry handles:
- Registration — Add/remove tools at runtime
- Schema generation — Export OpenAI function-calling definitions
- Execution dispatch — Route tool calls to the correct implementation
- Result serialization — Convert Pydantic models to JSON automatically
Tool Interface
All tools implement this abstract base class:Tool Context
Every tool execution receives aToolContext with runtime information:
extra dict can contain:
brave_api_key— For web search toolsdry_run— Skip actual execution (testing mode)trust_manager— For sandbox file access validation
Tool Registry
TheToolRegistry manages all registered tools:
Built-in Tools
Grip includes tools across multiple categories:Filesystem Tools
- read_file — Read file contents with offset/limit
- write_file — Write or overwrite file
- append_file — Append to existing file
- list_directory — List files and directories
- create_directory — Create directory tree
- delete_file — Remove file
- move_file — Move or rename file
- search_files — Glob pattern search
- grep_files — Content search with regex
Shell Tools
- execute_command — Run shell commands with timeout
- get_environment — Read environment variables
Web Tools
- fetch_url — HTTP GET with headers
- brave_search — Web search via Brave API
- scrape_page — Extract clean text from HTML
Messaging Tools
- send_message — Send text to user via channel
- send_file — Send file attachment
Orchestration Tools
- spawn_subagent — Launch parallel agent tasks
- schedule_task — Schedule cron jobs
- workflow_execute — Run multi-step workflows
Finance Tools
- stock_quote — Get stock price (requires yfinance)
- crypto_price — Get cryptocurrency price
Research Tools
- research_topic — Multi-source research with citations
- fact_check — Verify claims against sources
Code Analysis Tools
- analyze_code — Static analysis and metrics
- find_definition — Locate class/function definitions
- trace_calls — Build call graphs
Data Transform Tools
- convert_format — CSV ↔ JSON ↔ YAML conversions
- filter_data — Query JSON with JSONPath
- aggregate_data — Sum, average, group-by operations
Document Generation Tools
- generate_markdown — Create formatted markdown
- generate_pdf — Convert markdown to PDF
- generate_diagram — Create Mermaid diagrams
Email Tools
- compose_email — Draft email with template
- send_email — Send via SMTP (requires config)
Task Management Tools
- todo_write — Create and update tasks
- todo_read — List active tasks
Tool Execution Flow
1. LLM Returns Tool Calls
When the LLM decides to use tools, it returns:2. Parallel Tool Execution
The agent loop executes all tool calls in parallel:3. Tool Invocation
4. Result Scrubbing
Secrets are redacted before appending to message history:5. Loop Continues
The agent loop sends tool results back to the LLM, which can:- Return final text response (loop ends)
- Make more tool calls (loop continues)
- Hit max_tool_iterations limit (forced completion)
Creating Custom Tools
Example custom tool:MCP Tool Integration
MCP servers provide additional tools via the MCP protocol:mcp__server__tool
Tool Categories
Tools are grouped by category for system prompt generation:filesystem— File I/O operationsshell— Command executionweb— HTTP requests and scrapingmessaging— User communicationorchestration— Subagents, workflows, schedulingfinance— Stock/crypto dataresearch— Multi-source researchcode_analysis— Static analysisdata_transform— Data format conversionsdocument_gen— Document creationgeneral— Uncategorized
Configuration
Tool Result Serialization
Tools can return strings or Pydantic models:Next Steps
- Learn about Memory management
- Configure Session persistence
- Explore Agent lifecycle
- Understand Dual-engine architecture