mcptoon 0.1.0__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.
- mcptoon-0.1.0/LICENSE +201 -0
- mcptoon-0.1.0/NOTICE +20 -0
- mcptoon-0.1.0/PKG-INFO +409 -0
- mcptoon-0.1.0/README.md +377 -0
- mcptoon-0.1.0/pyproject.toml +44 -0
- mcptoon-0.1.0/setup.cfg +4 -0
- mcptoon-0.1.0/src/mcptoon/__init__.py +18 -0
- mcptoon-0.1.0/src/mcptoon/cache.py +92 -0
- mcptoon-0.1.0/src/mcptoon/cli.py +414 -0
- mcptoon-0.1.0/src/mcptoon/client.py +511 -0
- mcptoon-0.1.0/src/mcptoon/config.py +176 -0
- mcptoon-0.1.0/src/mcptoon/errors.py +46 -0
- mcptoon-0.1.0/src/mcptoon/manifest.py +120 -0
- mcptoon-0.1.0/src/mcptoon/output.py +212 -0
- mcptoon-0.1.0/src/mcptoon/router.py +147 -0
- mcptoon-0.1.0/src/mcptoon/usage.py +96 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/PKG-INFO +409 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/SOURCES.txt +24 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/dependency_links.txt +1 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/entry_points.txt +2 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/requires.txt +4 -0
- mcptoon-0.1.0/src/mcptoon.egg-info/top_level.txt +1 -0
- mcptoon-0.1.0/tests/test_client.py +184 -0
- mcptoon-0.1.0/tests/test_config.py +71 -0
- mcptoon-0.1.0/tests/test_output.py +186 -0
- mcptoon-0.1.0/tests/test_router.py +119 -0
mcptoon-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 cxh
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
200
|
+
implied. See the License for the specific language governing permissions
|
|
201
|
+
and limitations under the License.
|
mcptoon-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
mcptoon — Token-efficient MCP CLI client
|
|
2
|
+
Copyright 2025 cxh
|
|
3
|
+
|
|
4
|
+
This product includes software developed by cxh (https://github.com/activeing123/mcptoon).
|
|
5
|
+
|
|
6
|
+
=== TOON Format ===
|
|
7
|
+
The TOON (Token-Optimized Object Notation) format is an original design
|
|
8
|
+
created for this project. The encoding rules (pipe-separated key:value
|
|
9
|
+
pairs, T/F for booleans, ∅ for null, ↲ for newlines) are a distinctive
|
|
10
|
+
part of mcptoon's identity.
|
|
11
|
+
|
|
12
|
+
If you implement TOON encoding in a derivative work, you must:
|
|
13
|
+
1. Attribute the original design to mcptoon
|
|
14
|
+
2. Include a reference to https://github.com/activeing123/mcptoon
|
|
15
|
+
3. Include this NOTICE file
|
|
16
|
+
|
|
17
|
+
=== Third-Party Acknowledgments ===
|
|
18
|
+
This project is inspired by the Model Context Protocol (MCP) specification
|
|
19
|
+
by Anthropic (https://modelcontextprotocol.io/). mcptoon is an independent
|
|
20
|
+
implementation and is not affiliated with or endorsed by Anthropic.
|
mcptoon-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcptoon
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Token-efficient MCP CLI client — 97% less tokens on tool discovery, 40-60% on results. Zero dependencies. Cross-platform.
|
|
5
|
+
Author: cxh
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Keywords: mcp,cli,token-efficient,model-context-protocol,agent,llm
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: System :: Shells
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
License-File: NOTICE
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
<div align="center">
|
|
34
|
+
|
|
35
|
+
# mcptoon
|
|
36
|
+
|
|
37
|
+
**MCP tool discovery costs 10,000+ tokens. mcptoon's costs 350.**
|
|
38
|
+
|
|
39
|
+
*One MCP client for every AI agent. Cross-platform. Zero dependencies.*
|
|
40
|
+
|
|
41
|
+
[](https://pypi.org/project/mcptoon/)
|
|
42
|
+
[](LICENSE)
|
|
43
|
+
[](#privacy)
|
|
44
|
+
|
|
45
|
+
[English](README.md) · [中文文档](README.zh-CN.md)
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
Here's what happens in a typical MCP-enabled conversation:
|
|
52
|
+
|
|
53
|
+
- Your agent connects to 5 MCP servers. Listing their tools: **~10,000 tokens** of JSON — `{"name":"...","description":"...","inputSchema":{"type":"object","properties":{...}}}` repeated for every tool.
|
|
54
|
+
- Your agent calls 20 tools. Each returns 500-3,000 tokens wrapped in `{"content":[{"type":"text","text":"..."}]}`.
|
|
55
|
+
- Total MCP overhead: **40,000-70,000 tokens** — brackets, quotes, commas, schema declarations — before any actual thinking happens.
|
|
56
|
+
|
|
57
|
+
On a 128K context window, that's 30-55% gone. Not on work. On syntax.
|
|
58
|
+
|
|
59
|
+
mcptoon fixes this. It's a CLI client that connects to any MCP server (stdio or HTTP transport) and outputs **TOON** (Token-Optimized Object Notation) instead of JSON.
|
|
60
|
+
|
|
61
|
+
| Operation | JSON tokens | mcptoon tokens | Savings |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| Tool discovery (96 tools) | ~2,000 | ~60 | **97%** |
|
|
64
|
+
| Tool result (structured data) | ~800 | ~350 | **56%** |
|
|
65
|
+
| Tool result (raw HTML/text) | ~1,000 | ~900 | **10%** |
|
|
66
|
+
|
|
67
|
+
TOON strips JSON syntax — brackets, quotes, commas, repeated type declarations. What remains is **real data**: repo names, star counts, search results, web page content. That's the part you actually need.
|
|
68
|
+
|
|
69
|
+
Zero dependencies. Pure Python. 50KB. And because it's a CLI tool, it works with **every AI agent** — Claude Code, Codex, OpenCode, Cursor, CatPaw, anything that runs shell commands. One config, one command, every agent gets MCP access.
|
|
70
|
+
|
|
71
|
+
## Show me
|
|
72
|
+
|
|
73
|
+
**JSON (287 tokens)** — what every other MCP client returns:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
[
|
|
77
|
+
{"name": "search_web", "description": "Search the web for information",
|
|
78
|
+
"inputSchema": {"type": "object", "properties": {"query": {"type": "string", "description": "Search query"}, "num_results": {"type": "number", "default": 5}}, "required": ["query"]}},
|
|
79
|
+
{"name": "fetch_url", "description": "Fetch content from a URL",
|
|
80
|
+
"inputSchema": {"type": "object", "properties": {"url": {"type": "string"}}, "required": ["url"]}}
|
|
81
|
+
]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**TOON (5 tokens)** — what mcptoon returns:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
search_web fetch_url
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**TOON with full schema (115 tokens)** — when you need the details:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
name:search_web|description:Search_the_web|inputSchema:type:object|properties:query:type:string|description:Search_query|num_results:type:number|default:5|required:query||
|
|
94
|
+
name:fetch_url|description:Fetch_content_from_a_URL|inputSchema:type:object|properties:url:type:string|required:url
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
98% reduction for tool discovery, 60% for full schema, zero information lost.
|
|
98
|
+
|
|
99
|
+
## Install
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
pip install mcptoon
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Zero dependencies. 50KB. Python 3.10+. Windows, macOS, Linux. Done.
|
|
106
|
+
|
|
107
|
+
## 30 seconds to your first saved tokens
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
mcptoon init
|
|
111
|
+
# Sample config created: ~/.mcptoon/config.json
|
|
112
|
+
|
|
113
|
+
mcptoon add fetch --stdio npx -y @modelcontextprotocol/server-fetch
|
|
114
|
+
|
|
115
|
+
mcptoon manifest --toon
|
|
116
|
+
# → fetch:fetch
|
|
117
|
+
|
|
118
|
+
mcptoon call fetch fetch '{"url":"https://example.com"}' --toon
|
|
119
|
+
|
|
120
|
+
mcptoon call fetch fetch '{"url":"https://example.com"}' --json # when you need JSON
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
That's it. Every `--toon` call saves tokens: 97% on tool discovery, 40-60% on structured results, 10-20% on raw content.
|
|
124
|
+
|
|
125
|
+
## How TOON works
|
|
126
|
+
|
|
127
|
+
TOON strips the structural scaffolding JSON needs for machine parsing — brackets, quotes, commas, repeated type declarations — none of which adds semantic value for an LLM.
|
|
128
|
+
|
|
129
|
+
| JSON | TOON | Why |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `{"name":"search","count":3}` | `name:search\|count:3` | Pipes replace braces + quotes + colons |
|
|
132
|
+
| `[1, 2, 3]` | `1 2 3` | Spaces replace brackets + commas |
|
|
133
|
+
| `true` / `false` | `T` / `F` | 1 char vs 4-5 |
|
|
134
|
+
| `null` | `∅` | 1 symbol vs 4 chars |
|
|
135
|
+
| `"line1\nline2"` | `line1↲line2` | ↲ replaces escape sequence |
|
|
136
|
+
| `{"a":{"b":[1,2]}}` | `a:b:1_2` | Recursive compaction |
|
|
137
|
+
|
|
138
|
+
The AI gets the same data. It can reconstruct the full structure from TOON output. We just stopped charging you tokens for `{"type":"object","properties":` over and over.
|
|
139
|
+
|
|
140
|
+
## Output formats
|
|
141
|
+
|
|
142
|
+
| Flag | What you get | Token footprint |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| `--toon` | Compact notation, full semantics | 40-60% less than JSON |
|
|
145
|
+
| `--compact` | Tool names only, space-separated | 97% less than JSON |
|
|
146
|
+
| `--json` | Standard JSON (for scripts, CI) | Baseline |
|
|
147
|
+
| `--raw` | Raw response, no parsing | Full size |
|
|
148
|
+
| `--head N` | First N items only | Variable |
|
|
149
|
+
| `--max-chars N` | Hard truncate at N chars | Variable |
|
|
150
|
+
| `--full` | Disable the default 4000-char truncation | Full size |
|
|
151
|
+
|
|
152
|
+
Set `MCPTOON_AGENT_TYPE=claude` and every call auto-selects `--toon`. No need to add the flag manually.
|
|
153
|
+
|
|
154
|
+
## Examples
|
|
155
|
+
|
|
156
|
+
### GitHub repo search — 287 → 115 tokens (60% saved)
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
$ mcptoon call github search_repos '{"query":"mcp"}' --toon
|
|
160
|
+
total_count:234|items:name:mcp-server|full_name:anthropic/mcp-server|stargazers_count:1234|description:Official_MCP_server name:mcp-client|full_name:anthropic/mcp-client|stargazers_count:567|description:MCP_client_library
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```
|
|
164
|
+
$ mcptoon call github search_repos '{"query":"mcp"}' --compact
|
|
165
|
+
mcp-server mcp-client
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### 96-tool manifest discovery — 2,034 → 62 tokens (97% saved)
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
$ mcptoon manifest --toon
|
|
172
|
+
fetch:fetch filesystem:read_file filesystem:write_file github:search_repos github:create_issue ...
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Your agent now knows all 96 available tools and still has 97% of its context left to actually use them.
|
|
176
|
+
|
|
177
|
+
### Web fetch — strips the MCP wrapper
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
$ mcptoon call fetch fetch '{"url":"https://example.com"}' --toon
|
|
181
|
+
<!DOCTYPE html><html><head><title>Example</title>...</html>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
No `{"content":[{"type":"text","text":"..."}]}` wrapper. Just the content.
|
|
185
|
+
|
|
186
|
+
## vs. other MCP clients
|
|
187
|
+
|
|
188
|
+
| | mcptoon | mcp-cli | mcporter | raw MCP SDK |
|
|
189
|
+
|---|---|---|---|---|
|
|
190
|
+
| Token savings | **97% manifest, 40-60% results** | 0% | 0% | 0% |
|
|
191
|
+
| Works with all agents | **yes** (Claude Code, Codex, OpenCode, Cursor, any) | Claude only | Claude only | varies |
|
|
192
|
+
| One config for all agents | **yes** | no | no | no |
|
|
193
|
+
| Output formats | TOON + JSON + compact | JSON | JSON | JSON |
|
|
194
|
+
| Dependencies | **0** | 5-20 | npm | 3-8 |
|
|
195
|
+
| stdio transport (MCP servers) | yes | no | yes | yes |
|
|
196
|
+
| HTTP transport (MCP servers) | yes | yes (proxy) | yes | yes |
|
|
197
|
+
| Dangerous-op blocking | yes | no | no | no |
|
|
198
|
+
| Usage tracking | yes (local) | no | no | no |
|
|
199
|
+
| Schema cache | yes (5min) | no | no | no |
|
|
200
|
+
| Custom handlers | yes | no | no | no |
|
|
201
|
+
| Install size | ~50KB | ~50MB+ | ~30MB | ~10MB |
|
|
202
|
+
| Platform support | **Windows, macOS, Linux** | Linux/macOS | macOS | varies |
|
|
203
|
+
|
|
204
|
+
Same MCP servers. Same MCP protocol. Same results. 97% less tokens on discovery, 40-60% on results. Works on Windows, macOS, and Linux.
|
|
205
|
+
|
|
206
|
+
## Works with every agent
|
|
207
|
+
|
|
208
|
+
mcptoon is a CLI tool. If your agent can run shell commands, it can use mcptoon. No SDK integration, no plugin, no per-agent config.
|
|
209
|
+
|
|
210
|
+
You configure your MCP servers **once** in `~/.mcptoon/config.json`. Every agent shares the same servers, the same tools, the same token savings.
|
|
211
|
+
|
|
212
|
+
| Agent | How to use |
|
|
213
|
+
|---|---|
|
|
214
|
+
| **Claude Code** | Write `mcptoon` commands in SKILL.md files or custom instructions |
|
|
215
|
+
| **Codex (OpenAI)** | Add `mcptoon` to your AGENTS.md or prompt instructions |
|
|
216
|
+
| **OpenCode** | Use `mcptoon` in your custom commands or system prompt |
|
|
217
|
+
| **Cursor** | Add `mcptoon` to your .cursorrules or custom prompt |
|
|
218
|
+
| **CatPaw** | Write `mcptoon` commands in skill files |
|
|
219
|
+
| **Any agent** | If it runs shell commands, it can call `mcptoon` |
|
|
220
|
+
|
|
221
|
+
### Claude Code
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
export MCPTOON_AGENT_TYPE=claude # auto-select --toon
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```markdown
|
|
228
|
+
# In ~/.claude/skills/mcp-tools/SKILL.md
|
|
229
|
+
|
|
230
|
+
Search the web:
|
|
231
|
+
`mcptoon call exa search '{"query":"AI news"}'`
|
|
232
|
+
|
|
233
|
+
List available tools:
|
|
234
|
+
`mcptoon manifest --toon`
|
|
235
|
+
|
|
236
|
+
Fetch a URL:
|
|
237
|
+
`mcptoon call fetch fetch '{"url":"https://example.com"}'`
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Codex (OpenAI)
|
|
241
|
+
|
|
242
|
+
```markdown
|
|
243
|
+
# In AGENTS.md or system prompt
|
|
244
|
+
|
|
245
|
+
Use mcptoon to call MCP tools. It saves 60% tokens vs JSON.
|
|
246
|
+
|
|
247
|
+
- List tools: `mcptoon manifest --toon`
|
|
248
|
+
- Call a tool: `mcptoon call <server> <tool> '{"args":"here"}' --toon`
|
|
249
|
+
- Inspect a tool: `mcptoon inspect <server> <tool>`
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### OpenCode
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# In your OpenCode config or system prompt
|
|
256
|
+
export MCPTOON_AGENT_TYPE=claude
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
```
|
|
260
|
+
## Available MCP tools
|
|
261
|
+
Run `mcptoon manifest --toon` to see all tools.
|
|
262
|
+
Run `mcptoon call <server> <tool> '<json_args>' --toon` to call one.
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Why one unified layer?
|
|
266
|
+
|
|
267
|
+
Without mcptoon, you configure MCP servers separately for each agent — Claude Code's `claude_desktop_config.json`, Cursor's MCP settings, OpenCode's config, etc. Same servers, different formats, different setups.
|
|
268
|
+
|
|
269
|
+
With mcptoon, you configure once. `~/.mcptoon/config.json` is your single source of truth. Every agent calls `mcptoon` the same way. Add a server, every agent sees it instantly. Remove a server, it's gone everywhere.
|
|
270
|
+
|
|
271
|
+
Plus: every call saves 97% tokens on manifest discovery and 40-60% on tool results, no matter which agent you're using.
|
|
272
|
+
|
|
273
|
+
## Python API
|
|
274
|
+
|
|
275
|
+
```python
|
|
276
|
+
from mcptoon.client import MCPClient
|
|
277
|
+
from mcptoon.output import toon
|
|
278
|
+
|
|
279
|
+
with MCPClient(stdio=["npx", "-y", "@modelcontextprotocol/server-fetch"]) as c:
|
|
280
|
+
tools = c.list_tools()
|
|
281
|
+
print(toon(tools)) # compact TOON
|
|
282
|
+
result = c.call_tool("fetch", {"url": "https://example.com"})
|
|
283
|
+
print(toon(result))
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Custom handlers — bypass MCP entirely
|
|
287
|
+
|
|
288
|
+
```python
|
|
289
|
+
from mcptoon.router import register
|
|
290
|
+
|
|
291
|
+
@register("my-database", "db")
|
|
292
|
+
def handle_db(tool, args):
|
|
293
|
+
if tool == "query":
|
|
294
|
+
return {"rows": my_db.execute(args["sql"])}
|
|
295
|
+
return None # falls through to MCP
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
`mcptoon call db query '{"sql":"SELECT * FROM users"}'` goes straight to your handler. No MCP server needed.
|
|
299
|
+
|
|
300
|
+
## Config
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
# stdio (any npx MCP server)
|
|
304
|
+
mcptoon add fetch --stdio npx -y @modelcontextprotocol/server-fetch
|
|
305
|
+
mcptoon add github --stdio npx -y @modelcontextprotocol/server-github
|
|
306
|
+
|
|
307
|
+
# HTTP
|
|
308
|
+
mcptoon add myapi --http http://localhost:3001/mcp --header "Authorization: Bearer xxx"
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Config lives at `~/.mcptoon/config.json`. Project-level override at `./.mcptoon.json`. Env var `MCPTOON_SERVERS` (JSON string) takes highest priority.
|
|
312
|
+
|
|
313
|
+
```json
|
|
314
|
+
{
|
|
315
|
+
"servers": {
|
|
316
|
+
"fetch": {
|
|
317
|
+
"transport": "stdio",
|
|
318
|
+
"command": ["npx", "-y"],
|
|
319
|
+
"args": ["@modelcontextprotocol/server-fetch"]
|
|
320
|
+
},
|
|
321
|
+
"github": {
|
|
322
|
+
"transport": "stdio",
|
|
323
|
+
"command": ["npx", "-y"],
|
|
324
|
+
"args": ["@modelcontextprotocol/server-github"],
|
|
325
|
+
"env": {"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxx"}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
## Safety
|
|
332
|
+
|
|
333
|
+
mcptoon blocks operations that match dangerous patterns (`delete`, `drop`, `purge`, `wipe`, `kill`, `force=true`, `confirm=true`, etc.) unless you pass `--destructive`.
|
|
334
|
+
|
|
335
|
+
```bash
|
|
336
|
+
$ mcptoon call db delete_table '{"name":"users"}'
|
|
337
|
+
Error [CONFIRMATION_REQUIRED]: Dangerous operation needs confirmation
|
|
338
|
+
|
|
339
|
+
$ mcptoon call db delete_table '{"name":"users"}' --destructive
|
|
340
|
+
# runs
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
No surprises. No accidental data loss from an AI agent that got too creative.
|
|
344
|
+
|
|
345
|
+
## Usage tracking
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
$ mcptoon usage
|
|
349
|
+
Total calls: 142
|
|
350
|
+
Success rate: 138/142
|
|
351
|
+
Tokens (est): 84,200
|
|
352
|
+
|
|
353
|
+
By server:
|
|
354
|
+
fetch 89
|
|
355
|
+
github 53
|
|
356
|
+
|
|
357
|
+
Top tools:
|
|
358
|
+
fetch:fetch 45
|
|
359
|
+
github:search_repos 38
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Stored locally at `~/.cache/mcptoon/usage.json`. Never transmitted.
|
|
363
|
+
|
|
364
|
+
## Architecture
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
src/mcptoon/
|
|
368
|
+
├── cli.py # CLI entry + arg parsing
|
|
369
|
+
├── client.py # MCPClient — stdio + HTTP transport, MCPClientPool
|
|
370
|
+
├── router.py # Tool call routing, custom handlers, safety checks
|
|
371
|
+
├── config.py # Server config (~/.mcptoon/config.json + overrides)
|
|
372
|
+
├── manifest.py # Tool discovery with cache
|
|
373
|
+
├── output.py # TOON / JSON / compact rendering
|
|
374
|
+
├── cache.py # Schema cache (5-min TTL)
|
|
375
|
+
├── usage.py # Local usage tracking
|
|
376
|
+
└── errors.py # Structured error envelopes
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
~1,700 lines total. Zero third-party imports. The only network calls are to MCP servers you configure.
|
|
380
|
+
|
|
381
|
+
## Privacy
|
|
382
|
+
|
|
383
|
+
- **No telemetry.** No analytics, no crash reports, no phone-home. Nothing leaves your machine.
|
|
384
|
+
- **No credential storage.** API keys pass through from your config or env vars. Never logged, never cached.
|
|
385
|
+
- **No dependencies.** Pure Python stdlib. No supply chain to audit, no packages to hijack, no updates to chase.
|
|
386
|
+
|
|
387
|
+
Local files: `~/.mcptoon/config.json` (your config), `~/.cache/mcptoon/schema_cache.json` (5-min cache), `~/.cache/mcptoon/usage.json` (stats). Delete any of them, mcptoon recreates as needed.
|
|
388
|
+
|
|
389
|
+
Found a vulnerability? Email `security@activeing123.github.io` — don't open a public issue. 48h response, 7-day fix window. See [SECURITY.md](SECURITY.md).
|
|
390
|
+
|
|
391
|
+
## License
|
|
392
|
+
|
|
393
|
+
Apache 2.0. Commercial use, modification, distribution — all fine. Keep the LICENSE and NOTICE files, state your changes. The TOON format is open — implement it in your own tools, just attribute mcptoon. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
|
|
394
|
+
|
|
395
|
+
## Contributing
|
|
396
|
+
|
|
397
|
+
```bash
|
|
398
|
+
git clone https://github.com/activeing123/mcptoon.git
|
|
399
|
+
cd mcptoon
|
|
400
|
+
pip install -e . --no-build-isolation
|
|
401
|
+
pip install pytest pytest-cov
|
|
402
|
+
python -m pytest tests/ -v # 98 tests, 0.09s
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
Zero dependencies is a hard rule. New features need tests. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
406
|
+
|
|
407
|
+
---
|
|
408
|
+
|
|
409
|
+
*mcptoon is an independent third-party MCP client. Not affiliated with Anthropic.*
|