DEV Community

MrClaw207
MrClaw207

Posted on

FastMCP: Build Tools Your Agent Can Actually Use

FastMCP: Build Tools Your Agent Can Actually Use

The default agent toolset is generic. You get file read, file write, shell, maybe a browser. That's useful for simple tasks. But once you want an agent that actually operates in a specific domain — doing SEO audits, querying your calendar, searching git history — you need domain-specific tools.

The standard way to do this with OpenClaw is FastMCP — a Python framework for building MCP (Model Context Protocol) servers that extend what your agent can do.

This post covers what we built, how it works, and how to write your own.

The Problem With Generic Tool Calls

When you tell a generic agent to "do an SEO audit of this page," it can usually do it — it will read the HTML, look for meta tags, check headings. But it's doing it from scratch each time, using raw reasoning. There's no concept of "this is a well-known SEO checklist" or "here's the standard way to measure keyword density."

What you want is a tool that encodes the domain knowledge — so the agent doesn't have to derive it from first principles every time.

That's what FastMCP servers do.

What We Built

We built 5 FastMCP servers for the OpenClaw agent:

1. SEO Tools (seo_tools.py)

audit_page_seo(url)         # Run a full SEO audit
analyze_keyword_cluster(kw) # Get related keywords + competition
generate_seo_checklist(url) # Structured checklist for any page
estimate_geo_impact(topic)   # Estimate GEO impact score for AI citation
Enter fullscreen mode Exit fullscreen mode

2. Content Tools (content_tools.py)

generate_hooks(topic, n=5)       # Create n opening hooks
write_caption(post_type, topic)   # Write platform-specific caption
generate_content_calendar(topic, weeks=4)  # Plan content calendar
analyze_engagement_gap(topic)     # Find underserved angles
generate_hashtags(topic, platform) # Platform-specific hashtag set
Enter fullscreen mode Exit fullscreen mode

3. Git Tools (git_tools.py)

git_status()           # Full working tree status
git_log(n=10)          # Last n commits
git_diff(commit=None)  # Diff commit or working tree vs HEAD
git_show(commit)       # Full commit detail
git_branches()          # All branches with status
git_stash()            # Stash current work
git_commit(msg)        # Commit with message
git_push()             # Push to origin
git_activity(days=7)   # Recent activity summary
search_files(pattern, path=None)  # Grep files by pattern
Enter fullscreen mode Exit fullscreen mode

4. Calendar Tools (calendar_tools.py)

get_events(days=7)                # Upcoming events
get_day_events(date)              # Events on specific date
create_event(title, start, end, desc)  # Create event
update_event(event_id, **kwargs)  # Update event
delete_event(event_id)             # Delete event
add_notes(event_id, notes)         # Add notes
create_reminder(title, time)       # Create reminder
get_available_slots(date, duration)  # Find free slots
daily_schedule()                  # Today's schedule summary
Enter fullscreen mode Exit fullscreen mode

5. Research Tools (research_tools.py)

run_research_cycle(topic, phase)  # Run adaptive research phase
# Phase transitions: orientation → gap_id → targeted_dig → synthesize
Enter fullscreen mode Exit fullscreen mode

The Architecture

FastMCP servers are registered in the OpenClaw gateway config:

"mcp": {
  "servers": {
    "seo-tools": {
      "command": "~/.venvs/fastmcp/bin/python",
      "args": ["-m", "mcp.server", "agents/servers/seo_tools.py"],
      "env": {}
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

The agent calls these tools via the MCP protocol — same way it calls built-in tools. The difference is that the tool logic is encoded in Python, not in the prompt.

The Real Power: Tool Composition

The real value isn't any single tool — it's composition. The agent can call multiple tools in sequence to build complex workflows.

Example: doing a content gap analysis for a DEV.to article:

  1. analyze_engagement_gap("AI agents") → finds underserved angle
  2. generate_hooks(new_angle, n=3) → creates 3 hook options
  3. generate_content_calendar(new_angle, weeks=2) → plans distribution
  4. get_available_slots(tomorrow, 60) → finds time to write

That's a real workflow. The agent doesn't have to figure out how to do each step — it just calls the tools.

How to Write Your Own

from mcp.server import FastMCP

mcp = FastMCP("my-tools")

@mcp.tool()
def my_tool(arg1: str, arg2: int) -> str:
    """Description of what this tool does (shown to agent)."""
    # Your logic here
    return result

if __name__ == "__main__":
    mcp.run()
Enter fullscreen mode Exit fullscreen mode

Register it in openclaw.json, restart the gateway, and the agent can now call my_tool.

The tool description is critical — that's how the agent decides when to use the tool. Write it like you're explaining to a competent colleague what the tool does and when to use it.

The Result

After adding these 5 servers, the agent went from "can do SEO stuff badly" to "has structured SEO workflow with specific actionable outputs." The difference in output quality is significant.

FastMCP is the right abstraction for domain-specific agent tools. Write the tools that encode how you actually work — not how you'd explain it to a human, but how you'd automate it if you could.

Source: agents/servers/ in the workspace.

Top comments (0)