antd-mcp 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.
@@ -0,0 +1,100 @@
1
+ # Rust
2
+ target/
3
+ target-dev/
4
+ **/*.rs.bk
5
+
6
+ # Python
7
+ __pycache__/
8
+ *.py[cod]
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+ *.egg
13
+ .venv/
14
+ venv/
15
+
16
+ # Node.js
17
+ node_modules/
18
+
19
+ # C# / .NET
20
+ bin/
21
+ obj/
22
+ *.user
23
+ *.suo
24
+ *.csproj.user
25
+
26
+ # IDE
27
+ .idea/
28
+ .vscode/
29
+ *.swp
30
+ *.swo
31
+ *~
32
+
33
+ # OS
34
+ .DS_Store
35
+ Thumbs.db
36
+
37
+ # Dart
38
+ .dart_tool/
39
+ pubspec.lock
40
+
41
+ # PHP
42
+ vendor/
43
+ composer.lock
44
+ composer-setup.php
45
+ composer.phar
46
+
47
+ # Elixir
48
+ _build/
49
+ deps/
50
+ .elixir_ls/
51
+ mix.lock
52
+ # antd-elixir is a library but commits its lock: CI and dev resolve the same tree
53
+ !antd-elixir/mix.lock
54
+
55
+ # Zig
56
+ .zig-cache/
57
+ zig-out/
58
+
59
+ # C++ CMake
60
+ build/
61
+ CMakeCache.txt
62
+ CMakeFiles/
63
+
64
+ # Ruby
65
+ Gemfile.lock
66
+ .bundle/
67
+
68
+ # Java
69
+ out/
70
+ .gradle/
71
+ *.class
72
+
73
+ # Claude
74
+ .claude/
75
+
76
+ # Lua
77
+ .luarocks/
78
+
79
+ # ant-dev state
80
+ .ant-dev/
81
+
82
+ # Logs
83
+ *.log
84
+
85
+ # Sweep script output dirs (scripts/full-stack-sweep.sh, scripts/integration-sweep.sh)
86
+ .full-stack-sweep-results/
87
+ .integration-results/
88
+
89
+ # built gems (publish-ruby.yml builds them in CI)
90
+ *.gem
91
+
92
+ # ffi/scripts/build-native-manylinux.sh output (per-arch libant_ffi.so for packaging)
93
+ ffi/rust/native-out/
94
+
95
+ # Third-party notices generated by scripts/third_party_notices/generate.py;
96
+ # the release workflow builds them.
97
+ /THIRD-PARTY-NOTICES*.txt
98
+ /RUST-STD-COPYRIGHT*.html
99
+ /antd/*.THIRD-PARTY-NOTICES.txt
100
+ /antd/*.RUST-STD-COPYRIGHT.html
@@ -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 describing the origin of the Work and
141
+ 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 Support. While redistributing the Work or
166
+ Derivative Works thereof, You may choose to offer, and charge a
167
+ fee for, acceptance of support, warranty, indemnity, or other
168
+ liability obligations and/or rights consistent with this License.
169
+ However, in accepting such obligations, You may act only on Your
170
+ own behalf and on Your sole responsibility, not on behalf of any
171
+ other Contributor, and only if You agree to indemnify, defend, and
172
+ hold each Contributor harmless for any liability incurred by, or
173
+ claims asserted against, such Contributor by reason of your accepting
174
+ any such warranty or support.
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 2026 Autonomi
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 implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Autonomi
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,311 @@
1
+ Metadata-Version: 2.5
2
+ Name: antd-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server that lets AI agents store and fetch data on the Autonomi network through the antd daemon
5
+ Project-URL: Homepage, https://autonomi.com
6
+ Project-URL: Repository, https://github.com/WithAutonomi/ant-sdk
7
+ Project-URL: Documentation, https://github.com/WithAutonomi/ant-sdk/tree/main/antd-mcp#readme
8
+ Project-URL: Issues, https://github.com/WithAutonomi/ant-sdk/issues
9
+ Project-URL: Changelog, https://github.com/WithAutonomi/ant-sdk/releases
10
+ Author: Autonomi
11
+ License-Expression: MIT OR Apache-2.0
12
+ License-File: LICENSE-APACHE
13
+ License-File: LICENSE-MIT
14
+ Keywords: ai-agents,antd,autonomi,decentralized,mcp,model-context-protocol,storage
15
+ Classifier: Development Status :: 4 - Beta
16
+ Classifier: Intended Audience :: Developers
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Topic :: System :: Distributed Computing
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: antd[rest]<0.5,>=0.4.0
28
+ Requires-Dist: anyio>=4
29
+ Requires-Dist: mcp<3,>=2
30
+ Provides-Extra: test
31
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'test'
32
+ Requires-Dist: pytest>=7.0; extra == 'test'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # antd-mcp — MCP Server for Autonomi
36
+
37
+ An [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server that exposes the Autonomi network as 31 tools for AI agents (19 storage tools, 10 pointer tools, and the 2 manifest tools when the installed SDK supports them). Works with Claude Desktop, Claude Code, and any MCP-compatible client.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ # Run without installing (recommended for MCP client configs)
43
+ uvx antd-mcp
44
+
45
+ # Or install as a tool
46
+ pipx install antd-mcp
47
+
48
+ # Or into an environment
49
+ pip install antd-mcp
50
+ ```
51
+
52
+ Python 3.10+. Pulls in the [`antd`](https://pypi.org/project/antd/) Python SDK (REST transport) automatically. Needs a running [antd](https://github.com/WithAutonomi/ant-sdk/tree/main/antd) daemon: see [Get the antd daemon](#get-the-antd-daemon). antd 0.17.0 or later supports every tool.
53
+
54
+ From a source checkout: `pip install -e antd-mcp/`.
55
+
56
+ Add it to Claude Code in one line:
57
+
58
+ ```bash
59
+ claude mcp add antd-autonomi -- uvx antd-mcp
60
+ ```
61
+
62
+ ## Get the antd daemon
63
+
64
+ antd-mcp reaches the Autonomi network through antd, a daemon that runs on the same computer. antd-mcp does not install or start it. Without one, every tool returns a `DAEMON_NOT_RUNNING` error that links here. Some clients also offer to open this page, once per session: those that support MCP URL-mode elicitation on a protocol before 2026-07-28. From 2026-07-28 a server can't prompt mid-call, so those clients, like any others, get the link as `help_url` in the error.
65
+
66
+ The easiest way to get antd is an installer from the [latest ant-sdk release](https://github.com/WithAutonomi/ant-sdk/releases/latest):
67
+
68
+ | OS | Download |
69
+ |----|----------|
70
+ | Windows (x64) | `antd-windows-x64-setup.msi` |
71
+ | macOS (Apple silicon) | `antd-macos.pkg` |
72
+ | Linux (x64) | `antd-linux-x64.deb` or `antd-linux-x64.rpm` |
73
+ | Linux (x64 or arm64) | `antd-linux-install.sh` |
74
+
75
+ The installer starts antd straight away, and again each time you log in. antd listens on `127.0.0.1:8082` and writes the `daemon.port` file, so antd-mcp finds it with no configuration. Ask the agent to try again once antd is running.
76
+
77
+ You can also download the plain binary from the same release (`antd-windows-amd64.exe`, `antd-darwin-arm64`, `antd-linux-amd64`, `antd-linux-arm64`). Check it against `SHA256SUMS`, then run `antd`.
78
+
79
+ Reading data needs no wallet. Storing data is paid for from the daemon's wallet; see [Wallet & EVM Configuration](https://github.com/WithAutonomi/ant-sdk/tree/main/antd#wallet--evm-configuration).
80
+
81
+ To check that the daemon is up, call the `check_health` tool, or run `curl http://127.0.0.1:8082/health`.
82
+
83
+ ## Running
84
+
85
+ ```bash
86
+ # stdio transport (default — for Claude Desktop)
87
+ antd-mcp
88
+
89
+ # Streamable HTTP transport (for web-based clients; the current MCP HTTP transport)
90
+ antd-mcp --http
91
+
92
+ # Legacy SSE transport
93
+ antd-mcp --sse
94
+ ```
95
+
96
+ ### Environment Variables
97
+
98
+ | Variable | Default | Description |
99
+ |----------|---------|-------------|
100
+ | `ANTD_BASE_URL` | auto-discovered | antd daemon URL (overrides port-file discovery) |
101
+
102
+ The MCP server automatically discovers the antd daemon via the `daemon.port` file written by antd on startup. Set `ANTD_BASE_URL` only if you need to override this (e.g. connecting to a remote daemon). If neither the env var nor port file is available, falls back to `http://127.0.0.1:8082`.
103
+
104
+ ## Claude Desktop Configuration
105
+
106
+ Add to your Claude Desktop config (`claude_desktop_config.json`):
107
+
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "antd-autonomi": {
112
+ "command": "uvx",
113
+ "args": ["antd-mcp"]
114
+ }
115
+ }
116
+ }
117
+ ```
118
+
119
+ The server will auto-discover the daemon via the port file. Add `"env": {"ANTD_BASE_URL": "http://your-host:port"}` only if you need to override discovery.
120
+
121
+ ## Tool Reference
122
+
123
+ ### Data Operations
124
+
125
+ | # | Tool | Description |
126
+ |---|------|-------------|
127
+ | 1 | `store_data(text, private?, payment_mode?)` | Store text on the network. With `private=True`, the returned `address` is the caller-held DataMap (not stored on-network — keep it safe). Also returns `sha256`, the plaintext's SHA-256 (hex); requires antd 0.17.0 or later, `null` on older daemons. |
128
+ | 2 | `retrieve_data(address, private?)` | Retrieve text by address. Pass `private=True` if `address` is a caller-held DataMap from a private store. |
129
+ | 3 | `upload_file(path, private?, payment_mode?)` | Upload a local file. With `private=True`, the returned `address` is the caller-held DataMap. Also returns `sha256`, the plaintext's SHA-256 (hex); requires antd 0.17.0 or later, `null` on older daemons. |
130
+ | 4 | `download_file(address, dest_path, private?)` | Download to local path — the **daemon** writes the file (daemon and MCP server must share a filesystem). Pass `private=True` if `address` is a caller-held DataMap from a private upload. |
131
+ | 5 | `stream_download_file(address, dest_path, private?)` | Like `download_file`, but streams the bytes back to the MCP server process and writes `dest_path` on **this** host with constant memory (suits large objects / no shared filesystem). Returns `bytes_written`. |
132
+ | 6 | `get_cost(text?, file_path?, payment_mode?)` | Estimate storage cost — returns `cost`, `file_size`, `chunk_count`, `estimated_gas_cost_wei`, `payment_mode` |
133
+ | 7 | `check_health()` | Check daemon health and network status |
134
+
135
+ ### Wallet Operations
136
+
137
+ | # | Tool | Description |
138
+ |---|------|-------------|
139
+ | 8 | `wallet_address()` | Get wallet public address |
140
+ | 9 | `wallet_balance()` | Get wallet token and gas balances |
141
+ | 10 | `wallet_approve()` | Approve wallet to spend tokens on payment contracts (one-time) |
142
+
143
+ ### Chunk Operations
144
+
145
+ | # | Tool | Description |
146
+ |---|------|-------------|
147
+ | 11 | `chunk_put(data)` | Store a raw chunk (base64 input) |
148
+ | 12 | `chunk_get(address)` | Retrieve a chunk (base64 output) |
149
+
150
+ ### External Signer (Two-Phase Upload)
151
+
152
+ | # | Tool | Description |
153
+ |---|------|-------------|
154
+ | 13 | `prepare_upload(path, visibility?)` | Prepare a file upload for external signing. Pass `visibility="public"` to bundle the DataMap chunk into the same payment batch (the `data_map_address` on finalize is the shareable retrieval handle). |
155
+ | 14 | `prepare_upload_public(path)` | Convenience wrapper for `prepare_upload(path, visibility="public")`. |
156
+ | 15 | `prepare_data_upload(text)` | Prepare a data upload for external signing |
157
+ | 16 | `finalize_upload(upload_id, tx_hashes)` | Finalize a wave-batch upload. Returns `address`, `chunks_stored`, `data_map`, and (for public uploads) `data_map_address`, plus `sha256`, the plaintext's SHA-256 (hex); requires antd 0.17.0 or later, `null` on older daemons. A partial store returns a `PARTIAL_UPLOAD` error (see [Partial uploads](#partial-uploads)). |
158
+ | 17 | `finalize_merkle_upload(upload_id, winner_pool_hash)` | Finalize a merkle-batch upload. Returns the same fields as `finalize_upload` (including `sha256`); same `PARTIAL_UPLOAD` behaviour. |
159
+ | 18 | `prepare_chunk_upload(data_base64)` | Prepare a single raw chunk for external-signer publish. Returns either `already_stored=True` (no payment needed) or a wave-batch payment intent. |
160
+ | 19 | `finalize_chunk_upload(upload_id, tx_hashes)` | Submit a prepared chunk to the network after external payment. Returns `address`. |
161
+
162
+ ### Pointers
163
+
164
+ A pointer is a small, owner-signed, mutable reference: its address never changes, and its owner can move its target (a chunk, such as a public `store_data` / `upload_file` address, or another pointer). The daemon holds the owner keys (`antd --pointer-keys`), so every write names the pointer by its address (`owner`). See [Pointer payments, counters and errors](#pointer-payments-counters-and-errors) before using the write tools.
165
+
166
+ | # | Tool | Description |
167
+ |---|------|-------------|
168
+ | 20 | `pointer_keys()` | List the pointer addresses this daemon holds owner keys for, so can write. Free. |
169
+ | 21 | `pointer_get(address, include_owner_key?)` | Read a pointer: `counter` (decimal string), `target`, `kind` / `kind_tag`, `state_id`, `is_final`, `transferred_to`. The owner's ML-DSA-65 public key (~3,900 hex chars) only with `include_owner_key=True`. Free. |
170
+ | 22 | `pointer_resolve(address)` | Follow forwardings and transfers to the target at the end of the chain: `target`, `kind`, `kind_tag`. Free. |
171
+ | 23 | `pointer_finality(address)` | Ask the whole close group where a pointer stands: `status` is `open`, `settling`, `unconfirmed`, `final`, `forked`, or `unknown` (daemon string in `raw_status`). Only `final` means a transfer is beyond dispute. Free. |
172
+ | 24 | `pointer_controller(address)` | Follow transfers to the pointer whose owner now decides: `pointer`, `transfers`, `frozen`. Free. |
173
+ | 25 | `pointer_create(owner, target, kind?)` | Create a pointer (`kind` `"chunk"`, the default, or `"pointer"`). **Pays** from the daemon wallet. `ALREADY_EXISTS` if it exists, refused before paying. |
174
+ | 26 | `pointer_update(owner, target, kind?)` | Point a pointer at a new target; creates it if missing. **Pays** from the daemon wallet. `POINTER_FINAL` once transferred or frozen, usually refused before paying. |
175
+ | 27 | `pointer_transfer(owner, recipient, confirm_irreversible?)` | **Irreversible.** Hand the pointer over to the recipient's pointer for good: it becomes final and its readers are sent on to the recipient. **Pays** from the daemon wallet. Refuses with `CONFIRMATION_REQUIRED`, sending nothing, unless `confirm_irreversible=true`. Returns the close group's `finality`. |
176
+ | 28 | `pointer_prepare(owner, op, target?, kind?, recipient?)` | External signer: the daemon signs `op` (`"create"` / `"update"` with `target`, or `"transfer"` with `recipient`) and quotes it. Returns `upload_id`, `counter` and wave-batch `payments`. Pays nothing itself; other writes to the pointer get `CONFLICT` until it is finalized or expires (one hour). |
177
+ | 29 | `pointer_finalize(upload_id, tx_hashes)` | External signer: store the prepared write after `payForQuotes()`. Returns `counter`, and `finality` for a transfer. |
178
+
179
+ ### Manifests
180
+
181
+ A manifest (a `.ant` file, or an `ant://manifest/` link to one) bundles files that are already on the network, each with an optional relative path. The `link` is what you share. Both tools are **free**: nothing is uploaded and nothing is paid, so neither asks for confirmation. They are annotated read-only. Upload the files first (`store_data`, `upload_file`) and pass the `address` (public) or `data_map` (private, embedded in the manifest) they returned.
182
+
183
+ | # | Tool | Description |
184
+ |---|------|-------------|
185
+ | 30 | `build_manifest(entries, name?, torrent_info_hashes?, embed_roots?)` | Each entry is `{path?, size?, sha256?, data_map? \| address?}`: give exactly one of `data_map` or `address`. `sha256` is the file's plaintext SHA-256 (hex) to record; requires antd 0.17.0 or later; it is passed through as given and the daemon rejects a malformed one with `BAD_REQUEST`. Returns `manifest_base64` (the `.ant` bytes), `link` (null when the manifest exceeds 1,500 bytes; share the file instead) and `entries` (each with `sha256`, the hash the manifest records or `null`; requires antd 0.17.0 or later). `embed_roots` defaults to true. A bad entry returns `BAD_REQUEST` with a message naming `entries[i]`. |
186
+ | 31 | `decode_manifest(manifest_base64? \| link?, resolve?)` | Give exactly one of the base64 `.ant` bytes or a `link` (manifest link, file link or bare address). Returns `source` (`manifest` or `file_link`), `name`, the torrent hashes and `entries` (each with `sha256`, the hash the manifest records or `null`; requires antd 0.17.0 or later). With `resolve=true` it also reads each entry's root from the network to fill in `exact_size`; one entry's failure is in its `error`, not a failed call. |
187
+
188
+ Unset sizes and unset `sha256` values are `null`, never 0 or an empty string. These tools need an antd daemon with the manifest API (antd 0.16.0 or later) and an [`antd`](https://pypi.org/project/antd/) Python SDK that has `build_manifest`. With an older SDK the server still starts and serves its other tools; it just does not register the manifest tools.
189
+
190
+ ### Payment Modes
191
+
192
+ The `store_data`, `upload_file`, and `get_cost` tools accept an optional `payment_mode` parameter:
193
+
194
+ | Mode | Behavior |
195
+ |------|----------|
196
+ | `"auto"` (default) | Uses merkle batch payments for 64+ chunks, single payments otherwise. Recommended for most use cases. |
197
+ | `"merkle"` | Forces merkle batch payments regardless of chunk count (minimum 2 chunks). Saves gas on larger uploads. |
198
+ | `"single"` | Forces per-chunk payments. Useful for small data or debugging. |
199
+
200
+ ## Response Format
201
+
202
+ All tools return JSON with a `network` field indicating the connected network:
203
+
204
+ ```json
205
+ {
206
+ "address": "abc123...",
207
+ "cost": "1000000",
208
+ "network": "local"
209
+ }
210
+ ```
211
+
212
+ Errors return structured error objects:
213
+
214
+ ```json
215
+ {
216
+ "error": "NOT_FOUND",
217
+ "message": "Resource not found",
218
+ "status_code": 404,
219
+ "network": "local"
220
+ }
221
+ ```
222
+
223
+ When no daemon answers, the error is `DAEMON_NOT_RUNNING`. Its `message` says which address was tried and where that address came from (`ANTD_BASE_URL`, the `daemon.port` file, or the default). It also carries a `hint` and a `help_url` pointing to [Get the antd daemon](#get-the-antd-daemon). The address is shown as scheme, host and port only, so credentials in `ANTD_BASE_URL` never appear in errors or logs. That request never reached a daemon. It says nothing about a payment already sent, such as the on-chain payment an external signer makes before `finalize_upload`: keep the `upload_id` and payment details, and reconcile before paying again. Never pay again on this error alone.
224
+
225
+ The `sha256` fields on upload and manifest results need both an antd daemon 0.17.0 or later and an [`antd`](https://pypi.org/project/antd/) Python SDK 0.4.0 or later. With an older daemon or SDK they are `null`.
226
+
227
+ ### Partial uploads
228
+
229
+ `finalize_upload` / `finalize_merkle_upload` can fail *after* the payment went through: some chunks store, others miss quorum after the daemon's own retries. The error object then carries the counts and a `retryable` flag so the agent can decide what to do:
230
+
231
+ ```json
232
+ {
233
+ "error": "PARTIAL_UPLOAD",
234
+ "message": "Partial upload: 300/312 chunks stored, 12 failed after retries: ...",
235
+ "status_code": 502,
236
+ "chunks_stored": 300,
237
+ "chunks_failed": 12,
238
+ "total_chunks": 312,
239
+ "retryable": true,
240
+ "retention_known": true,
241
+ "network": "local"
242
+ }
243
+ ```
244
+
245
+ The payment and the stored chunks persist either way.
246
+
247
+ - **`retryable: true`** — the daemon kept the paid attempt under the same `upload_id` (antd ≥ 0.14.0). Call the **same** finalize tool again with the **same arguments**; it stores the remainder against the same payment — no re-prepare, no second payment. Bound the retries: stop after a few attempts, or when `chunks_failed` stops shrinking. The retained attempt expires with the daemon's pending-upload TTL (one hour).
248
+ - **`retention_known: true`, `retryable: false`** — the daemon confirmed it kept nothing (e.g. a merkle finalize with deliberately unpaid batches). Run the prepare step again for the same content; already-stored chunks are skipped, so only the remainder is paid for.
249
+ - **`retention_known: false`** — retention is unknown. The daemon may still hold the paid attempt: it records the resume handle before it returns the error. Stop automatic recovery, keep the `upload_id` and the payment details you passed, and reconcile before preparing or paying again. Never pay again on this signal alone. Daemons older than 0.14.0 never send `retryable`, so their partial uploads read as unknown.
250
+
251
+ `retryable: true` always comes with `retention_known: true`.
252
+
253
+ These fields come from the antd SDK, which reads the daemon's response strictly. A count that is not a non-negative JSON integer (at most 2^64−1) reads as `0`. `retryable` is `true` only when the daemon sent the JSON literal `true`, and `retention_known` is `true` only when `retryable` was a JSON bool. A malformed partial-upload response therefore never shows up as `UNEXPECTED`. It arrives as `PARTIAL_UPLOAD` with the unreadable fields at `0` / `false` (an unreadable `retryable` means retention unknown). If the body is unreadable, or its `code` is not exactly `"PARTIAL_UPLOAD"`, it arrives as a plain `NETWORK_ERROR` without the partial-upload fields.
254
+
255
+ Full contract: `docs/external-signer-flow.md` §6 in the ant-sdk repo.
256
+
257
+ ### Pointer payments, counters and errors
258
+
259
+ The pointer tools need an antd daemon with the pointer API and an [`antd`](https://pypi.org/project/antd/) Python SDK 0.3.0 or later. With an older SDK the server still starts and serves the other 19 tools; it just does not register the pointer tools.
260
+
261
+ **Every write pays, and no tool retries.** `pointer_create`, `pointer_update` and `pointer_transfer` each pay from the daemon wallet, about the price of one chunk, with the same posture as `store_data` / `upload_file` / `chunk_put`: no confirmation step and no automatic retry. Every repeat pays again, so check the pointer (`pointer_get`) before repeating a failed write. The reads are free.
262
+
263
+ **Transfers are irreversible.** A transfer makes the pointer final forever: nobody, its owner included, can update or transfer it again, and its readers are sent on to the recipient's pointer. On top of the paid-tool posture, `pointer_transfer` refuses to run unless `confirm_irreversible` is `true`. Without it the tool sends and pays nothing and returns:
264
+
265
+ ```json
266
+ {
267
+ "error": "CONFIRMATION_REQUIRED",
268
+ "message": "pointer_transfer would hand the pointer <owner> over to <recipient> forever: ... Nothing was sent or paid. Confirm with the user, then call again with confirm_irreversible=true.",
269
+ "network": "local"
270
+ }
271
+ ```
272
+
273
+ The tool is also annotated `destructiveHint: true`, `idempotentHint: false` for clients that prompt on those hints.
274
+
275
+ **Counters are decimal strings**, never JSON numbers. A final pointer (transferred or frozen) sits at counter `"18446744073709551615"` (2^64−1), which JSON clients that read numbers as doubles, and LLMs, round. Compare counters as strings of digits or as big integers. An unset counter (finality other than `open`) is `null`.
276
+
277
+ **Errors.** Four pointer-era codes carry a `hint` saying what to do next:
278
+
279
+ | `error` | HTTP | Meaning |
280
+ |---------|------|---------|
281
+ | `POINTER_FINAL` | 409 | The pointer is transferred or frozen; nothing can change it. Usually refused before paying, but a write already paid for when the network refused it keeps that payment. Do not retry. |
282
+ | `POINTER_FORKED` | 409 | The owner signed two different final states and no majority holds either. Do not retry. |
283
+ | `CONFLICT` | 409 | A prepared write to the pointer awaits payment (refused before paying), or an update lost to a newer state while in flight (possibly after paying). The `hint` says which; read the pointer before paying for another write. |
284
+ | `CLOSE_GROUP_SHORTFALL` | 503 | Too few of the close group answered or stored. Carries `retryable`. |
285
+
286
+ `CLOSE_GROUP_SHORTFALL` with `retryable: true` comes only from `pointer_finalize`. It means **retry the finalize, the payment was kept**: call `pointer_finalize` again with the same `upload_id` and the daemon stores the paid state against the same payment, with no second payment. Bound the retries; the kept attempt expires after one hour.
287
+
288
+ ```json
289
+ {
290
+ "error": "CLOSE_GROUP_SHORTFALL",
291
+ "message": "Close group shortfall: ... (paid attempt retained: call finalize again with the same upload_id ...)",
292
+ "status_code": 503,
293
+ "retryable": true,
294
+ "hint": "Retry the finalize, the payment was kept: call pointer_finalize again with the same upload_id ...",
295
+ "network": "local"
296
+ }
297
+ ```
298
+
299
+ With `retryable: false`, a read is free to retry later, but do not repeat a paid write automatically: it may already have been paid for. A create of an existing pointer stays `ALREADY_EXISTS`.
300
+
301
+ ## Project Structure
302
+
303
+ ```
304
+ antd-mcp/
305
+ ├── pyproject.toml
306
+ └── src/antd_mcp/
307
+ ├── __init__.py
308
+ ├── server.py # 29 MCP tool definitions
309
+ ├── discover.py # Daemon port-file discovery
310
+ └── errors.py # Error formatting
311
+ ```