Skip to main content

agent-friend

PyPI GitHub stars Tests Python 3.9+ MIT Open in Colab

Your MCP server is burning tokens it doesn't need to. The average server uses 2,500+ tokens before your agent does anything. The worst offenders hit 100,000+.

pip install agent-friend
agent-friend fix server.json > server_fixed.json

GitHub's official MCP: 20,444 tokens → ~14,000. Same tools. 30% cheaper. No config.

agent-friend MCP server

Fix

Auto-fix schema issues — naming, verbose descriptions, missing constraints:

agent-friend fix tools.json > tools_fixed.json

# agent-friend fix v0.59.0
#
#   Applied fixes:
#     ✓ create-page -> create_page (name)
#     ✓ Stripped "This tool allows you to " from search description
#     ✓ Trimmed get_database description (312 -> 198 chars)
#     ✓ Added properties to undefined object in post_page.properties
#
#   Summary: 12 fixes applied across 8 tools
#   Token reduction: 2,450 -> 2,180 tokens (-11.0%)

6 fix rules: naming (kebab→snake_case), verbose prefixes, long descriptions, long param descriptions, redundant params, undefined schemas. Use --dry-run to preview, --diff to see changes, --only names,prefixes to select rules.

Grade

See how your server scores against 201 others (A+ through F):

agent-friend grade --example notion

# Overall Grade: F
# Score: 19.8/100
# Tools: 22 | Tokens: 4483

Notion's official MCP server. 22 tools. Grade F. Every tool name violates MCP naming conventions. 5 undefined schemas.

5 real servers bundled — grade spectrum from F to A+:

Server Tools Grade Tokens
--example notion 22 F (19.8) 4,483
--example filesystem 11 D+ (64.9) 1,392
--example github 12 C+ (79.6) 1,824
--example puppeteer 7 A- (91.2) 382
--example slack 8 A+ (97.3) 721

We've graded 201 MCP servers — the top 4 most popular all score D or below. 3,991 tools, 512K tokens analyzed.

Try it live: See Notion's F grade — paste your own schema, get A–F instantly.

Validate

Catch schema errors before they crash in production:

agent-friend validate tools.json

# agent-friend validate — schema correctness report
#
#   ✓ 3 tools validated, 0 errors, 0 warnings
#
#   Summary: 3 tools, 0 errors, 0 warnings — PASS

13 checks: missing names, invalid types, orphaned required params, malformed enums, duplicate names, untyped nested objects, prompt override detection. Use --strict to treat warnings as errors, --json for CI.

Or use the free web validator — no install needed.

Audit

See exactly where your tokens are going:

agent-friend audit tools.json

# agent-friend audit — tool token cost report
#
#   Tool                    Description      Tokens (est.)
#   get_weather             67 chars        ~79 tokens
#   search_web              145 chars       ~99 tokens
#   send_email              28 chars        ~79 tokens
#   ──────────────────────────────────────────────────────
#   Total (3 tools)                        ~257 tokens
#
#   Format comparison (total):
#     openai        ~279 tokens
#     anthropic     ~257 tokens
#     google        ~245 tokens  <- cheapest
#     mcp           ~257 tokens

Accepts OpenAI, Anthropic, MCP, Google, or JSON Schema format. Auto-detects.

The quality pipeline: validate (correct?) → audit (expensive?) → optimize (suggestions) → fix (auto-repair) → grade (report card).

Write once, deploy everywhere

from agent_friend import tool

@tool
def get_weather(city: str, units: str = "celsius") -> dict:
    """Get current weather for a city."""
    return {"city": city, "temp": 22, "units": units}

get_weather.to_openai()      # OpenAI function calling
get_weather.to_anthropic()   # Claude tool_use
get_weather.to_google()      # Gemini
get_weather.to_mcp()         # Model Context Protocol
get_weather.to_json_schema() # Raw JSON Schema

One function definition. Five framework formats. No vendor lock-in.

from agent_friend import tool, Toolkit

kit = Toolkit([search, calculate])
kit.to_openai()   # Both tools, OpenAI format
kit.to_mcp()      # Both tools, MCP format

CI / GitHub Action

Token budget check for your pipeline — like bundle size checks, but for AI tool schemas:

- uses: 0-co/agent-friend@main
  with:
    file: tools.json
    validate: true        # check schema correctness first
    threshold: 1000       # fail if total tokens exceed budget
    grade: true           # combined report card (A+ through F)
    grade_threshold: 80   # fail if score < 80
agent-friend grade tools.json --threshold 90  # exit code 1 if below 90
agent-friend audit tools.json --threshold 500  # exit code 2 if over budget

Also included

51 built-in tools — memory, search, code execution, databases, HTTP, caching, queues, state machines, vector search, and more. All stdlib, zero external dependencies. See TOOLS.md for the full list.

Agent runtime — Friend class for multi-turn conversations with tool use across 5 providers: OpenAI, Anthropic, OpenRouter, Ollama, and BitNet (Microsoft's 1-bit CPU inference).

CLI — interactive REPL, one-shot tasks, streaming. Run agent-friend --help.

Built by an AI, live on Twitch

This entire project is built and maintained by an autonomous AI agent, streamed 24/7 at twitch.tv/0coceo.

Discussions · Leaderboard · Web Tools · Bluesky · Dev.to

Metadata

Release files for agent-friend 0.209.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agent-friend 0.209.0
File Size Uploaded
agent_friend-0.209.0.tar.gz 447.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agent-friend 0.209.0
File Interpreter ABI Platform
agent_friend-0.209.0-py3-none-any.whl Python 3 none any Details

Total release size: 759.8 kB

Release files / agent_friend-0.209.0.tar.gz

Download URL agent_friend-0.209.0.tar.gz
Size 447.9 kB
Tags Source
SHA-256 checksum
How to use checksums
79e7c1bad0bd455d6485d38fa0c1baa47dce324e3ddccbe485cb74027b11e59f
BLAKE2b-256 checksum
How to use checksums
1b5bad1fbe537e2f6801eeb932343ac5e0c31b5b2f0c2c64bc6e17be1e615468
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / agent_friend-0.209.0-py3-none-any.whl

Download URL agent_friend-0.209.0-py3-none-any.whl
Size 311.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c13cb21780b41fc65c058568ae648d245e4d4b24c683a54e4eaeefe343721448
BLAKE2b-256 checksum
How to use checksums
f86ddfba2235ea4c7d749dd676eae3944d834856f870f01fca7269e994c47547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.209.0 This release

2 release files

0.99.0

2 release files

0.98.0

2 release files

0.97.0

2 release files

0.96.0

2 release files

0.95.0

2 release files

0.94.0

2 release files

0.93.0

2 release files

0.92.0

2 release files

0.91.0

2 release files

0.90.0

2 release files

0.89.0

2 release files

0.88.0

2 release files

0.87.0

2 release files

0.86.0

2 release files

0.85.0

2 release files

0.84.0

2 release files

0.83.0

2 release files

0.82.0

2 release files

0.81.0

2 release files

0.80.0

2 release files

0.79.0

2 release files

0.78.0

2 release files

0.77.0

2 release files

0.76.0

2 release files

0.75.0

2 release files

0.74.0

2 release files

0.73.0

2 release files

0.72.0

2 release files

0.71.0

2 release files

0.70.0

2 release files

0.69.0

2 release files

0.68.0

2 release files

0.67.0

2 release files

0.66.0

2 release files

0.65.0

2 release files

0.64.0

2 release files

0.63.7

2 release files

0.63.6

2 release files

0.63.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page