toolpipe 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.
Files changed (73) hide show
  1. toolpipe-0.1.0/.github/workflows/ci.yml +98 -0
  2. toolpipe-0.1.0/.gitignore +16 -0
  3. toolpipe-0.1.0/CHANGELOG.md +26 -0
  4. toolpipe-0.1.0/LICENSE +192 -0
  5. toolpipe-0.1.0/PKG-INFO +251 -0
  6. toolpipe-0.1.0/README.md +228 -0
  7. toolpipe-0.1.0/examples/demo/analytics_mcp.py +20 -0
  8. toolpipe-0.1.0/examples/demo/producer_mcp.py +24 -0
  9. toolpipe-0.1.0/examples/toolpipe.toml +34 -0
  10. toolpipe-0.1.0/pyproject.toml +68 -0
  11. toolpipe-0.1.0/src/toolpipe/__init__.py +3 -0
  12. toolpipe-0.1.0/src/toolpipe/__main__.py +4 -0
  13. toolpipe-0.1.0/src/toolpipe/cli.py +258 -0
  14. toolpipe-0.1.0/src/toolpipe/config.py +163 -0
  15. toolpipe-0.1.0/src/toolpipe/constants.py +11 -0
  16. toolpipe-0.1.0/src/toolpipe/discovery.py +277 -0
  17. toolpipe-0.1.0/src/toolpipe/errors.py +33 -0
  18. toolpipe-0.1.0/src/toolpipe/models.py +103 -0
  19. toolpipe-0.1.0/src/toolpipe/results/__init__.py +0 -0
  20. toolpipe-0.1.0/src/toolpipe/results/cleanup.py +33 -0
  21. toolpipe-0.1.0/src/toolpipe/results/codec.py +76 -0
  22. toolpipe-0.1.0/src/toolpipe/results/manager.py +168 -0
  23. toolpipe-0.1.0/src/toolpipe/results/preview.py +108 -0
  24. toolpipe-0.1.0/src/toolpipe/results/search.py +121 -0
  25. toolpipe-0.1.0/src/toolpipe/results/selector.py +22 -0
  26. toolpipe-0.1.0/src/toolpipe/results/store.py +324 -0
  27. toolpipe-0.1.0/src/toolpipe/server/__init__.py +0 -0
  28. toolpipe-0.1.0/src/toolpipe/server/app.py +121 -0
  29. toolpipe-0.1.0/src/toolpipe/server/approval.py +91 -0
  30. toolpipe-0.1.0/src/toolpipe/server/consent.py +256 -0
  31. toolpipe-0.1.0/src/toolpipe/server/dispatcher.py +28 -0
  32. toolpipe-0.1.0/src/toolpipe/server/registry.py +213 -0
  33. toolpipe-0.1.0/src/toolpipe/server/schema_transform.py +54 -0
  34. toolpipe-0.1.0/src/toolpipe/server/virtualization.py +154 -0
  35. toolpipe-0.1.0/src/toolpipe/tools/__init__.py +22 -0
  36. toolpipe-0.1.0/src/toolpipe/tools/_common.py +26 -0
  37. toolpipe-0.1.0/src/toolpipe/tools/inspect.py +32 -0
  38. toolpipe-0.1.0/src/toolpipe/tools/pipe.py +142 -0
  39. toolpipe-0.1.0/src/toolpipe/tools/policy.py +65 -0
  40. toolpipe-0.1.0/src/toolpipe/tools/read.py +37 -0
  41. toolpipe-0.1.0/src/toolpipe/tools/release.py +23 -0
  42. toolpipe-0.1.0/src/toolpipe/tools/search.py +27 -0
  43. toolpipe-0.1.0/src/toolpipe/tools/select.py +39 -0
  44. toolpipe-0.1.0/src/toolpipe/tools/servers.py +121 -0
  45. toolpipe-0.1.0/src/toolpipe/utils/__init__.py +0 -0
  46. toolpipe-0.1.0/src/toolpipe/utils/atomic.py +26 -0
  47. toolpipe-0.1.0/src/toolpipe/utils/sizes.py +11 -0
  48. toolpipe-0.1.0/src/toolpipe/utils/time.py +25 -0
  49. toolpipe-0.1.0/tests/__init__.py +0 -0
  50. toolpipe-0.1.0/tests/fixtures/analytics_mcp.py +38 -0
  51. toolpipe-0.1.0/tests/fixtures/echo_a_mcp.py +37 -0
  52. toolpipe-0.1.0/tests/fixtures/echo_b_mcp.py +14 -0
  53. toolpipe-0.1.0/tests/fixtures/marker_mcp.py +21 -0
  54. toolpipe-0.1.0/tests/fixtures/producer_mcp.py +24 -0
  55. toolpipe-0.1.0/tests/integration/__init__.py +0 -0
  56. toolpipe-0.1.0/tests/integration/test_acceptance.py +111 -0
  57. toolpipe-0.1.0/tests/integration/test_consent.py +309 -0
  58. toolpipe-0.1.0/tests/integration/test_large_result.py +49 -0
  59. toolpipe-0.1.0/tests/integration/test_pipe.py +185 -0
  60. toolpipe-0.1.0/tests/integration/test_policy.py +122 -0
  61. toolpipe-0.1.0/tests/integration/test_proxy.py +81 -0
  62. toolpipe-0.1.0/tests/integration/test_tools.py +160 -0
  63. toolpipe-0.1.0/tests/unit/__init__.py +0 -0
  64. toolpipe-0.1.0/tests/unit/test_cli.py +102 -0
  65. toolpipe-0.1.0/tests/unit/test_codec.py +218 -0
  66. toolpipe-0.1.0/tests/unit/test_config.py +82 -0
  67. toolpipe-0.1.0/tests/unit/test_consent.py +113 -0
  68. toolpipe-0.1.0/tests/unit/test_discovery.py +179 -0
  69. toolpipe-0.1.0/tests/unit/test_registry.py +41 -0
  70. toolpipe-0.1.0/tests/unit/test_schema_transform.py +53 -0
  71. toolpipe-0.1.0/tests/unit/test_store.py +178 -0
  72. toolpipe-0.1.0/tests/unit/test_virtualization.py +166 -0
  73. toolpipe-0.1.0/uv.lock +1895 -0
@@ -0,0 +1,98 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ["v*"]
7
+ pull_request:
8
+ branches: [main]
9
+
10
+ jobs:
11
+ test:
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.11", "3.12", "3.13"]
15
+ os: [ubuntu-latest, macos-latest]
16
+ fail-fast: false
17
+
18
+ runs-on: ${{ matrix.os }}
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - name: Install uv
24
+ uses: astral-sh/setup-uv@v5
25
+ with:
26
+ enable-cache: true
27
+
28
+ - name: Set up Python ${{ matrix.python-version }}
29
+ uses: actions/setup-python@v5
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+
33
+ - name: Install dependencies
34
+ run: uv sync
35
+
36
+ - name: Lint (ruff check)
37
+ run: uv run ruff check .
38
+
39
+ - name: Format (ruff format check)
40
+ run: uv run ruff format --check .
41
+
42
+ - name: Type check (pyright)
43
+ run: uv run pyright
44
+
45
+ - name: Test
46
+ run: uv run pytest
47
+
48
+ publish:
49
+ needs: [test]
50
+ if: startsWith(github.ref, 'refs/tags/v')
51
+ runs-on: ubuntu-latest
52
+ steps:
53
+ - uses: actions/checkout@v4
54
+
55
+ - name: Install uv
56
+ uses: astral-sh/setup-uv@v5
57
+ with:
58
+ enable-cache: true
59
+
60
+ - name: Build
61
+ run: uv build
62
+
63
+ - name: Publish to PyPI
64
+ run: uv publish
65
+ env:
66
+ UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
67
+
68
+ - name: Upload build artifacts
69
+ uses: actions/upload-artifact@v4
70
+ with:
71
+ name: dist
72
+ path: dist/
73
+
74
+ release:
75
+ needs: [publish]
76
+ if: startsWith(github.ref, 'refs/tags/v')
77
+ runs-on: ubuntu-latest
78
+ permissions:
79
+ contents: write
80
+ steps:
81
+ - uses: actions/checkout@v4
82
+
83
+ - name: Download build artifacts
84
+ uses: actions/download-artifact@v4
85
+ with:
86
+ name: dist
87
+ path: dist/
88
+
89
+ - name: Extract changelog for this version
90
+ run: |
91
+ TAG="${{ github.ref_name }}"
92
+ awk -v tag="$TAG" 'index($0, "## " tag) == 1{found=NR; print; next} found && /^## v/{exit} found' CHANGELOG.md > release-notes.md
93
+
94
+ - name: Create GitHub Release
95
+ uses: softprops/action-gh-release@v2
96
+ with:
97
+ body_path: release-notes.md
98
+ files: dist/*
@@ -0,0 +1,16 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+
12
+ # Local ToolPipe result store (runtime state)
13
+ .toolpipe/
14
+
15
+ # Miscellaneous
16
+ misc/
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## v0.1.0
4
+
5
+ Initial release: ToolPipe MCP data-plane proxy.
6
+
7
+ - STDIO proxying of multiple downstream MCP servers with namespaced tools;
8
+ overlapping namespaces resolve by longest prefix.
9
+ - Fail-fast TOML config validation (bad sections, unknown keys, bad
10
+ ranges/types) with `${VAR}` environment substitution.
11
+ - Output-schema normalization so large responses can become references.
12
+ - SQLite + content-hashed blob result store (TTL, refcounts, dedup-aware
13
+ storage limits, blob repair, ref-collision retry).
14
+ - Automatic virtualization middleware (JSON + text, compact `res_*` envelopes);
15
+ limit rejections raise a clear `ToolError`.
16
+ - Control tools: inspect, read, select (JMESPath), search (iterative walk with
17
+ depth cap and exact truncation), release, pipe.
18
+ - Zero-config serve with IDE auto-discovery (Claude Code, Cursor, Codex,
19
+ OpenCode, Zed); first-use consent (once/session/workspace/always) with
20
+ elicitation and approve-tool fallback; scope files with unresolved `${VAR}`.
21
+ - Server management tools (pending/approve/add/remove/list) and per-server/tool
22
+ virtualization policies (auto/always/never).
23
+ - Direct result piping with literal args, collision detection, single-bump
24
+ reads, and re-virtualization of large target outputs.
25
+ - CLI: serve, inspect, results, stats, clean; stderr-only logging.
26
+ - Demo producer/analytics pair; 100k-customer acceptance test.
toolpipe-0.1.0/LICENSE ADDED
@@ -0,0 +1,192 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+
180
+ Copyright 2026 Kunal Kaul
181
+
182
+ Licensed under the Apache License, Version 2.0 (the "License");
183
+ you may not use this file except in compliance with the License.
184
+ You may obtain a copy of the License at
185
+
186
+ http://www.apache.org/licenses/LICENSE-2.0
187
+
188
+ Unless required by applicable law or agreed to in writing, software
189
+ distributed under the License is distributed on an "AS IS" BASIS,
190
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
191
+ See the License for the specific language governing permissions and
192
+ limitations under the License.
@@ -0,0 +1,251 @@
1
+ Metadata-Version: 2.5
2
+ Name: toolpipe
3
+ Version: 0.1.0
4
+ Summary: Pass MCP results by reference, not through the LLM.
5
+ Project-URL: Homepage, https://github.com/kunalkaul/toolpipe
6
+ Project-URL: Repository, https://github.com/kunalkaul/toolpipe
7
+ Project-URL: Changelog, https://github.com/kunalkaul/toolpipe/blob/main/CHANGELOG.md
8
+ Author-email: Kunal Kaul <kkdevcode@gmail.com>
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: llm,mcp,proxy,tools
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: Apache Software License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: fastmcp<5,>=4
21
+ Requires-Dist: jmespath>=1.1.0
22
+ Description-Content-Type: text/markdown
23
+
24
+ # ToolPipe
25
+
26
+ > **Pass MCP results by reference, not through the LLM.**
27
+
28
+ ToolPipe is an MCP data-plane proxy that keeps large tool outputs out of LLM context by storing them as references and piping the underlying data directly between tools.
29
+
30
+ ```text
31
+ Without ToolPipe: Tool A → 18 MB → LLM → Tool B
32
+ With ToolPipe: Tool A → ToolPipe storage ├→ LLM: res_xxx └→ Tool B: actual data
33
+ ```
34
+
35
+ The LLM stays the **reasoning plane** (it sees a small `res_*` reference plus a
36
+ preview). ToolPipe is the **data plane** (it holds the bytes and feeds them to
37
+ the next tool).
38
+
39
+ ## How it works
40
+
41
+ 1. ToolPipe exposes downstream MCP servers' tools through one server, namespaced
42
+ (`producer_generate_customers`, `analytics_calculate_statistics`).
43
+ 2. When a downstream tool returns more than `inline_max_bytes` (default 32 KiB),
44
+ ToolPipe stores the payload locally (SQLite metadata + content-hashed blobs)
45
+ and returns a compact reference envelope instead.
46
+ 3. The agent then uses control tools to inspect, read, search, or select from
47
+ the stored result — or pipes data straight into another tool without the
48
+ payload ever re-entering context.
49
+
50
+ ```text
51
+ 100,000 customer objects (~5.1 MiB)
52
+ │ producer_generate_customers
53
+
54
+ ToolPipe res_A (542 B: ref + preview)
55
+ │ mapping customers[].revenue
56
+ ▼ analytics_calculate_statistics
57
+ {count: 100000, min: 0.0, max: 4999.0, mean: 2499.5} (60 B)
58
+ ```
59
+
60
+ Measured on the bundled demo: **5,355,595 B → 542 B (~9881x smaller)** for the
61
+ producer step; the final stats response is 60 B.
62
+
63
+ ## Installation
64
+
65
+ Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
66
+
67
+ ```bash
68
+ uv sync
69
+ uv run toolpipe --help
70
+ ```
71
+
72
+ ## Configuration
73
+
74
+ Zero-config first: just add ToolPipe to your agent — no `toolpipe.toml`
75
+ needed.
76
+
77
+ ```bash
78
+ toolpipe serve
79
+ ```
80
+
81
+ On startup ToolPipe auto-discovers the MCP servers you already configured in
82
+ Claude Code (`.mcp.json`), Cursor (`.cursor/mcp.json`), Codex
83
+ (`.codex/config.toml`), OpenCode (`opencode.json`), and Zed
84
+ (`.zed/settings.json`), workspace files first. Discovered servers spawn
85
+ nothing until you approve them: the first time the agent routes a call through
86
+ one, **you** are asked — once, for this session, for this workspace, or always
87
+ — and your choice is saved. Static TOML and explicit imports work as before:
88
+
89
+ ```bash
90
+ toolpipe serve --config toolpipe.toml
91
+ toolpipe serve --import-mcp-json path/to/mcp.json
92
+ toolpipe serve --import-codex-toml ~/.codex/config.toml
93
+ toolpipe serve --no-discover --no-dynamic-servers
94
+ ```
95
+
96
+ See `examples/toolpipe.toml` (working demo config). Format:
97
+
98
+ ```toml
99
+ [toolpipe]
100
+ name = "ToolPipe"
101
+
102
+ [results]
103
+ storage_dir = ".toolpipe"
104
+ inline_max_bytes = 32768 # below this: pass through unchanged
105
+ preview_max_bytes = 4096 # preview budget inside reference envelopes
106
+ read_max_bytes = 16384 # max bytes per toolpipe_read_result call
107
+ max_result_bytes = 104857600
108
+ max_store_bytes = 1073741824
109
+ ttl_seconds = 3600
110
+
111
+ [servers.producer]
112
+ command = "uv"
113
+ args = ["run", "python", "examples/demo/producer_mcp.py"]
114
+
115
+ [servers.analytics]
116
+ command = "uv"
117
+ args = ["run", "python", "examples/demo/analytics_mcp.py"]
118
+
119
+ [servers.remote]
120
+ url = "http://localhost:9001/mcp"
121
+ ```
122
+
123
+ Secrets use `${VAR}` substitution and fail fast when unset:
124
+
125
+ ```toml
126
+ [servers.github]
127
+ command = "npx"
128
+ args = ["-y", "@example/github-mcp"]
129
+
130
+ [servers.github.env]
131
+ GITHUB_TOKEN = "${GITHUB_TOKEN}"
132
+ ```
133
+
134
+ ### MCP client config (generic Claude/Cursor/Codex style)
135
+
136
+ Plug-and-play entry — no config file:
137
+
138
+ ```json
139
+ {
140
+ "mcpServers": {
141
+ "toolpipe": {
142
+ "command": "toolpipe",
143
+ "args": ["serve"]
144
+ }
145
+ }
146
+ }
147
+ ```
148
+
149
+ Pinned-config entry:
150
+
151
+ ```json
152
+ {
153
+ "mcpServers": {
154
+ "toolpipe": {
155
+ "command": "toolpipe",
156
+ "args": ["serve", "--config", "/path/to/toolpipe.toml"]
157
+ }
158
+ }
159
+ }
160
+ ```
161
+
162
+ ## Consent scopes
163
+
164
+ | Scope | Meaning | Stored in |
165
+ | ----- | ------- | --------- |
166
+ | `once` | This one call only | Memory |
167
+ | `session` | This ToolPipe process | Memory |
168
+ | `workspace` | This project, across restarts | `<storage_dir>/servers.json` |
169
+ | `always` | Everywhere, across restarts | `~/.toolpipe/servers.json` |
170
+
171
+ Approvals persist connect info with `${VAR}` references unresolved (resolved
172
+ secrets are never written to disk). Removing a server revokes it everywhere
173
+ but keeps stored results. If your client cannot render approval prompts, the
174
+ agent asks in chat and calls `toolpipe_approve_server` instead.
175
+
176
+ ## Control tools
177
+
178
+ | Tool | Purpose |
179
+ | ---- | ------- |
180
+ | `toolpipe_inspect_result` | Metadata + bounded preview for a `res_*` ref |
181
+ | `toolpipe_read_result` | Bounded byte-slice reads (diagnostic; prefer select for JSON) |
182
+ | `toolpipe_select_result` | JMESPath selection, e.g. `customers[].revenue` (small→inline, large→new ref) |
183
+ | `toolpipe_search_result` | Substring/regex search; line matches for text, leaf paths for JSON |
184
+ | `toolpipe_release_result` | Drop a stored result immediately |
185
+ | `toolpipe_pipe_result` | Pipe mapped data directly into a downstream tool |
186
+ | `toolpipe_pending_servers` | Discovered servers waiting for approval |
187
+ | `toolpipe_approve_server` | Approve a server (`once`/`session`/`workspace`/`always`) |
188
+ | `toolpipe_add_server` | Manually register a server discovery cannot see |
189
+ | `toolpipe_remove_server` | Revoke a server (stored results are kept) |
190
+ | `toolpipe_list_servers` | Servers with scope, status, tool counts (env redacted) |
191
+ | `toolpipe_set_policy` | `auto`/`always`/`never` per `server` or `server:tool` |
192
+ | `toolpipe_get_policy` | Configured policies (default is `auto`) |
193
+
194
+ Selectors are JMESPath only — no Python/Jinja/shell evaluation, ever.
195
+
196
+ ## CLI
197
+
198
+ ```bash
199
+ toolpipe serve [--config toolpipe.toml] [--log-level INFO]
200
+ toolpipe serve --import-mcp-json mcp.json --import-codex-toml config.toml
201
+ toolpipe serve --no-discover --no-dynamic-servers
202
+ toolpipe inspect res_abc123 --config toolpipe.toml
203
+ toolpipe results --config toolpipe.toml
204
+ toolpipe stats --config toolpipe.toml # includes "estimated bytes avoided"
205
+ toolpipe clean --config toolpipe.toml # expired results only
206
+ ```
207
+
208
+ Logs go to stderr (stdout is the MCP protocol channel). Payloads and secrets
209
+ are never logged.
210
+
211
+ ## Demo
212
+
213
+ ```bash
214
+ uv run toolpipe serve --config examples/toolpipe.toml
215
+ ```
216
+
217
+ Then, from any MCP client: `producer_generate_customers(count=100000)` returns
218
+ a `res_*` reference; `toolpipe_pipe_result` with mapping
219
+ `{"values": "customers[].revenue"}` into `analytics_calculate_statistics`
220
+ returns the stats without the array crossing context.
221
+
222
+ ## Limitations
223
+
224
+ - STDIO upstream only; one process = one result scope (no multi-user mode).
225
+ - JSON and text virtualization only — images/audio/binary pass through.
226
+ - No CSV/row operations, no streaming, no cross-hose shared refs.
227
+ - Storage pressure fails loudly instead of evicting (`StorageLimitError`); no LRU.
228
+ - No `save_result(path=...)` by design (avoids path-traversal policy).
229
+
230
+ ## Security
231
+
232
+ - JMESPath only; `eval`/`exec`/shell/Jinja/JS are not supported anywhere.
233
+ - Refs are opaque random tokens, never filesystem paths or hashes.
234
+ - Pipe targets must be approved downstream tools; `toolpipe_*` control tools are rejected.
235
+ - First use asks for approval showing the exact command; `deny` persists nothing.
236
+ - Scope files keep `${VAR}` references unresolved; listings redact env values.
237
+ - `never` policy disables virtualization only — a context-bloat footgun, not a data leak.
238
+ - All size/TTL limits enforced; `stdout` carries protocol output only.
239
+
240
+ ## Development
241
+
242
+ ```bash
243
+ uv sync
244
+ uv run pytest
245
+ uv run ruff check .
246
+ uv run ruff format --check .
247
+ uv run pyright
248
+ uv build
249
+ ```
250
+
251
+ See `CHANGELOG.md` for release history.