mcp-client-kit 0.0.3__py3-none-any.whl

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.
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: mcp-client-kit
3
+ Version: 0.0.3
4
+ Summary: mcpgen — generate typed Python wrappers for any MCP server (codegen skill + CLI).
5
+ Project-URL: Homepage, https://github.com/svd/mcp-client-kit
6
+ Project-URL: Source, https://github.com/svd/mcp-client-kit
7
+ Project-URL: Issues, https://github.com/svd/mcp-client-kit/issues
8
+ Author-email: Sviatoslav Sviridov <sviridov@gmail.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Code Generators
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: httpx>=0.28
21
+ Requires-Dist: keyring>=24
22
+ Requires-Dist: mcp[cli]<2,>=1.27
23
+ Description-Content-Type: text/markdown
24
+
25
+ # mcpgen
26
+
27
+ **Write your MCP server wrappers once — from the live server. Keep them as real Python source you can diff, review, and pin.**
28
+
29
+ `mcpgen` turns any MCP server into a typed Python module: one `async def` per tool, real return types, no live server needed to read it. Call your tools from code instead of pumping their schemas through the model's context — the pattern Anthropic measured at up to **98% token reduction**.
30
+
31
+ > Two artifacts, one repo: a **CLI** (`mcpgen`) you run anywhere, and a **Claude Code plugin** (`generate-mcp-wrappers` skill) that drives it for the parts that need judgment.
32
+
33
+ ---
34
+
35
+ ## The problem
36
+
37
+ MCP tool schemas eat your context window before the agent does any work.
38
+
39
+ Every tool definition costs **300–600 tokens** for its name, description, and JSON schema. That adds up fast:
40
+
41
+ - The **GitHub MCP server alone** burns ~55,000 tokens across its 93 tools.
42
+ - One developer measured **66,000 tokens consumed at conversation start** — a third of a 200k window, gone before the first query.
43
+ - A SaaS server with 50+ endpoints can spend **30,000+ tokens just describing what it *could* do.**
44
+
45
+ Anthropic's validated fix ("Code execution with MCP," Nov 2025): stop routing schemas through the model. Generate wrapper code and call the tools from code instead — an approach Anthropic measured shrinking one workflow from ~150,000 tokens to ~2,000 (**98.7%**), with independent benchmarks landing around **78–85%** on less extreme workloads.
46
+
47
+ The catch for Python teams: no good tool generated **standalone, importable, reviewable `.py` wrappers** from a live MCP server. So everyone hand-writes `jira.py`, `github.py`, `slack.py` — slowly, inconsistently, and they silently rot when the server changes.
48
+
49
+ That's the gap mcpgen fills.
50
+
51
+ ---
52
+
53
+ ## What you get
54
+
55
+ ```bash
56
+ uv tool install mcp-client-kit # puts `mcpgen` on your PATH
57
+ mcpgen login github # browser OAuth, tokens persisted
58
+ mcpgen codegen github --out github.py # typed wrappers for every tool
59
+ ```
60
+
61
+ ```python
62
+ import asyncio
63
+ from mcpgen import McpBridgeCaller
64
+ import github # the file you just generated
65
+
66
+ async def main():
67
+ caller = McpBridgeCaller(url="https://api.githubcopilot.com/mcp/")
68
+ me = await github.get_me(caller) # -> GitHubUser
69
+ issues = await github.list_issues(caller, owner="octocat", repo="hello-world")
70
+ print(me, issues)
71
+
72
+ asyncio.run(main())
73
+ ```
74
+
75
+ `github.py` is just Python. Open it in your IDE, review it in a PR, pin it to a commit, ship it. No runtime proxy, no framework lock-in, no live server required to read what your tools return.
76
+
77
+ ---
78
+
79
+ ## Why developers pick it
80
+
81
+ **Real source you own.** Importable `.py` modules — not `.pyi` stubs (mcp2py), not a runtime proxy, not tied to one execution framework (ipybox). You can diff it, review it, pin it, and read it in your IDE without a server running.
82
+
83
+ **Types that match reality.** A tool's `inputSchema` describes its *inputs* — it tells you nothing about the *output* shape. mcpgen's `--probe` makes one live call and records the actual response, so your return types reflect what the server really sends. No other generator does this.
84
+
85
+ **OAuth that survives restarts.** Pre-flight token refresh means a fresh process renews a near-expired token silently from the refresh token — no surprise browser pop-up at cold start. (The official SDK's canonical example is in-memory only; every restart re-authenticates.)
86
+
87
+ **Swap auth without regenerating.** Every wrapper takes an `McpCaller` as its first argument. Change transports or auth backends — bearer, OAuth, stdio, a fake for tests — without touching the generated code.
88
+
89
+ **Built for production teams.** Works with any MCP server (HTTP URL, stdio, or bearer/PAT). Generated code lives in git like any other module, so it survives code review, audits, and pinning.
90
+
91
+ ---
92
+
93
+ ## How it works
94
+
95
+ | Step | Command | What happens |
96
+ |------|---------|--------------|
97
+ | 1. Generate | `mcpgen codegen <server> --out <server>.py` | One typed `async def` per tool. |
98
+ | 2. Probe (optional) | `mcpgen probe <server> <tool> --args '{}' --emit-shape <server>.shapes.json` | Records the *real* response shape from a live call. |
99
+ | 3. Regenerate | `mcpgen codegen <server> --out <server>.py --shapes <server>.shapes.json` | Wrappers now return precise types (`TypedDict`s, unions, lists). |
100
+
101
+ Polymorphic tools — ones that return different shapes depending on an input (`entityType=1` → `Person`, `=2` → `Position`) — get typed `@overload`s, so your type checker narrows the return at every call site.
102
+
103
+ The full reference, including the shape-spec format and credential backends, is in [`doc/USAGE.md`](doc/USAGE.md).
104
+
105
+ ---
106
+
107
+ ## Install
108
+
109
+ > The PyPI package is **`mcp-client-kit`**; the command it installs is **`mcpgen`**.
110
+
111
+ **CLI on your PATH:**
112
+
113
+ ```bash
114
+ uv tool install mcp-client-kit
115
+ ```
116
+
117
+ **One-off, no install:**
118
+
119
+ ```bash
120
+ uvx --from mcp-client-kit mcpgen codegen <server> --out <server>.py
121
+ ```
122
+
123
+ **As a project dependency:**
124
+
125
+ ```bash
126
+ uv add mcp-client-kit # or: pip install mcp-client-kit
127
+ ```
128
+
129
+ Requires Python 3.11+.
130
+
131
+ ---
132
+
133
+ ## Claude Code plugin
134
+
135
+ The plugin bundles the `generate-mcp-wrappers` skill, which drives the CLI through the 20% that needs judgment — curating which tools matter, probing live responses, and editing the shape-spec — then regenerates and verifies the module.
136
+
137
+ The CLI is not bundled with the plugin — install it separately (`uv add mcp-client-kit`, see [Install](#install) above). The skill requires **mcpgen >= 0.1.0** and checks this before running; a local editable install (`uv pip install -e .`) satisfies it for development. This is a version floor, not an exact pin, so the skill and CLI can be upgraded independently as long as the CLI stays at or above the floor.
138
+
139
+ ```
140
+ /plugin marketplace add svd/mcpgen
141
+ /mcp-client-kit:generate-mcp-wrappers
142
+ ```
143
+
144
+ A companion skill, `generate-mcp-runner`, writes a standalone smoke-test `run.py` that exercises the generated wrappers end-to-end.
145
+
146
+ ---
147
+
148
+ ## Command reference
149
+
150
+ | Command | What it does |
151
+ |---------|--------------|
152
+ | `codegen <server>` | Emit typed wrappers; `--shapes` applies the shape-spec, `--probe` records a response shape inline. |
153
+ | `list <server>` | Print a server's tools as JSON. |
154
+ | `probe <server> <tool>` | Live call(s) → response-shape skeleton. |
155
+ | `call <server> <tool> --out <p>` | One live call, raw payload to disk — bootstrap ids or inspect output. |
156
+ | `merge <server>` | Consolidate probe parts into `<server>.shapes.json`. |
157
+ | `login <server>` | Browser OAuth login; tokens stored at `~/.mcpgen/credentials.json`. |
158
+ | `migrate-creds` | Move stored OAuth tokens between `file` / `keyring` backends. |
159
+ | `discover` | List MCP servers configured in your installed agent hosts. |
160
+
161
+ Full workflow and flags: [`doc/USAGE.md`](doc/USAGE.md).
162
+
163
+ ---
164
+
165
+ ## Authentication
166
+
167
+ ```bash
168
+ mcpgen login <server> # OAuth (most servers)
169
+ mcpgen codegen <server> --bearer "$TOKEN" --out s.py # PAT / bearer
170
+ mcpgen codegen <server> --stdio "python server.py" --out s.py # local stdio, no auth
171
+ ```
172
+
173
+ Tokens persist in `~/.mcpgen/credentials.json` (chmod 0600) or your OS keystore via `--cred-backend keyring`. In code, `ensure_login(server, url=...)` refreshes silently and only opens a browser when a real login is required.
174
+
175
+ ---
176
+
177
+ ## Who it's for
178
+
179
+ Python developers building AI agent pipelines on MCP servers — especially Claude Code users who've already hand-written at least one `<server>.py` wrapper and felt the pain. And platform teams running multi-server MCP environments where token cost and auth reliability are production concerns.
180
+
181
+ If you write your agent logic in Python and want generated tool wrappers you can actually own — review, pin, and keep in git — this is built for you.
182
+
183
+ ---
184
+
185
+ ## Docs
186
+
187
+ - [`doc/USAGE.md`](doc/USAGE.md) — full end-user guide: install paths, server config, auth, the shape-spec, and calling generated wrappers.
188
+ - [`doc/RUNNING_LOCALLY.md`](doc/RUNNING_LOCALLY.md) — run from a local clone without installing.
189
+
190
+ ## Status
191
+
192
+ Early access (`v0.x`). The codegen engine, OAuth persistence, live-probe shaping, and both Claude Code skills are working today. On the roadmap: `--check` drift mode, so CI can flag when a server's tools change out from under your wrappers.
193
+
194
+ ## License
195
+
196
+ MIT.
@@ -0,0 +1,11 @@
1
+ mcpgen/__init__.py,sha256=wGBjWIY7A2BsJRm45A_hbZCIJ4VKKSES-BwS9B743og,438
2
+ mcpgen/_bridge.py,sha256=MtIIGi8P1f_CDOPhR2XaA2NXqWETRLCdDx2KaPSL0Ks,46457
3
+ mcpgen/cli.py,sha256=AhweW2I2_fFcHV1quS418OTiVAOlo8YRl9Yrd6Od0fQ,33006
4
+ mcpgen/codegen.py,sha256=05uQG_8Wi9vav6w65kS9Wl9xPXtgS2u6QQuYotiWkMQ,26894
5
+ mcpgen/discovery.py,sha256=UGmuCJYuHUGfGUXXoUKwNXmYJujcOQjdYAmdcDU7R4M,16130
6
+ mcpgen/seam.py,sha256=Fl3pddVNvGP-0XedeTGUGuvQRqVBtgz2sPlZrTTOLGE,620
7
+ mcp_client_kit-0.0.3.dist-info/METADATA,sha256=nQHMK3yz1LxrhCaT-QzoiI1lPenSlpg_D_4L5MQ-KbQ,9316
8
+ mcp_client_kit-0.0.3.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
9
+ mcp_client_kit-0.0.3.dist-info/entry_points.txt,sha256=JFrJbleWV3gemQ863IeTyIa6l5DbcJjOJsay183bSBw,43
10
+ mcp_client_kit-0.0.3.dist-info/licenses/LICENSE,sha256=spQ0BfGkOfbfuyGqXAunPi6dQTgczXrQTHH1OlcSTJo,1076
11
+ mcp_client_kit-0.0.3.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.30.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcpgen = mcpgen.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Sviatoslav Sviridov
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.
mcpgen/__init__.py ADDED
@@ -0,0 +1,23 @@
1
+ """mcpgen: typed Python wrapper generator for MCP servers."""
2
+
3
+ from mcpgen._bridge import (
4
+ McpBridgeCaller,
5
+ ReauthenticationRequired,
6
+ delete_cred,
7
+ ensure_login,
8
+ list_creds,
9
+ login,
10
+ migrate_creds,
11
+ )
12
+ from mcpgen.seam import McpCaller
13
+
14
+ __all__ = [
15
+ "McpBridgeCaller",
16
+ "McpCaller",
17
+ "ReauthenticationRequired",
18
+ "delete_cred",
19
+ "ensure_login",
20
+ "list_creds",
21
+ "login",
22
+ "migrate_creds",
23
+ ]