agent-friend 0.63.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_friend-0.63.5/LICENSE +21 -0
- agent_friend-0.63.5/PKG-INFO +268 -0
- agent_friend-0.63.5/README.md +244 -0
- agent_friend-0.63.5/agent_friend/__init__.py +61 -0
- agent_friend-0.63.5/agent_friend/__main__.py +9 -0
- agent_friend-0.63.5/agent_friend/audit.py +336 -0
- agent_friend-0.63.5/agent_friend/cli.py +643 -0
- agent_friend-0.63.5/agent_friend/config.py +200 -0
- agent_friend-0.63.5/agent_friend/examples/__init__.py +81 -0
- agent_friend-0.63.5/agent_friend/examples/filesystem.json +191 -0
- agent_friend-0.63.5/agent_friend/examples/github.json +400 -0
- agent_friend-0.63.5/agent_friend/examples/notion.json +732 -0
- agent_friend-0.63.5/agent_friend/examples/puppeteer.json +118 -0
- agent_friend-0.63.5/agent_friend/examples/slack.json +151 -0
- agent_friend-0.63.5/agent_friend/fix.py +742 -0
- agent_friend-0.63.5/agent_friend/friend.py +627 -0
- agent_friend-0.63.5/agent_friend/grade.py +413 -0
- agent_friend-0.63.5/agent_friend/leaderboard_data.py +231 -0
- agent_friend-0.63.5/agent_friend/mcp_server.py +312 -0
- agent_friend-0.63.5/agent_friend/optimize.py +612 -0
- agent_friend-0.63.5/agent_friend/providers/__init__.py +9 -0
- agent_friend-0.63.5/agent_friend/providers/anthropic.py +116 -0
- agent_friend-0.63.5/agent_friend/providers/base.py +64 -0
- agent_friend-0.63.5/agent_friend/providers/bitnet.py +60 -0
- agent_friend-0.63.5/agent_friend/providers/ollama.py +58 -0
- agent_friend-0.63.5/agent_friend/providers/openai.py +142 -0
- agent_friend-0.63.5/agent_friend/providers/openrouter.py +63 -0
- agent_friend-0.63.5/agent_friend/toolkit.py +151 -0
- agent_friend-0.63.5/agent_friend/tools/__init__.py +56 -0
- agent_friend-0.63.5/agent_friend/tools/alert_tool.py +452 -0
- agent_friend-0.63.5/agent_friend/tools/audit_tool.py +467 -0
- agent_friend-0.63.5/agent_friend/tools/base.py +182 -0
- agent_friend-0.63.5/agent_friend/tools/batch_tool.py +598 -0
- agent_friend-0.63.5/agent_friend/tools/browser.py +98 -0
- agent_friend-0.63.5/agent_friend/tools/cache.py +269 -0
- agent_friend-0.63.5/agent_friend/tools/chunker.py +361 -0
- agent_friend-0.63.5/agent_friend/tools/code.py +130 -0
- agent_friend-0.63.5/agent_friend/tools/config_tool.py +420 -0
- agent_friend-0.63.5/agent_friend/tools/crypto.py +341 -0
- agent_friend-0.63.5/agent_friend/tools/database.py +231 -0
- agent_friend-0.63.5/agent_friend/tools/datetime_tool.py +389 -0
- agent_friend-0.63.5/agent_friend/tools/diff.py +355 -0
- agent_friend-0.63.5/agent_friend/tools/email.py +306 -0
- agent_friend-0.63.5/agent_friend/tools/env.py +310 -0
- agent_friend-0.63.5/agent_friend/tools/event_bus.py +316 -0
- agent_friend-0.63.5/agent_friend/tools/fetch.py +164 -0
- agent_friend-0.63.5/agent_friend/tools/file.py +217 -0
- agent_friend-0.63.5/agent_friend/tools/format_tool.py +559 -0
- agent_friend-0.63.5/agent_friend/tools/function_tool.py +290 -0
- agent_friend-0.63.5/agent_friend/tools/git.py +257 -0
- agent_friend-0.63.5/agent_friend/tools/graph.py +561 -0
- agent_friend-0.63.5/agent_friend/tools/html_tool.py +526 -0
- agent_friend-0.63.5/agent_friend/tools/http.py +171 -0
- agent_friend-0.63.5/agent_friend/tools/json_tool.py +317 -0
- agent_friend-0.63.5/agent_friend/tools/lock_tool.py +384 -0
- agent_friend-0.63.5/agent_friend/tools/map_reduce.py +534 -0
- agent_friend-0.63.5/agent_friend/tools/memory.py +188 -0
- agent_friend-0.63.5/agent_friend/tools/metrics.py +410 -0
- agent_friend-0.63.5/agent_friend/tools/notify.py +289 -0
- agent_friend-0.63.5/agent_friend/tools/process.py +346 -0
- agent_friend-0.63.5/agent_friend/tools/queue_tool.py +437 -0
- agent_friend-0.63.5/agent_friend/tools/rate_limit.py +489 -0
- agent_friend-0.63.5/agent_friend/tools/regex_tool.py +441 -0
- agent_friend-0.63.5/agent_friend/tools/retry.py +580 -0
- agent_friend-0.63.5/agent_friend/tools/rss.py +347 -0
- agent_friend-0.63.5/agent_friend/tools/sampler.py +417 -0
- agent_friend-0.63.5/agent_friend/tools/scheduler.py +389 -0
- agent_friend-0.63.5/agent_friend/tools/search.py +194 -0
- agent_friend-0.63.5/agent_friend/tools/search_index.py +433 -0
- agent_friend-0.63.5/agent_friend/tools/state_machine.py +439 -0
- agent_friend-0.63.5/agent_friend/tools/stats_tool.py +505 -0
- agent_friend-0.63.5/agent_friend/tools/table.py +420 -0
- agent_friend-0.63.5/agent_friend/tools/template.py +353 -0
- agent_friend-0.63.5/agent_friend/tools/timer_tool.py +390 -0
- agent_friend-0.63.5/agent_friend/tools/transform_tool.py +446 -0
- agent_friend-0.63.5/agent_friend/tools/validator.py +511 -0
- agent_friend-0.63.5/agent_friend/tools/vector_store.py +388 -0
- agent_friend-0.63.5/agent_friend/tools/voice.py +249 -0
- agent_friend-0.63.5/agent_friend/tools/webhook.py +200 -0
- agent_friend-0.63.5/agent_friend/tools/workflow_tool.py +620 -0
- agent_friend-0.63.5/agent_friend/tools/xml_tool.py +352 -0
- agent_friend-0.63.5/agent_friend/validate.py +702 -0
- agent_friend-0.63.5/agent_friend.egg-info/PKG-INFO +268 -0
- agent_friend-0.63.5/agent_friend.egg-info/SOURCES.txt +149 -0
- agent_friend-0.63.5/agent_friend.egg-info/dependency_links.txt +1 -0
- agent_friend-0.63.5/agent_friend.egg-info/entry_points.txt +3 -0
- agent_friend-0.63.5/agent_friend.egg-info/requires.txt +17 -0
- agent_friend-0.63.5/agent_friend.egg-info/top_level.txt +1 -0
- agent_friend-0.63.5/pyproject.toml +36 -0
- agent_friend-0.63.5/setup.cfg +4 -0
- agent_friend-0.63.5/tests/test_adapters.py +608 -0
- agent_friend-0.63.5/tests/test_alert_tool.py +440 -0
- agent_friend-0.63.5/tests/test_audit_cli.py +762 -0
- agent_friend-0.63.5/tests/test_audit_tool.py +369 -0
- agent_friend-0.63.5/tests/test_batch_tool.py +390 -0
- agent_friend-0.63.5/tests/test_bitnet_provider.py +129 -0
- agent_friend-0.63.5/tests/test_cache_tool.py +218 -0
- agent_friend-0.63.5/tests/test_chunker_tool.py +322 -0
- agent_friend-0.63.5/tests/test_config.py +215 -0
- agent_friend-0.63.5/tests/test_config_tool.py +426 -0
- agent_friend-0.63.5/tests/test_crypto_tool.py +339 -0
- agent_friend-0.63.5/tests/test_database_tool.py +285 -0
- agent_friend-0.63.5/tests/test_datetime_tool.py +274 -0
- agent_friend-0.63.5/tests/test_diff_tool.py +267 -0
- agent_friend-0.63.5/tests/test_email_tool.py +201 -0
- agent_friend-0.63.5/tests/test_env_tool.py +294 -0
- agent_friend-0.63.5/tests/test_event_bus_tool.py +330 -0
- agent_friend-0.63.5/tests/test_examples.py +452 -0
- agent_friend-0.63.5/tests/test_fetch_tool.py +210 -0
- agent_friend-0.63.5/tests/test_file_tool.py +167 -0
- agent_friend-0.63.5/tests/test_fix.py +1381 -0
- agent_friend-0.63.5/tests/test_format_tool.py +458 -0
- agent_friend-0.63.5/tests/test_friend.py +407 -0
- agent_friend-0.63.5/tests/test_function_tool.py +304 -0
- agent_friend-0.63.5/tests/test_git_tool.py +265 -0
- agent_friend-0.63.5/tests/test_grade.py +646 -0
- agent_friend-0.63.5/tests/test_graph_tool.py +438 -0
- agent_friend-0.63.5/tests/test_html_tool.py +372 -0
- agent_friend-0.63.5/tests/test_http_tool.py +350 -0
- agent_friend-0.63.5/tests/test_json_tool.py +202 -0
- agent_friend-0.63.5/tests/test_leaderboard_data.py +103 -0
- agent_friend-0.63.5/tests/test_lock_tool.py +305 -0
- agent_friend-0.63.5/tests/test_map_reduce_tool.py +440 -0
- agent_friend-0.63.5/tests/test_metrics_tool.py +358 -0
- agent_friend-0.63.5/tests/test_notify_tool.py +182 -0
- agent_friend-0.63.5/tests/test_optimize.py +974 -0
- agent_friend-0.63.5/tests/test_process_tool.py +302 -0
- agent_friend-0.63.5/tests/test_providers.py +540 -0
- agent_friend-0.63.5/tests/test_queue_tool.py +332 -0
- agent_friend-0.63.5/tests/test_rate_limit_tool.py +373 -0
- agent_friend-0.63.5/tests/test_regex_tool.py +387 -0
- agent_friend-0.63.5/tests/test_retry_tool.py +502 -0
- agent_friend-0.63.5/tests/test_rss_tool.py +331 -0
- agent_friend-0.63.5/tests/test_sampler_tool.py +343 -0
- agent_friend-0.63.5/tests/test_scheduler.py +379 -0
- agent_friend-0.63.5/tests/test_search_index_tool.py +344 -0
- agent_friend-0.63.5/tests/test_state_machine_tool.py +380 -0
- agent_friend-0.63.5/tests/test_stats_tool.py +417 -0
- agent_friend-0.63.5/tests/test_table_tool.py +412 -0
- agent_friend-0.63.5/tests/test_template_tool.py +278 -0
- agent_friend-0.63.5/tests/test_timer_tool.py +321 -0
- agent_friend-0.63.5/tests/test_token_estimate.py +337 -0
- agent_friend-0.63.5/tests/test_tools.py +360 -0
- agent_friend-0.63.5/tests/test_transform_tool.py +449 -0
- agent_friend-0.63.5/tests/test_validate.py +1725 -0
- agent_friend-0.63.5/tests/test_validator_tool.py +416 -0
- agent_friend-0.63.5/tests/test_vector_store_tool.py +356 -0
- agent_friend-0.63.5/tests/test_voice_tool.py +344 -0
- agent_friend-0.63.5/tests/test_webhook_tool.py +521 -0
- agent_friend-0.63.5/tests/test_workflow_tool.py +459 -0
- agent_friend-0.63.5/tests/test_xml_tool.py +340 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 0-co
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agent-friend
|
|
3
|
+
Version: 0.63.5
|
|
4
|
+
Summary: MCP schema linter & quality grader — validate, audit, optimize, grade (A+ to F). Also: @tool exports to OpenAI, Claude, Gemini, MCP.
|
|
5
|
+
License: MIT
|
|
6
|
+
Project-URL: Homepage, https://github.com/0-co/agent-friend
|
|
7
|
+
Project-URL: Source, https://github.com/0-co/agent-friend
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/0-co/agent-friend/issues
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Requires-Dist: mcp>=1.0; python_version >= "3.10"
|
|
13
|
+
Provides-Extra: anthropic
|
|
14
|
+
Requires-Dist: anthropic>=0.40.0; extra == "anthropic"
|
|
15
|
+
Provides-Extra: openai
|
|
16
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
17
|
+
Provides-Extra: yaml
|
|
18
|
+
Requires-Dist: pyyaml>=6.0; extra == "yaml"
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: anthropic>=0.40.0; extra == "all"
|
|
21
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
22
|
+
Requires-Dist: pyyaml>=6.0; extra == "all"
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
|
|
25
|
+
# agent-friend
|
|
26
|
+
|
|
27
|
+
[](https://github.com/0-co/agent-friend/stargazers) [](https://github.com/0-co/agent-friend/actions/workflows/tests.yml)   [](https://colab.research.google.com/github/0-co/agent-friend/blob/main/demo.ipynb)
|
|
28
|
+
|
|
29
|
+
**The quality linter for MCP tool schemas.** Validate, audit, optimize, fix, and grade (A+ through F). Like ESLint for MCP. Also: write a tool once, export to OpenAI, Claude, Gemini, or MCP.
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from agent_friend import tool
|
|
33
|
+
|
|
34
|
+
@tool
|
|
35
|
+
def get_weather(city: str, units: str = "celsius") -> dict:
|
|
36
|
+
"""Get current weather for a city."""
|
|
37
|
+
return {"city": city, "temp": 22, "units": units}
|
|
38
|
+
|
|
39
|
+
get_weather.to_openai() # OpenAI function calling
|
|
40
|
+
get_weather.to_anthropic() # Claude tool_use
|
|
41
|
+
get_weather.to_google() # Gemini
|
|
42
|
+
get_weather.to_mcp() # Model Context Protocol
|
|
43
|
+
get_weather.to_json_schema() # Raw JSON Schema
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
One function definition. Five framework formats. No vendor lock-in.
|
|
47
|
+
|
|
48
|
+
[](https://glama.ai/mcp/servers/0-co/agent-friend)
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install git+https://github.com/0-co/agent-friend.git
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Grade a real MCP server (no API key, no schema file)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
agent-friend grade --example notion
|
|
60
|
+
|
|
61
|
+
# Overall Grade: F
|
|
62
|
+
# Score: 19.8/100
|
|
63
|
+
# Tools: 22 | Tokens: 4483
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Notion's official MCP server. 22 tools. Grade F. Every tool name violates MCP naming conventions. 5 undefined schemas.
|
|
67
|
+
|
|
68
|
+
5 real servers bundled — grade spectrum from F to A+:
|
|
69
|
+
|
|
70
|
+
| Server | Tools | Grade | Tokens |
|
|
71
|
+
|--------|-------|-------|--------|
|
|
72
|
+
| `--example notion` | 22 | F (19.8) | 4,483 |
|
|
73
|
+
| `--example filesystem` | 11 | D+ (64.9) | 1,392 |
|
|
74
|
+
| `--example github` | 12 | C+ (79.6) | 1,824 |
|
|
75
|
+
| `--example puppeteer` | 7 | A- (91.2) | 382 |
|
|
76
|
+
| `--example slack` | 8 | A+ (97.3) | 721 |
|
|
77
|
+
|
|
78
|
+
We've graded [50 MCP servers](https://0-co.github.io/company/leaderboard.html) — the top 4 most popular (Context7, Blender, Chrome DevTools, GitHub Official) all score D or below. 1,044 tools, 193K tokens analyzed.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
agent-friend examples # list all bundled schemas
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Or open the [Colab notebook](https://colab.research.google.com/github/0-co/agent-friend/blob/main/demo.ipynb) — 51 tool demos in the browser.
|
|
85
|
+
|
|
86
|
+
## Batch export
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from agent_friend import tool, Toolkit
|
|
90
|
+
|
|
91
|
+
@tool
|
|
92
|
+
def search(query: str) -> str: ...
|
|
93
|
+
|
|
94
|
+
@tool
|
|
95
|
+
def calculate(expr: str) -> float: ...
|
|
96
|
+
|
|
97
|
+
kit = Toolkit([search, calculate])
|
|
98
|
+
kit.to_openai() # Both tools, OpenAI format
|
|
99
|
+
kit.to_mcp() # Both tools, MCP format
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Context budget
|
|
103
|
+
|
|
104
|
+
MCP tool definitions can eat 40-50K tokens per request. Audit your tools from the CLI:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
agent-friend audit tools.json
|
|
108
|
+
|
|
109
|
+
# agent-friend audit — tool token cost report
|
|
110
|
+
#
|
|
111
|
+
# Tool Description Tokens (est.)
|
|
112
|
+
# get_weather 67 chars ~79 tokens
|
|
113
|
+
# search_web 145 chars ~99 tokens
|
|
114
|
+
# send_email 28 chars ~79 tokens
|
|
115
|
+
# ──────────────────────────────────────────────────────
|
|
116
|
+
# Total (3 tools) ~257 tokens
|
|
117
|
+
#
|
|
118
|
+
# Format comparison (total):
|
|
119
|
+
# openai ~279 tokens
|
|
120
|
+
# anthropic ~257 tokens
|
|
121
|
+
# google ~245 tokens <- cheapest
|
|
122
|
+
# mcp ~257 tokens
|
|
123
|
+
# json_schema ~245 tokens
|
|
124
|
+
#
|
|
125
|
+
# Context window impact:
|
|
126
|
+
# GPT-4o (128K) ~0.2%
|
|
127
|
+
# Claude (200K) ~0.1%
|
|
128
|
+
# GPT-4 (8K) ~3.1% <- check your budget
|
|
129
|
+
# Gemini 2.0 (1M) ~0.0%
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Or measure programmatically:
|
|
133
|
+
|
|
134
|
+
```python
|
|
135
|
+
kit = Toolkit([search, calculate])
|
|
136
|
+
kit.token_report()
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Accepts OpenAI, Anthropic, MCP, Google, or JSON Schema format. Auto-detects.
|
|
140
|
+
|
|
141
|
+
## Optimize
|
|
142
|
+
|
|
143
|
+
Found the bloat? Fix it:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
agent-friend optimize tools.json
|
|
147
|
+
|
|
148
|
+
# Tool: search_inventory
|
|
149
|
+
# ⚡ Description prefix: "This tool allows you to search..." → "Search..."
|
|
150
|
+
# Saves ~6 tokens
|
|
151
|
+
# ⚡ Parameter 'query': description "The query" restates parameter name
|
|
152
|
+
# Saves ~3 tokens
|
|
153
|
+
#
|
|
154
|
+
# Summary: 5 suggestions, ~42 tokens saved (21% reduction)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
7 heuristic rules: verbose prefixes, long descriptions, redundant params, missing descriptions, cross-tool duplicates, deep nesting. Machine-readable output with `--json`.
|
|
158
|
+
|
|
159
|
+
## Validate
|
|
160
|
+
|
|
161
|
+
Catch schema errors before they crash in production:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
agent-friend validate tools.json
|
|
165
|
+
|
|
166
|
+
# agent-friend validate — schema correctness report
|
|
167
|
+
#
|
|
168
|
+
# ✓ 3 tools validated, 0 errors, 0 warnings
|
|
169
|
+
#
|
|
170
|
+
# Summary: 3 tools, 0 errors, 0 warnings — PASS
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
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.
|
|
174
|
+
|
|
175
|
+
Or use the [free web validator](https://0-co.github.io/company/validate.html) — paste schemas, get instant results, no install needed.
|
|
176
|
+
|
|
177
|
+
## Fix
|
|
178
|
+
|
|
179
|
+
Found issues? Auto-fix them:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
agent-friend fix tools.json > tools_fixed.json
|
|
183
|
+
|
|
184
|
+
# agent-friend fix v0.59.0
|
|
185
|
+
#
|
|
186
|
+
# Applied fixes:
|
|
187
|
+
# ✓ create-page -> create_page (name)
|
|
188
|
+
# ✓ Stripped "This tool allows you to " from search description
|
|
189
|
+
# ✓ Trimmed get_database description (312 -> 198 chars)
|
|
190
|
+
# ✓ Added properties to undefined object in post_page.properties
|
|
191
|
+
#
|
|
192
|
+
# Summary: 12 fixes applied across 8 tools
|
|
193
|
+
# Token reduction: 2,450 -> 2,180 tokens (-11.0%)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
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 pick rules.
|
|
197
|
+
|
|
198
|
+
The quality pipeline: `validate` (correct?) → `audit` (expensive?) → `optimize` (suggestions) → `fix` (auto-repair) → `grade` (report card).
|
|
199
|
+
|
|
200
|
+
Or get the full report card:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
agent-friend grade tools.json
|
|
204
|
+
|
|
205
|
+
# agent-friend grade — schema quality report card
|
|
206
|
+
#
|
|
207
|
+
# Overall Grade: B+
|
|
208
|
+
# Score: 88.0/100
|
|
209
|
+
#
|
|
210
|
+
# Correctness A+ (100/100) 0 errors, 0 warnings
|
|
211
|
+
# Efficiency B- (80/100) avg 140 tokens/tool
|
|
212
|
+
# Quality B (85/100) 1 suggestion
|
|
213
|
+
#
|
|
214
|
+
# Tools: 3 | Format: anthropic | Tokens: 420
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Weighted scoring: Correctness 40%, Efficiency 30%, Quality 30%. Use `--threshold 90` to gate CI on quality, `--json` for machine-readable output.
|
|
218
|
+
|
|
219
|
+
Try it live: [See Notion's F grade](https://0-co.github.io/company/report.html?example=notion) — or paste your own schemas. 5 real servers to try, share buttons, copy-paste badge for your README.
|
|
220
|
+
|
|
221
|
+
## CI / GitHub Action
|
|
222
|
+
|
|
223
|
+
Add a token budget to your CI pipeline — like a bundle size check for AI tool schemas:
|
|
224
|
+
|
|
225
|
+
```yaml
|
|
226
|
+
- uses: 0-co/agent-friend@main
|
|
227
|
+
with:
|
|
228
|
+
file: tools.json
|
|
229
|
+
validate: true # check schema correctness first
|
|
230
|
+
threshold: 1000 # fail if total tokens exceed budget
|
|
231
|
+
optimize: true # also suggest fixes
|
|
232
|
+
grade: true # combined report card (A+ through F)
|
|
233
|
+
grade_threshold: 80 # fail if score < 80
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Runs the full quality pipeline: validate → audit → optimize → fix → grade. Writes a formatted summary to GitHub Actions with per-format token comparison. Use CLI flags too:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
agent-friend audit tools.json --json # machine-readable output
|
|
240
|
+
agent-friend audit tools.json --threshold 500 # exit code 2 if over budget
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## When you need this
|
|
244
|
+
|
|
245
|
+
- You're writing tools for one framework but want them to work in others
|
|
246
|
+
- You want to define a tool once and use it with OpenAI, Claude, Gemini, AND MCP
|
|
247
|
+
- You need the adapter layer, not an opinionated orchestration framework
|
|
248
|
+
- You want MCP tools in Claude Desktop — `agent-friend` ships an MCP server with 314 tools
|
|
249
|
+
|
|
250
|
+
## Also included
|
|
251
|
+
|
|
252
|
+
**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](TOOLS.md) for the full list.
|
|
253
|
+
|
|
254
|
+
**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).
|
|
255
|
+
|
|
256
|
+
**CLI** — interactive REPL, one-shot tasks, streaming. Run `agent-friend --help`.
|
|
257
|
+
|
|
258
|
+
## Why not just use [framework X]?
|
|
259
|
+
|
|
260
|
+
Most tool libraries are tied to a framework (LangChain, CrewAI) or a single provider (OpenAI function calling). If you switch providers, you rewrite your tools.
|
|
261
|
+
|
|
262
|
+
agent-friend decouples your tool logic from the delivery format. Write a Python function, export to whatever your deployment needs this week. No framework lock-in, no provider dependency, no external packages required.
|
|
263
|
+
|
|
264
|
+
## Built by an AI, live on Twitch
|
|
265
|
+
|
|
266
|
+
This entire project is built and maintained by an autonomous AI agent, streamed 24/7 at [twitch.tv/0coceo](https://twitch.tv/0coceo).
|
|
267
|
+
|
|
268
|
+
[Discussions](https://github.com/0-co/agent-friend/discussions) · [Website](https://0-co.github.io/company/) · [Bluesky](https://bsky.app/profile/0coceo.bsky.social) · [Dev.to](https://dev.to/0coceo)
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# agent-friend
|
|
2
|
+
|
|
3
|
+
[](https://github.com/0-co/agent-friend/stargazers) [](https://github.com/0-co/agent-friend/actions/workflows/tests.yml)   [](https://colab.research.google.com/github/0-co/agent-friend/blob/main/demo.ipynb)
|
|
4
|
+
|
|
5
|
+
**The quality linter for MCP tool schemas.** Validate, audit, optimize, fix, and grade (A+ through F). Like ESLint for MCP. Also: write a tool once, export to OpenAI, Claude, Gemini, or MCP.
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
from agent_friend import tool
|
|
9
|
+
|
|
10
|
+
@tool
|
|
11
|
+
def get_weather(city: str, units: str = "celsius") -> dict:
|
|
12
|
+
"""Get current weather for a city."""
|
|
13
|
+
return {"city": city, "temp": 22, "units": units}
|
|
14
|
+
|
|
15
|
+
get_weather.to_openai() # OpenAI function calling
|
|
16
|
+
get_weather.to_anthropic() # Claude tool_use
|
|
17
|
+
get_weather.to_google() # Gemini
|
|
18
|
+
get_weather.to_mcp() # Model Context Protocol
|
|
19
|
+
get_weather.to_json_schema() # Raw JSON Schema
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
One function definition. Five framework formats. No vendor lock-in.
|
|
23
|
+
|
|
24
|
+
[](https://glama.ai/mcp/servers/0-co/agent-friend)
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install git+https://github.com/0-co/agent-friend.git
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Grade a real MCP server (no API key, no schema file)
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
agent-friend grade --example notion
|
|
36
|
+
|
|
37
|
+
# Overall Grade: F
|
|
38
|
+
# Score: 19.8/100
|
|
39
|
+
# Tools: 22 | Tokens: 4483
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Notion's official MCP server. 22 tools. Grade F. Every tool name violates MCP naming conventions. 5 undefined schemas.
|
|
43
|
+
|
|
44
|
+
5 real servers bundled — grade spectrum from F to A+:
|
|
45
|
+
|
|
46
|
+
| Server | Tools | Grade | Tokens |
|
|
47
|
+
|--------|-------|-------|--------|
|
|
48
|
+
| `--example notion` | 22 | F (19.8) | 4,483 |
|
|
49
|
+
| `--example filesystem` | 11 | D+ (64.9) | 1,392 |
|
|
50
|
+
| `--example github` | 12 | C+ (79.6) | 1,824 |
|
|
51
|
+
| `--example puppeteer` | 7 | A- (91.2) | 382 |
|
|
52
|
+
| `--example slack` | 8 | A+ (97.3) | 721 |
|
|
53
|
+
|
|
54
|
+
We've graded [50 MCP servers](https://0-co.github.io/company/leaderboard.html) — the top 4 most popular (Context7, Blender, Chrome DevTools, GitHub Official) all score D or below. 1,044 tools, 193K tokens analyzed.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
agent-friend examples # list all bundled schemas
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or open the [Colab notebook](https://colab.research.google.com/github/0-co/agent-friend/blob/main/demo.ipynb) — 51 tool demos in the browser.
|
|
61
|
+
|
|
62
|
+
## Batch export
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from agent_friend import tool, Toolkit
|
|
66
|
+
|
|
67
|
+
@tool
|
|
68
|
+
def search(query: str) -> str: ...
|
|
69
|
+
|
|
70
|
+
@tool
|
|
71
|
+
def calculate(expr: str) -> float: ...
|
|
72
|
+
|
|
73
|
+
kit = Toolkit([search, calculate])
|
|
74
|
+
kit.to_openai() # Both tools, OpenAI format
|
|
75
|
+
kit.to_mcp() # Both tools, MCP format
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Context budget
|
|
79
|
+
|
|
80
|
+
MCP tool definitions can eat 40-50K tokens per request. Audit your tools from the CLI:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
agent-friend audit tools.json
|
|
84
|
+
|
|
85
|
+
# agent-friend audit — tool token cost report
|
|
86
|
+
#
|
|
87
|
+
# Tool Description Tokens (est.)
|
|
88
|
+
# get_weather 67 chars ~79 tokens
|
|
89
|
+
# search_web 145 chars ~99 tokens
|
|
90
|
+
# send_email 28 chars ~79 tokens
|
|
91
|
+
# ──────────────────────────────────────────────────────
|
|
92
|
+
# Total (3 tools) ~257 tokens
|
|
93
|
+
#
|
|
94
|
+
# Format comparison (total):
|
|
95
|
+
# openai ~279 tokens
|
|
96
|
+
# anthropic ~257 tokens
|
|
97
|
+
# google ~245 tokens <- cheapest
|
|
98
|
+
# mcp ~257 tokens
|
|
99
|
+
# json_schema ~245 tokens
|
|
100
|
+
#
|
|
101
|
+
# Context window impact:
|
|
102
|
+
# GPT-4o (128K) ~0.2%
|
|
103
|
+
# Claude (200K) ~0.1%
|
|
104
|
+
# GPT-4 (8K) ~3.1% <- check your budget
|
|
105
|
+
# Gemini 2.0 (1M) ~0.0%
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or measure programmatically:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
kit = Toolkit([search, calculate])
|
|
112
|
+
kit.token_report()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Accepts OpenAI, Anthropic, MCP, Google, or JSON Schema format. Auto-detects.
|
|
116
|
+
|
|
117
|
+
## Optimize
|
|
118
|
+
|
|
119
|
+
Found the bloat? Fix it:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
agent-friend optimize tools.json
|
|
123
|
+
|
|
124
|
+
# Tool: search_inventory
|
|
125
|
+
# ⚡ Description prefix: "This tool allows you to search..." → "Search..."
|
|
126
|
+
# Saves ~6 tokens
|
|
127
|
+
# ⚡ Parameter 'query': description "The query" restates parameter name
|
|
128
|
+
# Saves ~3 tokens
|
|
129
|
+
#
|
|
130
|
+
# Summary: 5 suggestions, ~42 tokens saved (21% reduction)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
7 heuristic rules: verbose prefixes, long descriptions, redundant params, missing descriptions, cross-tool duplicates, deep nesting. Machine-readable output with `--json`.
|
|
134
|
+
|
|
135
|
+
## Validate
|
|
136
|
+
|
|
137
|
+
Catch schema errors before they crash in production:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
agent-friend validate tools.json
|
|
141
|
+
|
|
142
|
+
# agent-friend validate — schema correctness report
|
|
143
|
+
#
|
|
144
|
+
# ✓ 3 tools validated, 0 errors, 0 warnings
|
|
145
|
+
#
|
|
146
|
+
# Summary: 3 tools, 0 errors, 0 warnings — PASS
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
Or use the [free web validator](https://0-co.github.io/company/validate.html) — paste schemas, get instant results, no install needed.
|
|
152
|
+
|
|
153
|
+
## Fix
|
|
154
|
+
|
|
155
|
+
Found issues? Auto-fix them:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
agent-friend fix tools.json > tools_fixed.json
|
|
159
|
+
|
|
160
|
+
# agent-friend fix v0.59.0
|
|
161
|
+
#
|
|
162
|
+
# Applied fixes:
|
|
163
|
+
# ✓ create-page -> create_page (name)
|
|
164
|
+
# ✓ Stripped "This tool allows you to " from search description
|
|
165
|
+
# ✓ Trimmed get_database description (312 -> 198 chars)
|
|
166
|
+
# ✓ Added properties to undefined object in post_page.properties
|
|
167
|
+
#
|
|
168
|
+
# Summary: 12 fixes applied across 8 tools
|
|
169
|
+
# Token reduction: 2,450 -> 2,180 tokens (-11.0%)
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
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 pick rules.
|
|
173
|
+
|
|
174
|
+
The quality pipeline: `validate` (correct?) → `audit` (expensive?) → `optimize` (suggestions) → `fix` (auto-repair) → `grade` (report card).
|
|
175
|
+
|
|
176
|
+
Or get the full report card:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
agent-friend grade tools.json
|
|
180
|
+
|
|
181
|
+
# agent-friend grade — schema quality report card
|
|
182
|
+
#
|
|
183
|
+
# Overall Grade: B+
|
|
184
|
+
# Score: 88.0/100
|
|
185
|
+
#
|
|
186
|
+
# Correctness A+ (100/100) 0 errors, 0 warnings
|
|
187
|
+
# Efficiency B- (80/100) avg 140 tokens/tool
|
|
188
|
+
# Quality B (85/100) 1 suggestion
|
|
189
|
+
#
|
|
190
|
+
# Tools: 3 | Format: anthropic | Tokens: 420
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Weighted scoring: Correctness 40%, Efficiency 30%, Quality 30%. Use `--threshold 90` to gate CI on quality, `--json` for machine-readable output.
|
|
194
|
+
|
|
195
|
+
Try it live: [See Notion's F grade](https://0-co.github.io/company/report.html?example=notion) — or paste your own schemas. 5 real servers to try, share buttons, copy-paste badge for your README.
|
|
196
|
+
|
|
197
|
+
## CI / GitHub Action
|
|
198
|
+
|
|
199
|
+
Add a token budget to your CI pipeline — like a bundle size check for AI tool schemas:
|
|
200
|
+
|
|
201
|
+
```yaml
|
|
202
|
+
- uses: 0-co/agent-friend@main
|
|
203
|
+
with:
|
|
204
|
+
file: tools.json
|
|
205
|
+
validate: true # check schema correctness first
|
|
206
|
+
threshold: 1000 # fail if total tokens exceed budget
|
|
207
|
+
optimize: true # also suggest fixes
|
|
208
|
+
grade: true # combined report card (A+ through F)
|
|
209
|
+
grade_threshold: 80 # fail if score < 80
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Runs the full quality pipeline: validate → audit → optimize → fix → grade. Writes a formatted summary to GitHub Actions with per-format token comparison. Use CLI flags too:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
agent-friend audit tools.json --json # machine-readable output
|
|
216
|
+
agent-friend audit tools.json --threshold 500 # exit code 2 if over budget
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## When you need this
|
|
220
|
+
|
|
221
|
+
- You're writing tools for one framework but want them to work in others
|
|
222
|
+
- You want to define a tool once and use it with OpenAI, Claude, Gemini, AND MCP
|
|
223
|
+
- You need the adapter layer, not an opinionated orchestration framework
|
|
224
|
+
- You want MCP tools in Claude Desktop — `agent-friend` ships an MCP server with 314 tools
|
|
225
|
+
|
|
226
|
+
## Also included
|
|
227
|
+
|
|
228
|
+
**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](TOOLS.md) for the full list.
|
|
229
|
+
|
|
230
|
+
**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).
|
|
231
|
+
|
|
232
|
+
**CLI** — interactive REPL, one-shot tasks, streaming. Run `agent-friend --help`.
|
|
233
|
+
|
|
234
|
+
## Why not just use [framework X]?
|
|
235
|
+
|
|
236
|
+
Most tool libraries are tied to a framework (LangChain, CrewAI) or a single provider (OpenAI function calling). If you switch providers, you rewrite your tools.
|
|
237
|
+
|
|
238
|
+
agent-friend decouples your tool logic from the delivery format. Write a Python function, export to whatever your deployment needs this week. No framework lock-in, no provider dependency, no external packages required.
|
|
239
|
+
|
|
240
|
+
## Built by an AI, live on Twitch
|
|
241
|
+
|
|
242
|
+
This entire project is built and maintained by an autonomous AI agent, streamed 24/7 at [twitch.tv/0coceo](https://twitch.tv/0coceo).
|
|
243
|
+
|
|
244
|
+
[Discussions](https://github.com/0-co/agent-friend/discussions) · [Website](https://0-co.github.io/company/) · [Bluesky](https://bsky.app/profile/0coceo.bsky.social) · [Dev.to](https://dev.to/0coceo)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"""
|
|
2
|
+
agent-friend — a composable personal AI agent library.
|
|
3
|
+
|
|
4
|
+
Quick start:
|
|
5
|
+
|
|
6
|
+
from agent_friend import Friend
|
|
7
|
+
|
|
8
|
+
friend = Friend(
|
|
9
|
+
seed="You are a helpful assistant.",
|
|
10
|
+
api_key="sk-...",
|
|
11
|
+
)
|
|
12
|
+
response = friend.chat("What is 2+2?")
|
|
13
|
+
print(response.text)
|
|
14
|
+
|
|
15
|
+
With tools:
|
|
16
|
+
|
|
17
|
+
friend = Friend(
|
|
18
|
+
seed="You are a helpful assistant with tools.",
|
|
19
|
+
tools=["search", "code", "memory"],
|
|
20
|
+
model="claude-sonnet-4-6",
|
|
21
|
+
budget_usd=1.0,
|
|
22
|
+
)
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from .friend import Friend, ChatResponse, BudgetExceeded
|
|
26
|
+
from .tools import MemoryTool, CodeTool, SearchTool, BrowserTool, EmailTool, FileTool, FetchTool, VoiceTool, RSSFeedTool, SchedulerTool, DatabaseTool, FunctionTool, tool, GitTool, TableTool, WebhookTool, HTTPTool, CacheTool, NotifyTool, JSONTool, DateTimeTool, ProcessTool, EnvTool, CryptoTool, ValidatorTool
|
|
27
|
+
from .toolkit import Toolkit
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"Friend",
|
|
31
|
+
"ChatResponse",
|
|
32
|
+
"BudgetExceeded",
|
|
33
|
+
"MemoryTool",
|
|
34
|
+
"CodeTool",
|
|
35
|
+
"SearchTool",
|
|
36
|
+
"BrowserTool",
|
|
37
|
+
"EmailTool",
|
|
38
|
+
"FileTool",
|
|
39
|
+
"FetchTool",
|
|
40
|
+
"VoiceTool",
|
|
41
|
+
"RSSFeedTool",
|
|
42
|
+
"SchedulerTool",
|
|
43
|
+
"DatabaseTool",
|
|
44
|
+
"FunctionTool",
|
|
45
|
+
"tool",
|
|
46
|
+
"GitTool",
|
|
47
|
+
"TableTool",
|
|
48
|
+
"WebhookTool",
|
|
49
|
+
"HTTPTool",
|
|
50
|
+
"CacheTool",
|
|
51
|
+
"NotifyTool",
|
|
52
|
+
"JSONTool",
|
|
53
|
+
"DateTimeTool",
|
|
54
|
+
"ProcessTool",
|
|
55
|
+
"EnvTool",
|
|
56
|
+
"CryptoTool",
|
|
57
|
+
"ValidatorTool",
|
|
58
|
+
"Toolkit",
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
__version__ = "0.63.5"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Run agent-friend as an MCP stdio server: python -m agent_friend
|
|
2
|
+
|
|
3
|
+
When invoked as a module (python -m agent_friend), start the MCP server.
|
|
4
|
+
This is how Glama and other MCP clients call package-based servers.
|
|
5
|
+
For the interactive CLI, use the `agent-friend` command directly.
|
|
6
|
+
"""
|
|
7
|
+
from agent_friend.mcp_server import main
|
|
8
|
+
|
|
9
|
+
main()
|