chain-insights 0.8.22 → 0.18.19
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.
- package/README.md +344 -190
- package/dist/action-log-Dfe88TwV.cjs +109 -0
- package/dist/action-log-diTHyMbV.mjs +93 -0
- package/dist/action-log-diTHyMbV.mjs.map +1 -0
- package/dist/{app-CCXmYEV1.mjs → app-CJwx_2Rr.mjs} +2 -2
- package/dist/{app-CCXmYEV1.mjs.map → app-CJwx_2Rr.mjs.map} +1 -1
- package/dist/{app-BNrqZ_LR.cjs → app-D4Cm69ob.cjs} +1 -1
- package/dist/{artifact-server-DR13HEei.mjs → artifact-server-D1D-_t5l.mjs} +2 -2
- package/dist/{artifact-server-DR13HEei.mjs.map → artifact-server-D1D-_t5l.mjs.map} +1 -1
- package/dist/{artifact-server-B4YVpWK2.cjs → artifact-server-sJBFGcum.cjs} +1 -1
- package/dist/{call-args-DyU9d6tT.cjs → call-args-DAiQSDmD.cjs} +4 -2
- package/dist/{call-args-D3UajHDq.mjs → call-args-ysbB_xdA.mjs} +5 -3
- package/dist/call-args-ysbB_xdA.mjs.map +1 -0
- package/dist/{capabilities-CjIcF3da.cjs → capabilities-BR985-bW.cjs} +26 -37
- package/dist/{capabilities-GuF58uDa.mjs → capabilities-rLNPG-O2.mjs} +16 -37
- package/dist/capabilities-rLNPG-O2.mjs.map +1 -0
- package/dist/cases-C1XewLdx.mjs +155 -0
- package/dist/cases-C1XewLdx.mjs.map +1 -0
- package/dist/cases-CVtc7Rf8.cjs +160 -0
- package/dist/cli.cjs +217 -167
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +217 -167
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-C_HEuq0f.mjs → client-BD9FLUt2.mjs} +131 -12
- package/dist/client-BD9FLUt2.mjs.map +1 -0
- package/dist/{client-rVqMG2j9.cjs → client-DLqndaSv.cjs} +130 -11
- package/dist/config-CwIb-tav.mjs +33 -0
- package/dist/config-CwIb-tav.mjs.map +1 -0
- package/dist/config-Cy-qzx4W.cjs +33 -0
- package/dist/{config-BFi5yBMm.mjs → config-DA6KRx60.mjs} +2 -2
- package/dist/{config-BFi5yBMm.mjs.map → config-DA6KRx60.mjs.map} +1 -1
- package/dist/{config-B8Hk-G1y.cjs → config-DE0dUT3P.cjs} +1 -1
- package/dist/{html-generator-DjWagEB5.mjs → html-generator-ClysZjfY.mjs} +3 -2
- package/dist/html-generator-ClysZjfY.mjs.map +1 -0
- package/dist/{html-generator-DF0F6nUI.cjs → html-generator-Ui29DLSD.cjs} +2 -1
- package/dist/index.cjs +9 -7
- package/dist/index.d.cts +66 -13
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +66 -13
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -8
- package/dist/init-9jY5rCcH.cjs +24 -0
- package/dist/init-BiRfMQcA.mjs +26 -0
- package/dist/init-BiRfMQcA.mjs.map +1 -0
- package/dist/{init-s0SU97fS.cjs → init-HVwOeOyo.cjs} +65 -80
- package/dist/{init-BWFFHDtL.mjs → init-Jp_AIMZ7.mjs} +66 -81
- package/dist/init-Jp_AIMZ7.mjs.map +1 -0
- package/dist/limits-D3Mn-gig.mjs +94 -0
- package/dist/limits-D3Mn-gig.mjs.map +1 -0
- package/dist/limits-km3pmmL3.cjs +115 -0
- package/dist/lock-Cs-a3Ng1.cjs +38 -0
- package/dist/lock-D_sWGS7W.mjs +40 -0
- package/dist/lock-D_sWGS7W.mjs.map +1 -0
- package/dist/mcp-proxy.cjs +79 -371
- package/dist/mcp-proxy.d.cts +4 -1
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts +4 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +79 -372
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/merge-B_5kxbGv.cjs +202 -0
- package/dist/merge-CJRZpuZ4.mjs +199 -0
- package/dist/merge-CJRZpuZ4.mjs.map +1 -0
- package/dist/paths-CffVTUCv.cjs +31 -0
- package/dist/paths-_3isihzD.mjs +21 -0
- package/dist/paths-_3isihzD.mjs.map +1 -0
- package/dist/public-tools-B9_wXs2o.mjs +1154 -0
- package/dist/public-tools-B9_wXs2o.mjs.map +1 -0
- package/dist/public-tools-CgiKgYgf.cjs +1154 -0
- package/dist/render-TmSq0f4f.cjs +207 -0
- package/dist/render-mxE0Tdsf.mjs +206 -0
- package/dist/render-mxE0Tdsf.mjs.map +1 -0
- package/dist/report-BFXFrJmj.mjs +36 -0
- package/dist/report-BFXFrJmj.mjs.map +1 -0
- package/dist/report-BwKQqOCR.cjs +36 -0
- package/dist/runner-CSss8Hvy.mjs +33 -0
- package/dist/runner-CSss8Hvy.mjs.map +1 -0
- package/dist/runner-aErdz2zn.cjs +31 -0
- package/dist/{schema-zWbVYCQW.mjs → schema-0BVyF-aL.mjs} +38 -2
- package/dist/schema-0BVyF-aL.mjs.map +1 -0
- package/dist/{schema-Dj2mqv1g.cjs → schema-DF0aOXII.cjs} +37 -1
- package/dist/{server-CGGSh1TZ.mjs → server-BXj6BRI1.mjs} +2 -2
- package/dist/{server-CGGSh1TZ.mjs.map → server-BXj6BRI1.mjs.map} +1 -1
- package/dist/{server-BkljWFmU.cjs → server-ta1oyJ2a.cjs} +1 -1
- package/dist/templates/graph.html +46 -3
- package/dist/{tool-visibility-9-rvB91K.mjs → tool-visibility-C0ALejXI.mjs} +12 -36
- package/dist/tool-visibility-C0ALejXI.mjs.map +1 -0
- package/dist/{tool-visibility-Cl2p7Ghx.cjs → tool-visibility-DMIEexib.cjs} +11 -35
- package/dist/{tools-e87fylVa.cjs → tools-BPfUpCUR.cjs} +12 -0
- package/dist/{tools-B4rwKdvU.mjs → tools-CWwX4yth.mjs} +2 -2
- package/dist/{tools-B4rwKdvU.mjs.map → tools-CWwX4yth.mjs.map} +1 -1
- package/dist/{topup-server-R3dNp-p8.mjs → topup-server-D2X7My7i.mjs} +3 -2
- package/dist/{topup-server-R3dNp-p8.mjs.map → topup-server-D2X7My7i.mjs.map} +1 -1
- package/dist/{topup-server-B8anfXcq.cjs → topup-server-VGl8-Fz5.cjs} +2 -1
- package/dist/{viz-Cvb81rMm.mjs → viz-Cq1jSWSH.mjs} +11 -7
- package/dist/viz-Cq1jSWSH.mjs.map +1 -0
- package/dist/{viz-C9m5OuQT.cjs → viz-HSwLcKr6.cjs} +10 -6
- package/docs/architecture.md +7 -8
- package/docs/contributing.md +1 -4
- package/docs/debugging.md +47 -2
- package/docs/development.md +38 -0
- package/docs/graph-query-compatibility.md +222 -0
- package/docs/graph-tools.md +34 -154
- package/docs/images/quickstart-demo.svg +1 -0
- package/docs/investigation-workspaces.md +35 -0
- package/docs/mcp-proxy.md +27 -41
- package/docs/monitoring.md +279 -0
- package/docs/search-limits.md +73 -0
- package/docs/stability.md +71 -0
- package/package.json +36 -15
- package/skills/chain-insights-address-risk/SKILL.md +12 -11
- package/skills/chain-insights-bittensor-cypher/SKILL.md +152 -61
- package/skills/chain-insights-cypher/SKILL.md +122 -44
- package/skills/chain-insights-cypher/references/gql-translation-matrix.md +22 -0
- package/skills/chain-insights-cypher/references/memgraph-examples.md +46 -57
- package/skills/chain-insights-developer-experience/SKILL.md +44 -11
- package/skills/chain-insights-investigation/SKILL.md +39 -26
- package/skills/chain-insights-investigation/scripts/run-target-uat.sh +11 -11
- package/skills/chain-insights-monitoring/SKILL.md +160 -0
- package/skills/chain-insights-monitoring/references/pm2-scheduling.md +100 -0
- package/skills/test-chain-insights-graph/SKILL.md +40 -11
- package/skills/test-chain-insights-graph/scripts/run-uat.sh +102 -155
- package/dist/call-args-D3UajHDq.mjs.map +0 -1
- package/dist/capabilities-GuF58uDa.mjs.map +0 -1
- package/dist/client-C_HEuq0f.mjs.map +0 -1
- package/dist/html-generator-DjWagEB5.mjs.map +0 -1
- package/dist/init-BWFFHDtL.mjs.map +0 -1
- package/dist/public-tools-CXD65Dfk.cjs +0 -2672
- package/dist/public-tools-DScJ1mRk.mjs +0 -2669
- package/dist/public-tools-DScJ1mRk.mjs.map +0 -1
- package/dist/schema-zWbVYCQW.mjs.map +0 -1
- package/dist/tool-visibility-9-rvB91K.mjs.map +0 -1
- package/dist/viz-Cvb81rMm.mjs.map +0 -1
- package/skills/chain-insights-trace-funds/SKILL.md +0 -135
package/README.md
CHANGED
|
@@ -1,49 +1,238 @@
|
|
|
1
1
|
# Chain Insights
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/chain-insights)
|
|
4
|
+
[](https://github.com/chainswarm/chain-insights/actions/workflows/verify.yml)
|
|
5
|
+
[](https://securityscorecards.dev/viewer/?uri=github.com/chainswarm/chain-insights)
|
|
6
|
+
[](https://github.com/chainswarm/chain-insights/blob/main/LICENSE)
|
|
7
|
+
|
|
3
8
|
[Website](https://chain-insights.ai) | [npm](https://www.npmjs.com/package/chain-insights)
|
|
4
9
|
|
|
5
10
|
Chain Insights is an open-source AML investigation toolkit for AI agents and
|
|
6
|
-
analysts.
|
|
7
|
-
|
|
11
|
+
analysts. It screens blockchain addresses, explores fund flows through graph
|
|
12
|
+
queries, manages local evidence workspaces, and generates graph reports.
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
All shell snippets in this documentation are for **Linux** (bash). They work
|
|
17
|
+
as-is on macOS; on Windows use WSL.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx chain-insights@latest --help # run without installing
|
|
21
|
+
npm install -g chain-insights # or install the cia CLI globally
|
|
22
|
+
cia init ~/cases # scaffold an investigation workspace
|
|
23
|
+
cia networks # supported networks + public tool surface
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
Sixty seconds gets you the CLI, a workspace, and the live tool catalog.
|
|
29
|
+
To call the same tools from an agent, register the MCP proxy:
|
|
30
|
+
`cia setup claude-code` (or `codex` / `hermes`).
|
|
31
|
+
|
|
32
|
+
## Purpose And Ownership
|
|
8
33
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
`graphMcpEndpoint` or `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT`.
|
|
34
|
+
One public npm package (`chain-insights`) providing the `cia` CLI and a
|
|
35
|
+
stdio MCP proxy over a Chain Insights Graph endpoint.
|
|
12
36
|
|
|
13
|
-
|
|
37
|
+
Owning group: chainswarm org, infra group.
|
|
38
|
+
|
|
39
|
+
## What It Does
|
|
40
|
+
|
|
41
|
+
Owns:
|
|
42
|
+
|
|
43
|
+
- The `cia` / `chain-insights` CLI and the `chain-insights-mcp-proxy` MCP
|
|
44
|
+
server (source under `src/`).
|
|
45
|
+
- The canonical public tool surface: prefixed `aml_*` / `graph_*` / `meta_*`
|
|
46
|
+
/ `wallet_*` tools.
|
|
47
|
+
- Local wallet and payment on Base mainnet (payment chain only).
|
|
48
|
+
- Investigation workspaces, graph reports, and visualization.
|
|
49
|
+
- `cia monitor`: per-case tracking with rendered dossiers on an external
|
|
50
|
+
schedule.
|
|
51
|
+
- Shipped product skills under `skills/` (`chain-insights-*`), packaged
|
|
52
|
+
into the npm tarball.
|
|
53
|
+
- The local Bittensor graph devkit under `devkit/`.
|
|
54
|
+
|
|
55
|
+
Never touches:
|
|
56
|
+
|
|
57
|
+
- Blockchain indexing, graph database storage, or graph serving — those
|
|
58
|
+
belong to the Chain Insights Graph backend.
|
|
59
|
+
- Automatic risk labeling. Address labels are served by the Chain Insights
|
|
60
|
+
Graph backend and read through `aml_address_risk`; the CLI never writes
|
|
61
|
+
labels.
|
|
62
|
+
- Custodial wallets or hosted case databases. Investigation data stays in
|
|
63
|
+
the local workspace unless the operator exports it.
|
|
64
|
+
|
|
65
|
+
### What You Can Do Today
|
|
14
66
|
|
|
15
67
|
| Tool | Use it for |
|
|
16
68
|
| --- | --- |
|
|
17
69
|
| `aml_address_risk` | Screen one address for risk, behavior, neighborhood context, and exchange exposure |
|
|
18
|
-
| `aml_trace_victim_funds` | Trace victim/source funds forward to exchange deposit candidates |
|
|
19
|
-
| `aml_trace_deposit_sources` | Trace backward from suspected deposit/cashout addresses to upstream sources and convergence |
|
|
20
|
-
| `aml_trace_suspect_funds` | Trace suspected scammer, mule, operator, or laundering-ring funds forward to cashout topology |
|
|
21
70
|
| `graph_query` | Run one read-only GQL/Cypher query against a Chain Insights Graph layer |
|
|
22
71
|
| `graph_query_batch` | Run related read-only graph queries as one MCP call |
|
|
23
72
|
| `meta_network_capabilities` | Check supported Chain Insights networks and graph tools |
|
|
24
73
|
| `meta_usage_status` | Check the caller's daily free-tier graph query allowance |
|
|
74
|
+
| `meta_help` | Show Chain Insights tool and workflow guidance |
|
|
25
75
|
| `wallet_balance` | Show the local payment wallet amount |
|
|
26
76
|
|
|
27
|
-
|
|
77
|
+
### Continuous Monitoring
|
|
28
78
|
|
|
29
|
-
|
|
79
|
+
`cia monitor` re-renders each open case's dossier on a schedule. It turns one
|
|
80
|
+
investigation into a standing view: seeds, scope changes, and render state
|
|
81
|
+
stay as plain files in the workspace.
|
|
30
82
|
|
|
31
|
-
|
|
32
|
-
|
|
83
|
+
| Command | What it does |
|
|
84
|
+
| --- | --- |
|
|
85
|
+
| `cia monitor run` | One pass: render the dossier of every open case |
|
|
86
|
+
| `cia monitor status` | Open cases and the last run |
|
|
87
|
+
| `cia monitor render` | Re-render all open cases (or one case) from the case document |
|
|
88
|
+
| `cia monitor init victim` | Bootstrap a stolen-funds case-tracking config in one command |
|
|
89
|
+
| `cia monitor case add` | Register a monitor case with one or more seed addresses |
|
|
90
|
+
| `cia monitor case list` | List monitor cases (open by default, `--all` for closed) |
|
|
91
|
+
| `cia monitor case add-seed` | Widen an open case's seed set, timestamped |
|
|
92
|
+
| `cia monitor case remove-seed` | Narrow an open case's seed set |
|
|
93
|
+
| `cia monitor case close` | Close a case; passes skip it |
|
|
94
|
+
|
|
95
|
+
Three things to know before scheduling it:
|
|
96
|
+
|
|
97
|
+
- **`cia monitor run` is a one-shot.** One pass, then exit. Schedule it with
|
|
98
|
+
cron, pm2 (`cron_restart` plus `autorestart: false`), or your agent
|
|
99
|
+
harness's scheduled tasks.
|
|
100
|
+
- **Exit `2` means an isolated case failed** while every other case
|
|
101
|
+
completed. Partial success, not a crash. Only exit `1` means nothing ran.
|
|
102
|
+
- **An unchanged case is skipped, not re-rendered.** The run document
|
|
103
|
+
records `skipped_reason: 'unchanged'`, so a quiet watch reads as healthy
|
|
104
|
+
by design.
|
|
105
|
+
|
|
106
|
+
See [Continuous monitoring](docs/monitoring.md) for the full surface.
|
|
107
|
+
|
|
108
|
+
## Dependencies
|
|
109
|
+
|
|
110
|
+
Upstream:
|
|
111
|
+
|
|
112
|
+
- **Chain Insights Graph MCP endpoint** — all graph queries and AML
|
|
113
|
+
primitives. Configured via `graphMcpEndpoint`; defaults to a local
|
|
114
|
+
endpoint.
|
|
115
|
+
- **Base mainnet RPC** — wallet balance and payment only
|
|
116
|
+
(`BASE_RPC_URL` override). Not a graph-support claim.
|
|
117
|
+
- **Devkit fixture data** — pre-generated from the upstream export path
|
|
118
|
+
and committed under `devkit/data/`.
|
|
119
|
+
|
|
120
|
+
Downstream:
|
|
121
|
+
|
|
122
|
+
- Analysts and AI agents install the npm package and call the CLI or the
|
|
123
|
+
MCP tools.
|
|
124
|
+
- Monitor case dossiers render as Markdown under the workspace
|
|
125
|
+
(`published/cases/<case_id>/`), ready for review and handoff.
|
|
126
|
+
|
|
127
|
+
## Architecture
|
|
128
|
+
|
|
129
|
+
Chain Insights is the investigation layer above the Chain Insights Graph.
|
|
130
|
+
The CLI and MCP proxy call graph tools over one MCP endpoint, keep all
|
|
131
|
+
evidence in local workspace folders, and never write to the graph.
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
Agent or CLI user
|
|
135
|
+
-> Chain Insights CLI / MCP proxy
|
|
136
|
+
-> local config, wallet, workspace, artifacts, reports
|
|
137
|
+
-> Chain Insights Graph
|
|
138
|
+
-> graph intelligence for AML workflows
|
|
33
139
|
```
|
|
34
140
|
|
|
35
|
-
|
|
141
|
+
Source modules (hand-maintained):
|
|
36
142
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
143
|
+
| Module | Entrypoint | Component doc |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| `config` | `src/config` | [components/config.md](docs/architecture/components/config.md) |
|
|
146
|
+
| `federation` | `src/federation` | [components/federation.md](docs/architecture/components/federation.md) |
|
|
147
|
+
| `investigation` | `src/investigation` | [components/investigation.md](docs/architecture/components/investigation.md) |
|
|
148
|
+
| `mcp` | `src/mcp` | [components/mcp.md](docs/architecture/components/mcp.md) |
|
|
149
|
+
| `monitor` | `src/monitor` | [components/monitor.md](docs/architecture/components/monitor.md) |
|
|
150
|
+
| `server` | `src/server` | [components/server.md](docs/architecture/components/server.md) |
|
|
151
|
+
| `viz` | `src/viz` | [components/viz.md](docs/architecture/components/viz.md) |
|
|
152
|
+
| `wallet` | `src/wallet` | [components/wallet.md](docs/architecture/components/wallet.md) |
|
|
153
|
+
|
|
154
|
+
Entry points:
|
|
155
|
+
|
|
156
|
+
- `bin/cli.js` → `src/cli.ts` (CLI bins: `cia`, `chain-insights`).
|
|
157
|
+
- `bin/mcp-proxy.cjs` → `src/mcp/proxy.ts` (bin:
|
|
158
|
+
`chain-insights-mcp-proxy`).
|
|
159
|
+
- `src/index.ts` — library exports.
|
|
160
|
+
|
|
161
|
+
Full architecture docs: [docs/architecture/](docs/architecture/ARCHITECTURE.md),
|
|
162
|
+
including C4 diagrams, [data contracts](docs/architecture/data-contracts.md),
|
|
163
|
+
and [operating rules](docs/architecture/operating-rules.md).
|
|
164
|
+
|
|
165
|
+
### Graph Access
|
|
166
|
+
|
|
167
|
+
Graph queries choose the read graph explicitly:
|
|
168
|
+
|
|
169
|
+
| Graph | Use it for |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| `topology` | The unified address / FLOWS_TO / LINKED graph — recent and full historical fund-flow traversal, plus the node `risk_score`/`risk_level` verdict |
|
|
172
|
+
| `facts` | Labels, features, assets, and enrichment |
|
|
173
|
+
|
|
174
|
+
One rule is worth reading before writing a query by hand: the `network`
|
|
175
|
+
argument selects the graph, not the addresses inside it. The address-space
|
|
176
|
+
split lives on the `:Address.network` node property. A `USE topology` match
|
|
177
|
+
on `:Address` without an exact address must scope itself with
|
|
178
|
+
`WHERE a.network = "..."`. On `USE facts` each network has its own backing
|
|
179
|
+
database and `Address` carries no `network` property at all. See
|
|
180
|
+
[Graph query compatibility](docs/graph-query-compatibility.md).
|
|
181
|
+
|
|
182
|
+
Agent installs include `chain-insights-cypher` for generic layer-aware
|
|
183
|
+
GQL/Cypher work and `chain-insights-bittensor-cypher` for Bittensor-specific
|
|
184
|
+
schema notes and examples (the bundled devkit serves a Bittensor fixture).
|
|
185
|
+
|
|
186
|
+
## Billing: Billable Units
|
|
187
|
+
|
|
188
|
+
Chain Insights Graph bills by **billable units**.
|
|
189
|
+
|
|
190
|
+
- A **billable unit** is one row, node, or edge in your returned payload.
|
|
191
|
+
- Bigger responses cost more. Narrow queries cost less.
|
|
192
|
+
- The server reports `billable_units` on every graph response.
|
|
193
|
+
|
|
194
|
+
**Check your own count.** `src/lib/recount-units.ts` mirrors the server's
|
|
195
|
+
counting logic. Use it client-side to recount units in a response and
|
|
196
|
+
confirm the billed amount matches what you received.
|
|
41
197
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
prompts before updating.
|
|
198
|
+
**Watch for `truncated: true`.** A response can hit the row limit and get
|
|
199
|
+
cut off. When you see `truncated: true`:
|
|
45
200
|
|
|
46
|
-
|
|
201
|
+
- Narrow the query with `LIMIT` to ask for fewer rows.
|
|
202
|
+
- Page through results with `SKIP` to fetch the next batch.
|
|
203
|
+
- Add a tighter `WHERE` filter before raising the limit.
|
|
204
|
+
|
|
205
|
+
**Workflow tools carry a `usage` block.** `aml_address_risk` runs many graph
|
|
206
|
+
queries behind the scenes to answer one question. Every response includes a
|
|
207
|
+
`usage` block with the total cost of all of them:
|
|
208
|
+
|
|
209
|
+
- **`billable_units`** — total units billed across every internal graph
|
|
210
|
+
query this workflow ran.
|
|
211
|
+
- **`query_count`** — how many internal graph queries it took.
|
|
212
|
+
- **`truncated_queries`** — how many of those internal queries hit their
|
|
213
|
+
row limit and got cut off.
|
|
214
|
+
|
|
215
|
+
Use `usage` to see the real cost of a workflow call, not just of one
|
|
216
|
+
`graph_query`.
|
|
217
|
+
|
|
218
|
+
## Prerequisites And Environment Setup
|
|
219
|
+
|
|
220
|
+
- **Linux** is the reference platform; shell snippets use bash (macOS works
|
|
221
|
+
the same; on Windows use WSL).
|
|
222
|
+
- **Node.js 22 or newer** (`package.json` engines) and npm.
|
|
223
|
+
- Optional: Docker with the Compose plugin, for the local devkit backend.
|
|
224
|
+
- Optional: pm2 or cron, for standing-watch monitoring.
|
|
225
|
+
|
|
226
|
+
`.env.example` documents the two supported overrides:
|
|
227
|
+
|
|
228
|
+
| Variable | Purpose |
|
|
229
|
+
| --- | --- |
|
|
230
|
+
| `BASE_RPC_URL` | Base RPC override for wallet balance and the local top-up page |
|
|
231
|
+
| `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` | Chain Insights Graph endpoint override; local HTTP loopback allowed, remote hosts must use `https://` |
|
|
232
|
+
|
|
233
|
+
## Run
|
|
234
|
+
|
|
235
|
+
### Local (from a checkout)
|
|
47
236
|
|
|
48
237
|
```bash
|
|
49
238
|
npm install
|
|
@@ -52,250 +241,215 @@ npm install -g .
|
|
|
52
241
|
cia --version
|
|
53
242
|
```
|
|
54
243
|
|
|
55
|
-
|
|
244
|
+
Or install the released package:
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
npm install -g chain-insights
|
|
248
|
+
cia --version
|
|
249
|
+
cia update --check
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Create an investigation workspace and run a first screen:
|
|
56
253
|
|
|
57
254
|
```bash
|
|
58
255
|
mkdir -p ./chain-insights-investigations
|
|
59
256
|
cd ./chain-insights-investigations
|
|
60
257
|
cia init .
|
|
61
|
-
```
|
|
62
258
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
published outputs.
|
|
259
|
+
cia mcp call aml_address_risk \
|
|
260
|
+
network=robinhood address=0xYourAddressHere
|
|
66
261
|
|
|
67
|
-
|
|
262
|
+
find reports -maxdepth 3 -type f | sort
|
|
263
|
+
```
|
|
68
264
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
265
|
+
Workspaces are plain local folders. Reports, graph JSON, graph HTML, and
|
|
266
|
+
published bundles live under the initialized workspace. Export only when
|
|
267
|
+
you need to share, hand off, or archive a review checkpoint — the handoff
|
|
268
|
+
package lands under `published/<workspace-slug>/`.
|
|
72
269
|
|
|
73
|
-
|
|
270
|
+
Example queries. Direct topology:
|
|
74
271
|
|
|
75
272
|
```bash
|
|
76
|
-
cia
|
|
273
|
+
cia mcp call graph_query \
|
|
274
|
+
network=robinhood \
|
|
275
|
+
"query=USE topology MATCH (a:Address) RETURN a.address AS address, a.network AS network, a.labels AS labels, a.risk_level AS risk_level LIMIT 10"
|
|
77
276
|
```
|
|
78
277
|
|
|
79
|
-
|
|
80
|
-
runbook and point Chain Insights at it persistently:
|
|
278
|
+
Batch across graph views:
|
|
81
279
|
|
|
82
280
|
```bash
|
|
83
|
-
cia
|
|
281
|
+
cia mcp call graph_query_batch \
|
|
282
|
+
network=robinhood \
|
|
283
|
+
'queries=[{"id":"count","query":"USE topology MATCH (a:Address) RETURN count(a) AS count LIMIT 1"},{"id":"flows","query":"USE topology MATCH (src:Address)-[f:FLOWS_TO]->(dst:Address) RETURN src.address AS source, dst.address AS target, f.amount_usd_sum AS amount_usd_sum, f.tx_count AS tx_count LIMIT 3"},{"id":"linked","query":"USE topology MATCH (a:Address)-[l:LINKED]-(b:Address) RETURN a.address AS address, b.address AS linked_address, l.basis AS basis, l.confidence AS confidence LIMIT 3"},{"id":"node_metrics","query":"USE topology MATCH (a:Address {address:\"FULL_ADDRESS\"}) RETURN a.address AS address, a.tx_out_count AS tx_out_count, a.tx_in_count AS tx_in_count LIMIT 1"}]'
|
|
84
284
|
```
|
|
85
285
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
`debug on` just skips payment negotiation outright.
|
|
286
|
+
More query examples (manual fund-flow reads, pagination):
|
|
287
|
+
[Graph tools](docs/graph-tools.md).
|
|
89
288
|
|
|
90
|
-
|
|
289
|
+
### Dev Compose (local devkit backend)
|
|
91
290
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
291
|
+
The devkit runs a deterministic local Bittensor Chain Insights Graph
|
|
292
|
+
backend. Compose file: `devkit/docker-compose.yml` (default compose
|
|
293
|
+
project network). Services: `starrocks`, `memgraph`,
|
|
294
|
+
`starrocks-import`, `memgraph-import` (one-shot), and
|
|
295
|
+
`chain-insights-graph-devkit`. Images build locally with
|
|
296
|
+
`docker compose build` — never pulled from a registry.
|
|
95
297
|
|
|
96
|
-
|
|
97
|
-
live yet.
|
|
298
|
+
Start from a clean state:
|
|
98
299
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
300
|
+
```bash
|
|
301
|
+
docker compose -f devkit/docker-compose.yml down -v --remove-orphans
|
|
302
|
+
docker compose -f devkit/docker-compose.yml up -d --build
|
|
303
|
+
```
|
|
103
304
|
|
|
104
|
-
|
|
305
|
+
One-shot import services must exit 0. `starrocks`, `memgraph`, and
|
|
306
|
+
`chain-insights-graph-devkit` must stay running. The MCP endpoint is
|
|
307
|
+
`http://127.0.0.1:18012/mcp`, unmetered:
|
|
105
308
|
|
|
106
309
|
```bash
|
|
107
|
-
export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=
|
|
310
|
+
export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=http://127.0.0.1:18012/mcp
|
|
108
311
|
```
|
|
109
312
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
- `http://` is accepted only for `localhost` / loopback addresses.
|
|
113
|
-
- Remote hosts must use `https://`.
|
|
114
|
-
- Endpoint URLs with credentials, query strings, or fragments are rejected.
|
|
313
|
+
Full contract and procedures live in the devkit directory's own README.
|
|
115
314
|
|
|
116
|
-
|
|
315
|
+
## Configure
|
|
117
316
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
3. Local default `http://127.0.0.1:8012/mcp`
|
|
317
|
+
`cia` uses `graphMcpEndpoint` for all Chain Insights Graph calls. The npm
|
|
318
|
+
package does not hardcode a hosted endpoint.
|
|
121
319
|
|
|
122
|
-
|
|
320
|
+
Local development endpoint (default):
|
|
123
321
|
|
|
124
322
|
```bash
|
|
125
|
-
cia config
|
|
126
|
-
cia mcp networks
|
|
127
|
-
cia mcp call meta_usage_status
|
|
128
|
-
cia mcp tools --refresh
|
|
323
|
+
cia config set graphMcpEndpoint http://127.0.0.1:8012/mcp
|
|
129
324
|
```
|
|
130
325
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
without a reachable Chain Insights Graph endpoint.
|
|
134
|
-
|
|
135
|
-
Hosted Chain Insights Graph includes a small public free tier for `graph_query`
|
|
136
|
-
before paid access is required. The default public free tier is 10 execution seconds
|
|
137
|
-
per IP per UTC day. Use `meta_usage_status` to see the current caller allowance.
|
|
138
|
-
Prepared wallet users receive the daily free tier first, then paid access
|
|
139
|
-
continues automatically after the allowance is exhausted.
|
|
140
|
-
If you do not have a prepared wallet yet, use bounded single `graph_query`
|
|
141
|
-
calls within the free tier, then prepare a wallet or use an invited tester
|
|
142
|
-
access key when the allowance is exhausted.
|
|
143
|
-
|
|
144
|
-
Run a focused investigation in the initialized workspace:
|
|
326
|
+
Public production Graph (operator configuration, never a package default).
|
|
327
|
+
Use the host root. Do not add `/mcp`.
|
|
145
328
|
|
|
146
329
|
```bash
|
|
147
|
-
cia
|
|
148
|
-
|
|
149
|
-
cia mcp trace-victim-funds \
|
|
150
|
-
--network bittensor \
|
|
151
|
-
--victim-addresses 5GTjfJaLpBNrgybhY24NqhDnKW9r94z72RSYLxeodxJfSkj5
|
|
330
|
+
cia config set graphMcpEndpoint https://mcp.chain-insights.ai/
|
|
152
331
|
```
|
|
153
332
|
|
|
154
|
-
|
|
333
|
+
Optional one-shot override from the environment:
|
|
155
334
|
|
|
156
335
|
```bash
|
|
157
|
-
|
|
336
|
+
export CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT=https://mcp.chain-insights.ai/
|
|
158
337
|
```
|
|
159
338
|
|
|
160
|
-
|
|
339
|
+
Configuration precedence:
|
|
161
340
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
341
|
+
1. `CHAIN_INSIGHTS_GRAPH_MCP_ENDPOINT` env var (`GRAPH_MCP_ENDPOINT`
|
|
342
|
+
legacy alias also supported).
|
|
343
|
+
2. `cia config set graphMcpEndpoint ...` saved value.
|
|
344
|
+
3. Local default `http://127.0.0.1:8012/mcp`.
|
|
165
345
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
346
|
+
Validation rules:
|
|
347
|
+
|
|
348
|
+
- `http://` is accepted only for localhost / loopback addresses.
|
|
349
|
+
- Remote hosts must use `https://`.
|
|
350
|
+
- Endpoint URLs with credentials, query strings, or fragments are rejected.
|
|
170
351
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
352
|
+
Hosted access also needs an access mode, such as an approved access key or
|
|
353
|
+
a prepared wallet. For paid access, run `cia wallet ready` — it checks
|
|
354
|
+
funding and finishes one-time payment setup. Setup commands live in
|
|
355
|
+
[MCP proxy](docs/mcp-proxy.md).
|
|
174
356
|
|
|
175
|
-
|
|
357
|
+
The hosted graph includes a small public free tier for `graph_query`
|
|
358
|
+
(default: 10 execution seconds per IP per UTC day). Use
|
|
359
|
+
`meta_usage_status` to see the current caller allowance. Prepared wallet
|
|
360
|
+
users receive the free tier first, then paid access continues
|
|
361
|
+
automatically.
|
|
176
362
|
|
|
177
|
-
|
|
363
|
+
Search bounds (hops, row limits, frontiers) are tunable per call, per
|
|
364
|
+
network, or globally — see [Search limits](docs/search-limits.md).
|
|
178
365
|
|
|
179
|
-
|
|
180
|
-
cia mcp call graph_query \
|
|
181
|
-
network=bittensor \
|
|
182
|
-
"query=USE live_topology MATCH (i:Identity) RETURN i.identity_id AS identity_id, i.labels AS labels, i.risk_level AS risk_level LIMIT 10"
|
|
183
|
-
```
|
|
366
|
+
## Test
|
|
184
367
|
|
|
185
|
-
|
|
368
|
+
Local gate, in order:
|
|
186
369
|
|
|
187
370
|
```bash
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
371
|
+
npm run typecheck
|
|
372
|
+
npm run build
|
|
373
|
+
npm test
|
|
374
|
+
npm run release:check # PR-only step in verify.yml
|
|
191
375
|
```
|
|
192
376
|
|
|
193
|
-
|
|
194
|
-
Batch calls reserve worst-case execution time and can ask for paid access even
|
|
195
|
-
when a small free allowance remains.
|
|
196
|
-
|
|
197
|
-
Run suspect topology without requiring an incident timestamp:
|
|
377
|
+
Devkit-backed tiers (need the dev compose lane running):
|
|
198
378
|
|
|
199
379
|
```bash
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
--max-hops 16
|
|
380
|
+
npm run devkit:smoke
|
|
381
|
+
npm run devkit:smoke:parity
|
|
382
|
+
npm run test:devkit
|
|
204
383
|
```
|
|
205
384
|
|
|
206
|
-
|
|
385
|
+
CI install step, when reproducing CI:
|
|
207
386
|
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
-> Chain Insights CLI / MCP proxy
|
|
211
|
-
-> local config, wallet, workspace, artifacts, reports
|
|
212
|
-
-> Chain Insights Graph
|
|
213
|
-
-> graph intelligence for AML workflows
|
|
387
|
+
```bash
|
|
388
|
+
npm ci --ignore-scripts --audit=false --fund=false
|
|
214
389
|
```
|
|
215
390
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
391
|
+
CI workflows: `.github/workflows/verify.yml` (typecheck, build,
|
|
392
|
+
release:check, tests, npm pack contents), `security.yml`, `scorecard.yml`,
|
|
393
|
+
`docs.yml`.
|
|
219
394
|
|
|
220
|
-
##
|
|
395
|
+
## Debug
|
|
221
396
|
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
| `live_topology` | Recent topology and fast traversal |
|
|
227
|
-
| `archive_topology` | Historical fund-flow context |
|
|
228
|
-
| `facts` | Labels, features, risk scores, assets, and enrichment |
|
|
397
|
+
- Diagnostics and debug workflows: [docs/debugging.md](docs/debugging.md).
|
|
398
|
+
- Skip payment negotiation against the unmetered devkit:
|
|
399
|
+
`cia debug on --token <any-string> --endpoint http://127.0.0.1:18012/mcp`.
|
|
400
|
+
- MCP proxy structured logs: `~/.chain-insights/runtime/logs/mcp-proxy.jsonl`.
|
|
229
401
|
|
|
230
|
-
|
|
231
|
-
result envelope. Use explicit `LIMIT` and pagination in your query when you
|
|
232
|
-
want bounded result sets. Endpoint access and authentication are configured
|
|
233
|
-
separately; see [MCP proxy](docs/mcp-proxy.md).
|
|
402
|
+
Health checks (each is runnable):
|
|
234
403
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
404
|
+
```bash
|
|
405
|
+
# Configured endpoint
|
|
406
|
+
cia config get graphMcpEndpoint
|
|
238
407
|
|
|
239
|
-
|
|
408
|
+
# Endpoint reachable, networks listed
|
|
409
|
+
cia mcp networks
|
|
240
410
|
|
|
241
|
-
|
|
242
|
-
|
|
411
|
+
# Caller allowance / metering status
|
|
412
|
+
cia mcp call meta_usage_status
|
|
243
413
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
- `aml_trace_victim_funds` traces victim/source funds forward through
|
|
247
|
-
intermediaries to exchange deposit candidates.
|
|
248
|
-
- `aml_trace_deposit_sources` traces backward from suspected deposit/cashout
|
|
249
|
-
addresses to upstream sources and shared-source convergence.
|
|
250
|
-
- `aml_trace_suspect_funds` traces suspected scammer, mule, operator, or
|
|
251
|
-
laundering-ring funds forward to cashout topology.
|
|
414
|
+
# Fresh tool discovery
|
|
415
|
+
cia mcp tools --refresh
|
|
252
416
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
identity-grain topology internally and includes identity resolution metadata for
|
|
256
|
-
audit/debug use.
|
|
417
|
+
# Installed CLI sanity
|
|
418
|
+
cia --version && cia update --check
|
|
257
419
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
420
|
+
# Devkit service state (all imports exited 0, backends running)
|
|
421
|
+
docker compose -f devkit/docker-compose.yml ps -a
|
|
422
|
+
```
|
|
261
423
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
424
|
+
If network or tool discovery fails, check the endpoint and access mode
|
|
425
|
+
first. The CLI can still initialize workspaces and continue local
|
|
426
|
+
investigation workflow without a reachable endpoint.
|
|
265
427
|
|
|
266
|
-
|
|
267
|
-
graph reports under the workspace instead of embedding large payloads in human
|
|
268
|
-
notes.
|
|
428
|
+
## Documentation Links
|
|
269
429
|
|
|
270
|
-
|
|
430
|
+
Product docs:
|
|
271
431
|
|
|
272
432
|
| Doc | Use it for |
|
|
273
433
|
| --- | --- |
|
|
274
|
-
| [Graph tools](docs/graph-tools.md) |
|
|
275
|
-
|
|
|
276
|
-
| [
|
|
277
|
-
| [
|
|
278
|
-
| [
|
|
434
|
+
| [Graph tools](docs/graph-tools.md) | Graph layers, `graph_query`, `graph_query_batch`, AML tool contracts, graph reports |
|
|
435
|
+
| [Graph query compatibility](docs/graph-query-compatibility.md) | GQL/Cypher support per layer, rewrite recipes, traversal guidance |
|
|
436
|
+
| [Search limits](docs/search-limits.md) | Tunable search/row/frontier/hop bounds, precedence, ceilings |
|
|
437
|
+
| [Investigation workspaces](docs/investigation-workspaces.md) | `cia init`, workspace layout, artifacts, templates, reports, visualization |
|
|
438
|
+
| [Continuous monitoring](docs/monitoring.md) | `cia monitor` commands, case tracking, dossier rendering, scheduling, exit codes |
|
|
439
|
+
| [MCP proxy](docs/mcp-proxy.md) | Stdio proxy behavior, endpoint configuration, agent installers, auth modes |
|
|
440
|
+
| [Architecture overview](docs/architecture.md) | Product layers, data flow, local storage, security model, config keys |
|
|
279
441
|
| [Development](docs/development.md) | Build, test, and local install commands |
|
|
280
442
|
| [Contributing](docs/contributing.md) | Development workflow, pull requests, release expectations |
|
|
443
|
+
| [Stability policy](docs/stability.md) | Guaranteed surfaces (exit codes, MCP tool names, workspace layout), deprecation rules |
|
|
281
444
|
| [Debugging](docs/debugging.md) | Local troubleshooting, diagnostics, debug workflows |
|
|
445
|
+
| Bittensor devkit (in this repo under `devkit/`) | Local Bittensor graph backend contract, fixture, smoke procedures |
|
|
282
446
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
Chain Insights is not a custodial wallet, hosted case database, or replacement
|
|
286
|
-
for analyst review. It does not write risk labels automatically. Investigation
|
|
287
|
-
data stays in the local workspace unless the operator exports or shares it.
|
|
447
|
+
Architecture depth:
|
|
288
448
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
| `investigation` | `src/investigation` | [components/investigation.md](docs/architecture/components/investigation.md) |
|
|
297
|
-
| `mcp` | `src/mcp` | [components/mcp.md](docs/architecture/components/mcp.md) |
|
|
298
|
-
| `server` | `src/server` | [components/server.md](docs/architecture/components/server.md) |
|
|
299
|
-
| `viz` | `src/viz` | [components/viz.md](docs/architecture/components/viz.md) |
|
|
300
|
-
| `wallet` | `src/wallet` | [components/wallet.md](docs/architecture/components/wallet.md) |
|
|
301
|
-
<!-- /gsd: workers -->
|
|
449
|
+
- [docs/architecture/](docs/architecture/ARCHITECTURE.md) — index, C4
|
|
450
|
+
diagrams, context, containers, components.
|
|
451
|
+
- [Data contracts](docs/architecture/data-contracts.md) — tool surface,
|
|
452
|
+
search limits, endpoint rules, shared-graph model, devkit contract.
|
|
453
|
+
- [Operating rules](docs/architecture/operating-rules.md) — repo
|
|
454
|
+
invariants, findings rules, CI gotchas.
|
|
455
|
+
- [docs/acceptance/](docs/acceptance/) — per-component acceptance evidence.
|