chain-insights 0.40.0 → 0.42.1
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 +6 -0
- package/dist/{capabilities-BbAQ4Tfa.cjs → capabilities-A8fsfP24.cjs} +4 -1
- package/dist/{capabilities-BOOUnAeV.mjs → capabilities-DfWL6n_g.mjs} +5 -2
- package/dist/capabilities-DfWL6n_g.mjs.map +1 -0
- package/dist/cli.cjs +76 -127
- package/dist/cli.mjs +73 -124
- package/dist/cli.mjs.map +1 -1
- package/dist/{config-Br6VEK0O.mjs → config-9MabJh5R.mjs} +34 -2
- package/dist/config-9MabJh5R.mjs.map +1 -0
- package/dist/{config-CPUhkz0Z.cjs → config-BxtMoo9c.cjs} +32 -0
- package/dist/flows-BfUlyWvJ.mjs +344 -0
- package/dist/flows-BfUlyWvJ.mjs.map +1 -0
- package/dist/flows-CzsxUf35.cjs +394 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/mcp-proxy.cjs +80 -334
- package/dist/mcp-proxy.d.cts.map +1 -1
- package/dist/mcp-proxy.d.mts.map +1 -1
- package/dist/mcp-proxy.mjs +65 -319
- package/dist/mcp-proxy.mjs.map +1 -1
- package/dist/print-result-BEA_PyNz.cjs +178 -0
- package/dist/print-result-k9kXVR2c.mjs +151 -0
- package/dist/print-result-k9kXVR2c.mjs.map +1 -0
- package/dist/public-tools-CZyeptJQ.mjs.map +1 -1
- package/dist/{tool-visibility-Boxtlbtr.cjs → tool-visibility-BdsE6vQB.cjs} +8 -3
- package/dist/{tool-visibility-IB5nHCZ_.mjs → tool-visibility-wW2vAaj9.mjs} +7 -3
- package/dist/tool-visibility-wW2vAaj9.mjs.map +1 -0
- package/dist/{transport-error-DmC9WLTW.cjs → transport-error-CenkuT7T.cjs} +5 -2
- package/dist/{transport-error-CSEb6sPr.mjs → transport-error-S0za4TCe.mjs} +6 -3
- package/dist/transport-error-S0za4TCe.mjs.map +1 -0
- package/dist/{update-MsoEFbhn.mjs → update-7TewxG_2.mjs} +2 -2
- package/dist/{update-MsoEFbhn.mjs.map → update-7TewxG_2.mjs.map} +1 -1
- package/dist/{update-RKd0UW90.cjs → update-Rn1RSqrb.cjs} +7 -7
- package/docs/graph-query-compatibility.md +23 -16
- package/docs/graph-tools.md +123 -25
- package/package.json +1 -1
- package/skills/chain-insights-cypher/SKILL.md +222 -43
- package/skills/chain-insights-cypher/agents/openai.yaml +1 -1
- package/skills/chain-insights-schema-evm/SKILL.md +61 -29
- package/dist/capabilities-BOOUnAeV.mjs.map +0 -1
- package/dist/config-Br6VEK0O.mjs.map +0 -1
- package/dist/tool-visibility-IB5nHCZ_.mjs.map +0 -1
- package/dist/transport-error-CSEb6sPr.mjs.map +0 -1
- package/dist/version-BA3J8hu4.mjs +0 -8
- package/dist/version-BA3J8hu4.mjs.map +0 -1
- package/dist/version-CO9Or_YV.cjs +0 -17
package/README.md
CHANGED
|
@@ -311,6 +311,12 @@ add `/mcp`.
|
|
|
311
311
|
cia config set graphMcpEndpoint https://mcp.chain-insights.ai/
|
|
312
312
|
```
|
|
313
313
|
|
|
314
|
+
To undo every local override at once, after an upgrade or a test setup:
|
|
315
|
+
|
|
316
|
+
```bash
|
|
317
|
+
cia config reset # production endpoint, paid mode, no test key; wallet kept; old file in config.json.bak
|
|
318
|
+
```
|
|
319
|
+
|
|
314
320
|
Optional one-shot override from the environment:
|
|
315
321
|
|
|
316
322
|
```bash
|
|
@@ -58,9 +58,12 @@ function advertisedNetwork(raw) {
|
|
|
58
58
|
network,
|
|
59
59
|
display_name: typeof raw.display_name === "string" && raw.display_name.trim() !== "" ? raw.display_name : network,
|
|
60
60
|
status: typeof raw.status === "string" && raw.status.trim() !== "" ? raw.status : "live",
|
|
61
|
-
layers: {},
|
|
62
61
|
tools: advertisedTools(raw.tools)
|
|
63
62
|
};
|
|
63
|
+
if (isRecord(raw.layers)) capability.layers = raw.layers;
|
|
64
|
+
if (isRecord(raw.chain_admission)) capability.chain_admission = raw.chain_admission;
|
|
65
|
+
if (isRecord(raw.topology_admission)) capability.topology_admission = raw.topology_admission;
|
|
66
|
+
if (isRecord(raw.facts_admission)) capability.facts_admission = raw.facts_admission;
|
|
64
67
|
if (raw.default === true) capability.default = true;
|
|
65
68
|
if (raw.default === false) capability.default = false;
|
|
66
69
|
if (isRecord(raw.coverage)) capability.coverage = raw.coverage;
|
|
@@ -58,9 +58,12 @@ function advertisedNetwork(raw) {
|
|
|
58
58
|
network,
|
|
59
59
|
display_name: typeof raw.display_name === "string" && raw.display_name.trim() !== "" ? raw.display_name : network,
|
|
60
60
|
status: typeof raw.status === "string" && raw.status.trim() !== "" ? raw.status : "live",
|
|
61
|
-
layers: {},
|
|
62
61
|
tools: advertisedTools(raw.tools)
|
|
63
62
|
};
|
|
63
|
+
if (isRecord(raw.layers)) capability.layers = raw.layers;
|
|
64
|
+
if (isRecord(raw.chain_admission)) capability.chain_admission = raw.chain_admission;
|
|
65
|
+
if (isRecord(raw.topology_admission)) capability.topology_admission = raw.topology_admission;
|
|
66
|
+
if (isRecord(raw.facts_admission)) capability.facts_admission = raw.facts_admission;
|
|
64
67
|
if (raw.default === true) capability.default = true;
|
|
65
68
|
if (raw.default === false) capability.default = false;
|
|
66
69
|
if (isRecord(raw.coverage)) capability.coverage = raw.coverage;
|
|
@@ -196,4 +199,4 @@ function formatNetworkCapability(network) {
|
|
|
196
199
|
//#endregion
|
|
197
200
|
export { mirrorGraphNetworkCapabilities as n, capabilities_exports as t };
|
|
198
201
|
|
|
199
|
-
//# sourceMappingURL=capabilities-
|
|
202
|
+
//# sourceMappingURL=capabilities-DfWL6n_g.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities-DfWL6n_g.mjs","names":[],"sources":["../src/mcp/capabilities.ts"],"sourcesContent":["import type { InvestigatorConfig } from '../config/schema.js'\nimport { applyMcpAuthHeaders, resolveGraphMcpEndpoint } from './client.js'\n\nexport interface NetworkTopologyLayer {\n enabled: boolean\n coverage?: {\n from_block?: number\n to_block?: number\n from_timestamp?: string\n to_timestamp?: string\n chain_tip_block?: number\n blocks_behind_tip?: number\n /** Lowest height among the raw-data lanes that have started. Above it an empty answer may mean \"not indexed yet\". */\n complete_through_block?: number\n }\n}\n\nexport interface NetworkLayerCapability {\n enabled: boolean\n live?: NetworkTopologyLayer\n archive?: NetworkTopologyLayer\n /** The relationships a facts layer serves, when the server lists them. */\n relationships?: string[]\n}\n\n/**\n * A block the server publishes about one layer's limits. The mirror repeats it\n * exactly as it came: the members named below are the ones known today, and\n * any other member the server adds is kept. Read a limit from the block, never\n * from a number written elsewhere.\n */\nexport type NetworkAdmissionBlock = Record<string, unknown>\n\n/** `USE chain`: the lookups, the ceilings and the slots of the chain layer. */\nexport interface ChainAdmission extends NetworkAdmissionBlock {\n enabled: boolean\n /** ok, or the reason the layer is off or behind. */\n status?: string\n rules_version?: string\n grammar?: string\n /** The labels of `USE chain`, such as Transaction, Block and Head. */\n lookups?: string[]\n ceiling_seconds?: Record<string, number>\n slots?: number\n past_slots?: number\n slots_per_caller?: number\n calls_per_second_per_caller?: number\n batch_max?: number\n call_gas?: number\n head_ttl_ms?: number\n max_head_age_seconds?: number\n}\n\n/** `USE topology`: the shape rules, when the server publishes them. */\nexport interface TopologyAdmission extends NetworkAdmissionBlock {\n rules_version?: string\n max_hops_per_path?: number\n max_limit?: number\n slots?: number\n}\n\n/** `USE facts`: the read contract, when the server publishes it. */\nexport interface FactsAdmission extends NetworkAdmissionBlock {\n rules_version?: string\n window_days?: number\n max_rows?: number\n max_hops?: number\n}\n\nexport interface NetworkCapability {\n network: string\n display_name?: string\n status: string\n default?: boolean\n /** The layers as the server sent them. Absent when the server sent none. */\n layers?: Record<string, NetworkLayerCapability>\n tools: Record<string, string>\n /** The three layer blocks below are repeated exactly as sent, and absent when not sent. */\n chain_admission?: ChainAdmission\n topology_admission?: TopologyAdmission\n facts_admission?: FactsAdmission\n coverage?: {\n from_block?: number\n to_block?: number\n from_timestamp?: string\n to_timestamp?: string\n chain_tip_block?: number\n blocks_behind_tip?: number\n /** Lowest height among the raw-data lanes that have started. Above it an empty answer may mean \"not indexed yet\". */\n complete_through_block?: number\n }\n freshness?: {\n last_processed_at?: string\n last_successful_sync_at?: string\n max_data_age_seconds?: number\n last_processing_duration_seconds?: number\n }\n lane_progress?: NetworkLaneProgress[]\n graph_progress?: NetworkGraphProgress\n}\n\n/** One writer lane's committed height. null: the lane has not started. */\nexport interface NetworkLaneProgress {\n lane: string\n height: number | null\n}\n\n/** How far each block layer of the topology graph reaches, and their lowest. */\nexport interface NetworkGraphProgress {\n complete_through_block: number\n layers: { layer: string; position: number }[]\n}\n\nexport interface NetworkCapabilitiesDocument {\n schema: 'chain-insights.network-capabilities.v1'\n networks: NetworkCapability[]\n}\n\nconst AVAILABLE_TOOLS_PER_LINE = 3\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction advertisedTools(raw: unknown): Record<string, string> {\n if (!isRecord(raw)) return {}\n const tools: Record<string, string> = {}\n for (const [name, status] of Object.entries(raw)) {\n if (name.trim() !== '' && typeof status === 'string') tools[name] = status\n }\n return tools\n}\n\nfunction advertisedLaneProgress(raw: unknown): NetworkLaneProgress[] | undefined {\n if (!Array.isArray(raw)) return undefined\n const lanes: NetworkLaneProgress[] = []\n for (const entry of raw) {\n if (!isRecord(entry) || typeof entry.lane !== 'string' || entry.lane.trim() === '') continue\n if (typeof entry.height === 'number') lanes.push({ lane: entry.lane, height: entry.height })\n else if (entry.height === null) lanes.push({ lane: entry.lane, height: null })\n }\n return lanes\n}\n\nfunction advertisedGraphProgress(raw: unknown): NetworkGraphProgress | undefined {\n if (!isRecord(raw) || typeof raw.complete_through_block !== 'number') return undefined\n if (!Array.isArray(raw.layers)) return undefined\n const layers: NetworkGraphProgress['layers'] = []\n for (const entry of raw.layers) {\n if (!isRecord(entry) || typeof entry.layer !== 'string' || typeof entry.position !== 'number')\n continue\n layers.push({ layer: entry.layer, position: entry.position })\n }\n return { complete_through_block: raw.complete_through_block, layers }\n}\n\nfunction advertisedNetwork(raw: unknown): NetworkCapability | null {\n if (!isRecord(raw) || typeof raw.network !== 'string' || raw.network.trim() === '') {\n return null\n }\n const network = raw.network.trim()\n const capability: NetworkCapability = {\n network,\n display_name:\n typeof raw.display_name === 'string' && raw.display_name.trim() !== ''\n ? raw.display_name\n : network,\n status: typeof raw.status === 'string' && raw.status.trim() !== '' ? raw.status : 'live',\n tools: advertisedTools(raw.tools),\n }\n // The layer blocks are the server's own words about its limits. They pass\n // through exactly as sent: nothing is added, no default is invented and no\n // member is dropped. A block the server did not send stays absent.\n if (isRecord(raw.layers)) capability.layers = raw.layers as NetworkCapability['layers']\n if (isRecord(raw.chain_admission)) {\n capability.chain_admission = raw.chain_admission as unknown as ChainAdmission\n }\n if (isRecord(raw.topology_admission)) {\n capability.topology_admission = raw.topology_admission as TopologyAdmission\n }\n if (isRecord(raw.facts_admission)) {\n capability.facts_admission = raw.facts_admission as FactsAdmission\n }\n if (raw.default === true) capability.default = true\n if (raw.default === false) capability.default = false\n if (isRecord(raw.coverage)) capability.coverage = raw.coverage as NetworkCapability['coverage']\n if (isRecord(raw.freshness))\n capability.freshness = raw.freshness as NetworkCapability['freshness']\n const laneProgress = advertisedLaneProgress(raw.lane_progress)\n if (laneProgress) capability.lane_progress = laneProgress\n const graphProgress = advertisedGraphProgress(raw.graph_progress)\n if (graphProgress) capability.graph_progress = graphProgress\n return capability\n}\n\n/** Repeat GraphRAG's network list. CIA does not add, drop, or invent names. */\nexport function mirrorGraphNetworkCapabilities(document: {\n networks: unknown[]\n}): NetworkCapabilitiesDocument {\n return {\n schema: 'chain-insights.network-capabilities.v1',\n networks: document.networks\n .map((network) => advertisedNetwork(network))\n .filter((network): network is NetworkCapability => network !== null),\n }\n}\n\nfunction publicNetworkCapabilities(\n document: NetworkCapabilitiesDocument\n): NetworkCapabilitiesDocument {\n return mirrorGraphNetworkCapabilities(document)\n}\n\nfunction metadataNetworksUrl(endpoint: string): URL {\n const url = new URL(endpoint)\n url.pathname = '/metadata/networks'\n url.search = ''\n url.hash = ''\n return url\n}\n\nexport async function fetchNetworkCapabilities(\n config: Pick<InvestigatorConfig, 'graphMcpAuthToken' | 'graphMcpMode' | 'graphMcpEndpoint'>\n): Promise<NetworkCapabilitiesDocument> {\n const endpoint = resolveGraphMcpEndpoint(config)\n const request = metadataNetworksUrl(endpoint)\n const headers = new Headers()\n const token = config.graphMcpAuthToken?.trim()\n if (token) {\n applyMcpAuthHeaders(headers, token)\n }\n let response: Response\n try {\n response = await fetch(request, { headers })\n } catch (err) {\n throw new Error(`network capabilities unavailable at ${request}: ${(err as Error).message}`)\n }\n if (!response.ok) {\n throw new Error(`network capabilities unavailable at ${request}: HTTP ${response.status}`)\n }\n const parsed = (await response.json()) as NetworkCapabilitiesDocument\n if (\n parsed.schema !== 'chain-insights.network-capabilities.v1' ||\n !Array.isArray(parsed.networks)\n ) {\n throw new Error('network capabilities response has unsupported schema')\n }\n return publicNetworkCapabilities(parsed)\n}\n\nfunction availableTools(network: NetworkCapability): string[] {\n const tools = Object.entries(network.tools ?? {})\n .filter(([, status]) => status === 'available')\n .map(([name]) => name)\n return tools.sort()\n}\n\nfunction availableToolLines(network: NetworkCapability): string[] {\n const tools = availableTools(network)\n if (tools.length === 0) return ['none']\n const lines: string[] = []\n for (let index = 0; index < tools.length; index += AVAILABLE_TOOLS_PER_LINE) {\n lines.push(tools.slice(index, index + AVAILABLE_TOOLS_PER_LINE).join(', '))\n }\n return lines\n}\n\nfunction shortDate(value?: string): string {\n if (!value) return ''\n return value.slice(0, 10)\n}\n\nfunction datasetLabel(network: NetworkCapability): string {\n const coverage = network.coverage\n if (!coverage) return 'unknown'\n const blockRange =\n coverage.from_block !== undefined && coverage.to_block !== undefined\n ? `${coverage.from_block}..${coverage.to_block}`\n : 'blocks unknown'\n const dateRange =\n coverage.from_timestamp && coverage.to_timestamp\n ? `${shortDate(coverage.from_timestamp)}..${shortDate(coverage.to_timestamp)}`\n : ''\n if (blockRange === 'blocks unknown' && dateRange === '') return 'unknown'\n if (blockRange === 'blocks unknown') return dateRange\n if (dateRange === '') return blockRange\n return `${blockRange} / ${dateRange}`\n}\n\nfunction displayName(network: NetworkCapability): string {\n return network.display_name || network.network\n}\n\nfunction statusLabel(network: NetworkCapability): string {\n return network.default ? `${network.status} (default)` : network.status\n}\n\nfunction formatTable(headers: string[], rows: string[][], minimumWidths: number[]): string {\n const widths = headers.map((header, index) =>\n Math.max(\n minimumWidths[index] ?? 0,\n header.length,\n ...rows.map((row) => row[index]?.length ?? 0)\n )\n )\n const row = (values: string[]) =>\n values.map((value, index) => value.padEnd(widths[index]!)).join(' ')\n return [row(headers), widths.map((width) => '-'.repeat(width)).join(' '), ...rows.map(row)].join(\n '\\n'\n )\n}\n\nexport function formatNetworkOverview(document: NetworkCapabilitiesDocument): string {\n if (document.networks.length === 0) return 'No supported networks advertised.'\n const rows = document.networks.map((network) => [\n displayName(network),\n statusLabel(network),\n datasetLabel(network),\n ])\n return formatTable(['Network', 'Status', 'Dataset'], rows, [14, 10, 38])\n}\n\nexport function formatNetworkCapabilities(document: NetworkCapabilitiesDocument): string {\n if (document.networks.length === 0) return 'No supported networks advertised.'\n const networkRows = document.networks.flatMap((network) => {\n const toolLines = availableToolLines(network)\n return toolLines.map((toolLine, index) => [\n index === 0 ? displayName(network) : '',\n index === 0 ? datasetLabel(network) : '',\n toolLine,\n ])\n })\n return formatTable(['Network', 'Dataset', 'Chain Insights tools'], networkRows, [14, 38, 64])\n}\n\nexport function findNetworkCapability(\n document: NetworkCapabilitiesDocument,\n name: string\n): NetworkCapability | undefined {\n const normalizedName = name.trim().toLowerCase()\n if (!normalizedName) return undefined\n return document.networks.find((network) =>\n [network.network, network.display_name].some(\n (candidate) => candidate?.trim().toLowerCase() === normalizedName\n )\n )\n}\n\nexport function formatNetworkCapability(network: NetworkCapability): string {\n const rows = [\n ['Network', network.display_name || network.network],\n ['Identifier', network.network],\n ['Status', network.default ? `${network.status} (default)` : network.status],\n ['Dataset', datasetLabel(network)],\n ['Available tools', availableTools(network).join(', ') || 'none'],\n ]\n const labelWidth = Math.max(...rows.map(([label]) => label.length))\n return rows.map(([label, value]) => `${label.padEnd(labelWidth)} ${value}`).join('\\n')\n}\n"],"mappings":";;;;;;;;;;;AAsHA,MAAM,2BAA2B;AAEjC,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,gBAAgB,KAAsC;CAC7D,IAAI,CAAC,SAAS,GAAG,GAAG,OAAO,CAAC;CAC5B,MAAM,QAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,MAAM,WAAW,OAAO,QAAQ,GAAG,GAC7C,IAAI,KAAK,KAAK,MAAM,MAAM,OAAO,WAAW,UAAU,MAAM,QAAQ;CAEtE,OAAO;AACT;AAEA,SAAS,uBAAuB,KAAiD;CAC/E,IAAI,CAAC,MAAM,QAAQ,GAAG,GAAG,OAAO,KAAA;CAChC,MAAM,QAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,KAAK;EACvB,IAAI,CAAC,SAAS,KAAK,KAAK,OAAO,MAAM,SAAS,YAAY,MAAM,KAAK,KAAK,MAAM,IAAI;EACpF,IAAI,OAAO,MAAM,WAAW,UAAU,MAAM,KAAK;GAAE,MAAM,MAAM;GAAM,QAAQ,MAAM;EAAO,CAAC;OACtF,IAAI,MAAM,WAAW,MAAM,MAAM,KAAK;GAAE,MAAM,MAAM;GAAM,QAAQ;EAAK,CAAC;CAC/E;CACA,OAAO;AACT;AAEA,SAAS,wBAAwB,KAAgD;CAC/E,IAAI,CAAC,SAAS,GAAG,KAAK,OAAO,IAAI,2BAA2B,UAAU,OAAO,KAAA;CAC7E,IAAI,CAAC,MAAM,QAAQ,IAAI,MA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AAC;EACjC,CAAC,mBAAmB,eAAe,OAAO,CAAC,CAAC,KAAK,IAAI,KAAK,MAAM;CAClE;CACA,MAAM,aAAa,KAAK,IAAI,GAAG,KAAK,KAAK,CAAC,WAAW,MAAM,MAAM,CAAC;CAClE,OAAO,KAAK,KAAK,CAAC,OAAO,WAAW,GAAG,MAAM,OAAO,UAAU,EAAE,IAAI,OAAO,CAAC,CAAC,KAAK,IAAI;AACxF"}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require("./rolldown-runtime-C0BPl7ul.cjs");
|
|
2
|
-
const
|
|
2
|
+
const require_print_result = require("./print-result-BEA_PyNz.cjs");
|
|
3
3
|
let commander = require("commander");
|
|
4
4
|
let node_child_process = require("node:child_process");
|
|
5
5
|
let node_url = require("node:url");
|
|
@@ -47,99 +47,6 @@ function formatCiaWorkflows(workflows) {
|
|
|
47
47
|
].join("\n");
|
|
48
48
|
}
|
|
49
49
|
//#endregion
|
|
50
|
-
//#region src/mcp/print-result.ts
|
|
51
|
-
function isRecord(value) {
|
|
52
|
-
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
53
|
-
}
|
|
54
|
-
function displayValue(value) {
|
|
55
|
-
if (value === null || value === void 0) return "";
|
|
56
|
-
if (typeof value === "string") return value;
|
|
57
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
58
|
-
try {
|
|
59
|
-
return JSON.stringify(value);
|
|
60
|
-
} catch {
|
|
61
|
-
return String(value);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function formatTable(rows) {
|
|
65
|
-
if (rows.length === 0) return [];
|
|
66
|
-
const columns = [...new Set(rows.flatMap((row) => Object.keys(row)))];
|
|
67
|
-
const values = rows.map((row) => columns.map((column) => displayValue(row[column])));
|
|
68
|
-
const widths = columns.map((column, index) => Math.max(column.length, ...values.map((row) => row[index]?.length ?? 0)));
|
|
69
|
-
const line = (row) => row.map((value, index) => index === row.length - 1 ? value : value.padEnd(widths[index] ?? 0)).join(" | ");
|
|
70
|
-
return [
|
|
71
|
-
line(columns),
|
|
72
|
-
widths.map((width) => "-".repeat(width)).join("-+-"),
|
|
73
|
-
...values.map(line)
|
|
74
|
-
];
|
|
75
|
-
}
|
|
76
|
-
function formatGraphResult(value, fallbackTool) {
|
|
77
|
-
const facts = isRecord(value.facts) ? value.facts : void 0;
|
|
78
|
-
const query = facts && isRecord(facts.query) ? facts.query : void 0;
|
|
79
|
-
const queries = facts && Array.isArray(facts.queries) ? facts.queries : void 0;
|
|
80
|
-
if (!query && !queries) return null;
|
|
81
|
-
const lines = [`Tool: ${displayValue(value.tool) || fallbackTool || "MCP result"}`];
|
|
82
|
-
const subject = isRecord(value.subject) ? value.subject : facts && isRecord(facts.subject) ? facts.subject : void 0;
|
|
83
|
-
if (subject?.network !== void 0) lines.push(`Network: ${displayValue(subject.network)}`);
|
|
84
|
-
if (query) {
|
|
85
|
-
const results = Array.isArray(query.results) ? query.results.filter(isRecord) : [];
|
|
86
|
-
if (query.count !== void 0) lines.push(`Rows: ${displayValue(query.count)}`);
|
|
87
|
-
else lines.push(`Rows: ${results.length}`);
|
|
88
|
-
if (query.billable_units !== void 0) lines.push(`Billed units: ${displayValue(query.billable_units)}`);
|
|
89
|
-
if (query.elapsed_ms !== void 0) lines.push(`Elapsed: ${displayValue(query.elapsed_ms)} ms`);
|
|
90
|
-
if (query.truncated !== void 0) lines.push(`Truncated: ${displayValue(query.truncated)}`);
|
|
91
|
-
if (query.error !== void 0) lines.push(`Error: ${displayValue(query.error)}`);
|
|
92
|
-
if (results.length > 0) lines.push("", "Results:", ...formatTable(results));
|
|
93
|
-
else lines.push("", "Results: none");
|
|
94
|
-
}
|
|
95
|
-
if (queries) {
|
|
96
|
-
lines.push(`Queries: ${queries.length}`);
|
|
97
|
-
for (const entry of queries) {
|
|
98
|
-
if (!isRecord(entry)) continue;
|
|
99
|
-
const id = displayValue(entry.id) || "query";
|
|
100
|
-
const results = Array.isArray(entry.results) ? entry.results.filter(isRecord) : [];
|
|
101
|
-
lines.push("", `[${id}]`);
|
|
102
|
-
if (entry.error !== void 0) lines.push(`Error: ${displayValue(entry.error)}`);
|
|
103
|
-
lines.push(`Rows: ${displayValue(entry.count ?? results.length)}`);
|
|
104
|
-
if (results.length > 0) lines.push(...formatTable(results));
|
|
105
|
-
else lines.push("Results: none");
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return lines.join("\n");
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Formats one MCP text block for terminal output. JSON is indented when the
|
|
112
|
-
* caller requests `--json`; graph query envelopes are rendered as a compact
|
|
113
|
-
* result summary and table by default.
|
|
114
|
-
*/
|
|
115
|
-
function formatMcpTextContent(text, tool, options = {}) {
|
|
116
|
-
let parsed;
|
|
117
|
-
try {
|
|
118
|
-
parsed = JSON.parse(text);
|
|
119
|
-
} catch {
|
|
120
|
-
return text;
|
|
121
|
-
}
|
|
122
|
-
if (options.json) try {
|
|
123
|
-
return JSON.stringify(parsed, null, 2);
|
|
124
|
-
} catch {
|
|
125
|
-
return text;
|
|
126
|
-
}
|
|
127
|
-
if (isRecord(parsed)) return formatGraphResult(parsed, tool) ?? JSON.stringify(parsed, null, 2);
|
|
128
|
-
return displayValue(parsed);
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Prints the text blocks of an MCP tool result to stdout. When the result is
|
|
132
|
-
* flagged `isError`, throws with the tool's error text instead — MCP `callTool`
|
|
133
|
-
* returns tool errors as ordinary results (it does not reject), so callers must
|
|
134
|
-
* surface them as failures (non-zero exit) rather than printing to stdout and
|
|
135
|
-
* exiting 0.
|
|
136
|
-
*/
|
|
137
|
-
function printMcpTextContent(result, options = {}) {
|
|
138
|
-
const texts = (result.content ?? []).filter((item) => item.type === "text").map((item) => item.text ?? "");
|
|
139
|
-
if (result.isError) throw new Error(texts.join("\n").trim() || "MCP tool returned an error");
|
|
140
|
-
for (const text of texts) console.log(formatMcpTextContent(text, options.tool, options));
|
|
141
|
-
}
|
|
142
|
-
//#endregion
|
|
143
50
|
//#region src/cli.ts
|
|
144
51
|
const __dirname$1 = node_path.default.dirname((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
|
145
52
|
const installerPath = node_path.default.resolve(__dirname$1, "..", "bin", "install.cjs");
|
|
@@ -147,7 +54,7 @@ const program = new commander.Command();
|
|
|
147
54
|
function createCliCommand(name) {
|
|
148
55
|
return new commander.Command(name).showHelpAfterError();
|
|
149
56
|
}
|
|
150
|
-
program.name("cia").description("AML investigation toolkit for blockchain analysis").version(
|
|
57
|
+
program.name("cia").description("AML investigation toolkit for blockchain analysis").version(require_print_result.PACKAGE_INFO.version).showHelpAfterError().option("--claude", "Install Claude Code skills globally to ~/.claude/skills/").option("--claude-desktop", "Register the MCP proxy in Claude Desktop").option("--codex", "Install Codex skills globally to ~/.codex/skills/ and register MCP").option("--hermes", "Install Hermes skills globally to ~/.hermes/skills/chain-insights/ and register MCP");
|
|
151
58
|
const rawArgs = process.argv.slice(2);
|
|
152
59
|
const installerFlags = rawArgs.filter((a) => a === "--claude" || a === "--claude-desktop" || a === "--codex" || a === "--hermes");
|
|
153
60
|
function normalizeAmlToolVersionArgv(argv) {
|
|
@@ -184,17 +91,17 @@ function runInstaller(flag) {
|
|
|
184
91
|
}
|
|
185
92
|
}
|
|
186
93
|
async function withGraphMcpClient(name, fn) {
|
|
187
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
94
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
188
95
|
const config = await loadConfig();
|
|
189
96
|
const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ypw9BNbn.cjs")).then((n) => n.client_exports);
|
|
190
|
-
const { toGraphMcpEndpointError } = await Promise.resolve().then(() => require("./transport-error-
|
|
97
|
+
const { toGraphMcpEndpointError } = await Promise.resolve().then(() => require("./transport-error-CenkuT7T.cjs"));
|
|
191
98
|
const endpoint = resolveGraphMcpEndpoint(config);
|
|
192
99
|
const paymentFetch = await createConfiguredGraphMcpFetch(config);
|
|
193
100
|
const { Client } = await import("@modelcontextprotocol/sdk/client/index.js");
|
|
194
101
|
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
195
102
|
const client = new Client({
|
|
196
103
|
name,
|
|
197
|
-
version:
|
|
104
|
+
version: require_print_result.PACKAGE_VERSION
|
|
198
105
|
});
|
|
199
106
|
try {
|
|
200
107
|
await client.connect(new StreamableHTTPClientTransport(new URL(endpoint), { fetch: paymentFetch }));
|
|
@@ -212,22 +119,22 @@ async function withGraphMcpClient(name, fn) {
|
|
|
212
119
|
}
|
|
213
120
|
}
|
|
214
121
|
async function printNetworkCapabilities(opts) {
|
|
215
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
216
|
-
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-
|
|
122
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
123
|
+
const { fetchNetworkCapabilities, formatNetworkCapabilities } = await Promise.resolve().then(() => require("./capabilities-A8fsfP24.cjs")).then((n) => n.capabilities_exports);
|
|
217
124
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
218
125
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
219
126
|
else console.log(formatNetworkCapabilities(document));
|
|
220
127
|
}
|
|
221
128
|
async function printNetworkOverview(opts) {
|
|
222
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
223
|
-
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-
|
|
129
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
130
|
+
const { fetchNetworkCapabilities, formatNetworkOverview } = await Promise.resolve().then(() => require("./capabilities-A8fsfP24.cjs")).then((n) => n.capabilities_exports);
|
|
224
131
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
225
132
|
if (opts.json) console.log(JSON.stringify(document, null, 2));
|
|
226
133
|
else console.log(formatNetworkOverview(document));
|
|
227
134
|
}
|
|
228
135
|
async function printNetworkCapability(name, opts) {
|
|
229
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
230
|
-
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-
|
|
136
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
137
|
+
const { fetchNetworkCapabilities, findNetworkCapability, formatNetworkCapability } = await Promise.resolve().then(() => require("./capabilities-A8fsfP24.cjs")).then((n) => n.capabilities_exports);
|
|
231
138
|
const document = await fetchNetworkCapabilities(await loadConfig());
|
|
232
139
|
const network = findNetworkCapability(document, name);
|
|
233
140
|
if (!network) {
|
|
@@ -344,7 +251,7 @@ program.command("workflows").description("List CIA workflow tools").option("--js
|
|
|
344
251
|
});
|
|
345
252
|
addAmlAddressRiskCommand(program.command("workflow").description("Run a high-level CIA workflow"), "cia networks");
|
|
346
253
|
program.command("status").description("Show toolkit status and configuration").action(async () => {
|
|
347
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
254
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
348
255
|
const config = await loadConfig();
|
|
349
256
|
const graphMcpStatus = config.graphMcpMode === "debug" && config.graphMcpAuthToken?.trim() ? "bearer access mode" : `${config.graphMcpMode} mode`;
|
|
350
257
|
console.log("Config: ", config.dataDir);
|
|
@@ -353,7 +260,7 @@ program.command("status").description("Show toolkit status and configuration").a
|
|
|
353
260
|
});
|
|
354
261
|
program.command("update").description("Check npmjs for a newer Chain Insights release and update this CLI").option("--check", "Only check for a newer release").option("--dry-run", "Print the update command without running it").action(async (opts) => {
|
|
355
262
|
try {
|
|
356
|
-
const { checkForUpdate, runPackageUpdate } = await Promise.resolve().then(() => require("./update-
|
|
263
|
+
const { checkForUpdate, runPackageUpdate } = await Promise.resolve().then(() => require("./update-Rn1RSqrb.cjs"));
|
|
357
264
|
const result = await checkForUpdate();
|
|
358
265
|
if (result.error) throw new Error(`Could not check npmjs for updates: ${result.error}`);
|
|
359
266
|
if (!result.updateAvailable || !result.latestVersion) {
|
|
@@ -378,7 +285,7 @@ program.command("update").description("Check npmjs for a newer Chain Insights re
|
|
|
378
285
|
});
|
|
379
286
|
program.command("debug").description("Configure Chain Insights Graph debug mode").addCommand(createCliCommand("on").description("Enable Chain Insights Graph debug mode without x402 payments").requiredOption("--token <token>", "Debug bearer token").option("--endpoint <url>", "Chain Insights Graph endpoint").action(async (opts) => {
|
|
380
287
|
try {
|
|
381
|
-
const { saveConfig } = await Promise.resolve().then(() => require("./config-
|
|
288
|
+
const { saveConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
382
289
|
await saveConfig({
|
|
383
290
|
graphMcpMode: "debug",
|
|
384
291
|
graphMcpAuthToken: opts.token,
|
|
@@ -393,7 +300,7 @@ program.command("debug").description("Configure Chain Insights Graph debug mode"
|
|
|
393
300
|
}
|
|
394
301
|
})).addCommand(createCliCommand("off").description("Disable Chain Insights Graph debug mode and use paid x402 calls").action(async () => {
|
|
395
302
|
try {
|
|
396
|
-
const { saveConfig } = await Promise.resolve().then(() => require("./config-
|
|
303
|
+
const { saveConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
397
304
|
await saveConfig({
|
|
398
305
|
graphMcpMode: "paid",
|
|
399
306
|
graphMcpAuthToken: ""
|
|
@@ -406,7 +313,7 @@ program.command("debug").description("Configure Chain Insights Graph debug mode"
|
|
|
406
313
|
}
|
|
407
314
|
})).addCommand(createCliCommand("status").description("Show Chain Insights Graph payment/debug mode").action(async () => {
|
|
408
315
|
try {
|
|
409
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
316
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
410
317
|
const config = await loadConfig();
|
|
411
318
|
console.log(`Chain Insights Graph mode: ${config.graphMcpMode}`);
|
|
412
319
|
console.log(`Graph endpoint: ${config.graphMcpEndpoint}`);
|
|
@@ -421,7 +328,7 @@ program.command("access-key").description("Configure Chain Insights Graph test a
|
|
|
421
328
|
try {
|
|
422
329
|
const normalizedKey = key.trim();
|
|
423
330
|
if (!normalizedKey) throw new Error("Test access key is required");
|
|
424
|
-
const { saveConfig } = await Promise.resolve().then(() => require("./config-
|
|
331
|
+
const { saveConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
425
332
|
await saveConfig({
|
|
426
333
|
graphMcpMode: "debug",
|
|
427
334
|
graphMcpAuthToken: normalizedKey,
|
|
@@ -436,7 +343,7 @@ program.command("access-key").description("Configure Chain Insights Graph test a
|
|
|
436
343
|
}
|
|
437
344
|
})).addCommand(createCliCommand("clear").description("Remove the Chain Insights Graph test access key and use paid x402 calls").action(async () => {
|
|
438
345
|
try {
|
|
439
|
-
const { saveConfig } = await Promise.resolve().then(() => require("./config-
|
|
346
|
+
const { saveConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
440
347
|
await saveConfig({
|
|
441
348
|
graphMcpMode: "paid",
|
|
442
349
|
graphMcpAuthToken: ""
|
|
@@ -449,7 +356,7 @@ program.command("access-key").description("Configure Chain Insights Graph test a
|
|
|
449
356
|
}
|
|
450
357
|
})).addCommand(createCliCommand("status").description("Show Chain Insights Graph test access key status").action(async () => {
|
|
451
358
|
try {
|
|
452
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
359
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
453
360
|
const config = await loadConfig();
|
|
454
361
|
console.log(`Graph endpoint: ${config.graphMcpEndpoint}`);
|
|
455
362
|
console.log(`Access key: ${config.graphMcpAuthToken?.trim() ? "configured" : "not configured"}`);
|
|
@@ -469,7 +376,7 @@ program.command("setup").description("Configure external MCP clients").addComman
|
|
|
469
376
|
runInstaller("--hermes");
|
|
470
377
|
}));
|
|
471
378
|
program.command("config").description("Read or write configuration values").addCommand(createCliCommand("get").description("Read one Chain Insights configuration value").argument("<key>", "Config key to read").action(async (key) => {
|
|
472
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
379
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
473
380
|
const { CONFIG_KEYS } = await Promise.resolve().then(() => require("./schema-tX0U0-VI.cjs")).then((n) => n.schema_exports);
|
|
474
381
|
if (!CONFIG_KEYS.includes(key)) {
|
|
475
382
|
console.error(`Unknown config key: ${key}`);
|
|
@@ -477,6 +384,21 @@ program.command("config").description("Read or write configuration values").addC
|
|
|
477
384
|
}
|
|
478
385
|
const value = (await loadConfig())[key];
|
|
479
386
|
console.log(value ?? "");
|
|
387
|
+
})).addCommand(createCliCommand("reset").description("Put every setting back to its default (production endpoint, paid mode, no test key); the wallet stays").action(async () => {
|
|
388
|
+
try {
|
|
389
|
+
const { resetConfig, loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
390
|
+
const { backupPath } = await resetConfig();
|
|
391
|
+
const config = await loadConfig();
|
|
392
|
+
if (backupPath) console.log(`Previous settings saved to ${backupPath}`);
|
|
393
|
+
console.log("Settings reset to defaults.");
|
|
394
|
+
console.log(`Graph endpoint: ${config.graphMcpEndpoint}`);
|
|
395
|
+
console.log(`Mode: ${config.graphMcpMode}`);
|
|
396
|
+
console.log("Test access: off");
|
|
397
|
+
console.log("Wallet: unchanged (~/.chain-insights/wallet.json)");
|
|
398
|
+
} catch (err) {
|
|
399
|
+
console.error(err.message);
|
|
400
|
+
process.exit(1);
|
|
401
|
+
}
|
|
480
402
|
})).addCommand(createCliCommand("set").description("Write one Chain Insights configuration value").argument("<key>", "Config key to write").argument("<value>", "Value to set").action(async (key, value) => {
|
|
481
403
|
if (key === "walletPrivateKey") {
|
|
482
404
|
try {
|
|
@@ -490,7 +412,7 @@ program.command("config").description("Read or write configuration values").addC
|
|
|
490
412
|
}
|
|
491
413
|
return;
|
|
492
414
|
}
|
|
493
|
-
const { loadConfig, saveConfig } = await Promise.resolve().then(() => require("./config-
|
|
415
|
+
const { loadConfig, saveConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
494
416
|
const { CONFIG_KEYS, DEFAULT_CONFIG } = await Promise.resolve().then(() => require("./schema-tX0U0-VI.cjs")).then((n) => n.schema_exports);
|
|
495
417
|
const current = await loadConfig();
|
|
496
418
|
if (!CONFIG_KEYS.includes(key)) {
|
|
@@ -626,12 +548,12 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
626
548
|
console.error(err.message);
|
|
627
549
|
process.exit(1);
|
|
628
550
|
}
|
|
629
|
-
})).addCommand(createCliCommand("tools").description("List remote GraphRAG MCP tools
|
|
551
|
+
})).addCommand(createCliCommand("tools").description("List the remote GraphRAG MCP tools (cached for 24 hours) and the local money_flows tool").option("--refresh", "Force refresh schema cache").action(async (opts) => {
|
|
630
552
|
try {
|
|
631
553
|
const { loadSchema, saveSchema } = await Promise.resolve().then(() => require("./schema-cache-n7Gbhvsj.cjs"));
|
|
632
554
|
const { formatToolsTable } = await Promise.resolve().then(() => require("./format-BjZuYDr8.cjs"));
|
|
633
|
-
const { visibleRemoteTools } = await Promise.resolve().then(() => require("./tool-visibility-
|
|
634
|
-
const { loadConfig } = await Promise.resolve().then(() => require("./config-
|
|
555
|
+
const { visibleRemoteTools } = await Promise.resolve().then(() => require("./tool-visibility-BdsE6vQB.cjs")).then((n) => n.tool_visibility_exports);
|
|
556
|
+
const { loadConfig } = await Promise.resolve().then(() => require("./config-BxtMoo9c.cjs")).then((n) => n.config_exports);
|
|
635
557
|
const { createConfiguredGraphMcpFetch, resolveGraphMcpEndpoint } = await Promise.resolve().then(() => require("./client-Ypw9BNbn.cjs")).then((n) => n.client_exports);
|
|
636
558
|
const config = await loadConfig();
|
|
637
559
|
const graphMcpEndpoint = resolveGraphMcpEndpoint(config);
|
|
@@ -642,7 +564,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
642
564
|
const { StreamableHTTPClientTransport } = await import("@modelcontextprotocol/sdk/client/streamableHttp.js");
|
|
643
565
|
const client = new Client({
|
|
644
566
|
name: "chain-insights-cli",
|
|
645
|
-
version:
|
|
567
|
+
version: require_print_result.PACKAGE_VERSION
|
|
646
568
|
});
|
|
647
569
|
await client.connect(new StreamableHTTPClientTransport(new URL(graphMcpEndpoint), { fetch: paymentFetch }));
|
|
648
570
|
try {
|
|
@@ -652,7 +574,12 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
652
574
|
await client.close();
|
|
653
575
|
}
|
|
654
576
|
}
|
|
655
|
-
|
|
577
|
+
const { MONEY_FLOWS_TOOL, MONEY_FLOWS_DESCRIPTION } = await Promise.resolve().then(() => require("./flows-CzsxUf35.cjs")).then((n) => n.flows_exports);
|
|
578
|
+
const listed = visibleRemoteTools(tools).filter((t) => t.name !== MONEY_FLOWS_TOOL);
|
|
579
|
+
console.log(formatToolsTable([...listed, {
|
|
580
|
+
name: MONEY_FLOWS_TOOL,
|
|
581
|
+
description: MONEY_FLOWS_DESCRIPTION
|
|
582
|
+
}]));
|
|
656
583
|
} catch (err) {
|
|
657
584
|
console.error(err.message);
|
|
658
585
|
process.exit(1);
|
|
@@ -660,7 +587,7 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
660
587
|
})).addCommand(createCliCommand("call").description("Call a low-level MCP tool directly (advanced)").option("--json", "Print machine-readable JSON output").argument("<tool>", "Tool name to call").argument("[args...]", "Key=value arguments (e.g. address=0x1234... network=robinhood)").action(async (tool, rawArgs, opts) => {
|
|
661
588
|
try {
|
|
662
589
|
const { parseMcpCallArgs } = await Promise.resolve().then(() => require("./call-args-DAiQSDmD.cjs"));
|
|
663
|
-
const { assertPublicMcpToolName, validatePublicMcpToolArguments } = await Promise.resolve().then(() => require("./tool-visibility-
|
|
590
|
+
const { assertPublicMcpToolName, validatePublicMcpToolArguments } = await Promise.resolve().then(() => require("./tool-visibility-BdsE6vQB.cjs")).then((n) => n.tool_visibility_exports);
|
|
664
591
|
const args = parseMcpCallArgs(rawArgs);
|
|
665
592
|
assertPublicMcpToolName(tool);
|
|
666
593
|
if (tool === "aml_address_risk") throw new Error("aml_address_risk is a CIA workflow. Run `cia workflow aml-address-risk` instead.");
|
|
@@ -674,6 +601,25 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
674
601
|
await printNetworkCapabilities({ json: opts.json });
|
|
675
602
|
return;
|
|
676
603
|
}
|
|
604
|
+
if (tool === "graph_expand") throw new Error("graph_expand is used only by the money-flow view in Claude. Run `cia mcp call money_flows` instead.");
|
|
605
|
+
if (tool === "money_flows") {
|
|
606
|
+
await withGraphMcpClient("chain-insights-cli-call", async (client) => {
|
|
607
|
+
const { handleMoneyFlows } = await Promise.resolve().then(() => require("./flows-CzsxUf35.cjs")).then((n) => n.flows_exports);
|
|
608
|
+
const { graphToolRequestOptions } = await Promise.resolve().then(() => require("./request-timeout-CYmQF8N7.cjs"));
|
|
609
|
+
const result = await handleMoneyFlows(args, {
|
|
610
|
+
graphQuery: async (queryArgs) => await client.callTool({
|
|
611
|
+
name: "graph_query",
|
|
612
|
+
arguments: queryArgs
|
|
613
|
+
}, void 0, graphToolRequestOptions("graph_query")),
|
|
614
|
+
describeFailure: (err) => err instanceof Error ? err.message : String(err)
|
|
615
|
+
});
|
|
616
|
+
require_print_result.printMcpTextContent(result, {
|
|
617
|
+
tool,
|
|
618
|
+
json: opts.json
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
677
623
|
if (tool === "meta_help") {
|
|
678
624
|
console.log("Chain Insights workflow tools: aml_address_risk. Low-level GraphRAG tools: graph_query and graph_query_batch. Metadata and payment tools: meta_* and wallet_balance.");
|
|
679
625
|
return;
|
|
@@ -681,10 +627,11 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
681
627
|
await withGraphMcpClient("chain-insights-cli-call", async (client, config) => {
|
|
682
628
|
if (tool === "meta_usage_status") {
|
|
683
629
|
try {
|
|
684
|
-
|
|
630
|
+
const result = await client.callTool({
|
|
685
631
|
name: "usage_status",
|
|
686
632
|
arguments: {}
|
|
687
|
-
})
|
|
633
|
+
});
|
|
634
|
+
require_print_result.printMcpTextContent(result, {
|
|
688
635
|
tool,
|
|
689
636
|
json: opts.json
|
|
690
637
|
});
|
|
@@ -700,10 +647,11 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
700
647
|
try {
|
|
701
648
|
const { getWalletAccount } = await Promise.resolve().then(() => require("./tools-BHfphgy9.cjs")).then((n) => n.tools_exports);
|
|
702
649
|
const account = await getWalletAccount();
|
|
703
|
-
|
|
650
|
+
const result = await client.callTool({
|
|
704
651
|
name: "subscription_status",
|
|
705
652
|
arguments: { wallet: account.address }
|
|
706
|
-
})
|
|
653
|
+
});
|
|
654
|
+
require_print_result.printMcpTextContent(result, {
|
|
707
655
|
tool,
|
|
708
656
|
json: opts.json
|
|
709
657
|
});
|
|
@@ -717,19 +665,20 @@ program.command("mcp").description("Low-level access to the Chain Insights MCP e
|
|
|
717
665
|
}
|
|
718
666
|
const { graphToolRequestOptions } = await Promise.resolve().then(() => require("./request-timeout-CYmQF8N7.cjs"));
|
|
719
667
|
const requestOptions = graphToolRequestOptions(tool);
|
|
720
|
-
|
|
668
|
+
const result = requestOptions ? await client.callTool({
|
|
721
669
|
name: tool,
|
|
722
670
|
arguments: args
|
|
723
671
|
}, void 0, requestOptions) : await client.callTool({
|
|
724
672
|
name: tool,
|
|
725
673
|
arguments: args
|
|
726
|
-
})
|
|
674
|
+
});
|
|
675
|
+
require_print_result.printMcpTextContent(result, {
|
|
727
676
|
tool,
|
|
728
677
|
json: opts.json
|
|
729
678
|
});
|
|
730
679
|
});
|
|
731
680
|
} catch (err) {
|
|
732
|
-
const { formatMcpCallError } = await Promise.resolve().then(() => require("./tool-visibility-
|
|
681
|
+
const { formatMcpCallError } = await Promise.resolve().then(() => require("./tool-visibility-BdsE6vQB.cjs")).then((n) => n.tool_visibility_exports);
|
|
733
682
|
console.error(formatMcpCallError(tool, err));
|
|
734
683
|
process.exit(1);
|
|
735
684
|
}
|