@cryptoquant_official/mcp 0.0.4 → 0.0.6-alpha
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/LICENSE +21 -0
- package/README.md +330 -37
- package/dist/ai-sdk/anthropic.d.ts +125 -0
- package/dist/ai-sdk/anthropic.d.ts.map +1 -0
- package/dist/ai-sdk/anthropic.js +278 -0
- package/dist/ai-sdk/anthropic.js.map +1 -0
- package/dist/ai-sdk/execute.d.ts +35 -0
- package/dist/ai-sdk/execute.d.ts.map +1 -0
- package/dist/ai-sdk/execute.js +531 -0
- package/dist/ai-sdk/execute.js.map +1 -0
- package/dist/ai-sdk/index.d.ts +53 -0
- package/dist/ai-sdk/index.d.ts.map +1 -0
- package/dist/ai-sdk/index.js +56 -0
- package/dist/ai-sdk/index.js.map +1 -0
- package/dist/ai-sdk/prompts.d.ts +34 -0
- package/dist/ai-sdk/prompts.d.ts.map +1 -0
- package/dist/ai-sdk/prompts.js +74 -0
- package/dist/ai-sdk/prompts.js.map +1 -0
- package/dist/ai-sdk/schemas.d.ts +66 -0
- package/dist/ai-sdk/schemas.d.ts.map +1 -0
- package/dist/ai-sdk/schemas.js +136 -0
- package/dist/ai-sdk/schemas.js.map +1 -0
- package/dist/ai-sdk/tools.d.ts +165 -0
- package/dist/ai-sdk/tools.d.ts.map +1 -0
- package/dist/ai-sdk/tools.js +152 -0
- package/dist/ai-sdk/tools.js.map +1 -0
- package/dist/ai-sdk/types.d.ts +149 -0
- package/dist/ai-sdk/types.d.ts.map +1 -0
- package/dist/ai-sdk/types.js +5 -0
- package/dist/ai-sdk/types.js.map +1 -0
- package/dist/core/auth/storage.d.ts.map +1 -0
- package/dist/core/auth/storage.js.map +1 -0
- package/dist/core/cache/storage.d.ts +110 -0
- package/dist/core/cache/storage.d.ts.map +1 -0
- package/dist/core/cache/storage.js +356 -0
- package/dist/core/cache/storage.js.map +1 -0
- package/dist/core/cache/summary.d.ts.map +1 -0
- package/dist/core/cache/summary.js.map +1 -0
- package/dist/{cache → core/cache}/types.d.ts +25 -0
- package/dist/{cache → core/cache}/types.d.ts.map +1 -1
- package/dist/core/cache/types.js.map +1 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/discovery.d.ts.map +1 -0
- package/dist/{discovery.js → core/discovery.js} +14 -2
- package/dist/core/discovery.js.map +1 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +19 -0
- package/dist/core/index.js.map +1 -0
- package/dist/{permissions.d.ts → core/permissions.d.ts} +2 -2
- package/dist/core/permissions.d.ts.map +1 -0
- package/dist/{permissions.js → core/permissions.js} +38 -14
- package/dist/core/permissions.js.map +1 -0
- package/dist/core/plan-limits.d.ts.map +1 -0
- package/dist/core/plan-limits.js.map +1 -0
- package/dist/{utils.d.ts → core/utils.d.ts} +13 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/{utils.js → core/utils.js} +34 -0
- package/dist/core/utils.js.map +1 -0
- package/dist/data/metrics.toon +8 -5
- package/dist/http/chat-proxy.d.ts +32 -0
- package/dist/http/chat-proxy.d.ts.map +1 -0
- package/dist/http/chat-proxy.js +310 -0
- package/dist/http/chat-proxy.js.map +1 -0
- package/dist/http/index.d.ts +12 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +30 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/server.d.ts +20 -0
- package/dist/http/server.d.ts.map +1 -0
- package/dist/http/server.js +231 -0
- package/dist/http/server.js.map +1 -0
- package/dist/shared/metrics-data.generated.d.ts +176 -0
- package/dist/shared/metrics-data.generated.d.ts.map +1 -0
- package/dist/shared/metrics-data.generated.js +3077 -0
- package/dist/shared/metrics-data.generated.js.map +1 -0
- package/dist/stdio/index.d.ts +10 -0
- package/dist/stdio/index.d.ts.map +1 -0
- package/dist/stdio/index.js +30 -0
- package/dist/stdio/index.js.map +1 -0
- package/dist/stdio/tools/auth.d.ts +3 -0
- package/dist/stdio/tools/auth.d.ts.map +1 -0
- package/dist/{tools → stdio/tools}/auth.js +38 -12
- package/dist/stdio/tools/auth.js.map +1 -0
- package/dist/stdio/tools/core.d.ts +3 -0
- package/dist/stdio/tools/core.d.ts.map +1 -0
- package/dist/{tools → stdio/tools}/core.js +122 -162
- package/dist/stdio/tools/core.js.map +1 -0
- package/package.json +55 -14
- package/dist/auth/storage.d.ts.map +0 -1
- package/dist/auth/storage.js.map +0 -1
- package/dist/cache/storage.d.ts +0 -47
- package/dist/cache/storage.d.ts.map +0 -1
- package/dist/cache/storage.js +0 -140
- package/dist/cache/storage.js.map +0 -1
- package/dist/cache/summary.d.ts.map +0 -1
- package/dist/cache/summary.js.map +0 -1
- package/dist/cache/types.js.map +0 -1
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/discovery.d.ts.map +0 -1
- package/dist/discovery.js.map +0 -1
- package/dist/index.d.ts +0 -18
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -46
- package/dist/index.js.map +0 -1
- package/dist/permissions.d.ts.map +0 -1
- package/dist/permissions.js.map +0 -1
- package/dist/plan-limits.d.ts.map +0 -1
- package/dist/plan-limits.js.map +0 -1
- package/dist/tools/auth.d.ts +0 -3
- package/dist/tools/auth.d.ts.map +0 -1
- package/dist/tools/auth.js.map +0 -1
- package/dist/tools/core.d.ts +0 -3
- package/dist/tools/core.d.ts.map +0 -1
- package/dist/tools/core.js.map +0 -1
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js.map +0 -1
- /package/dist/{auth → core/auth}/storage.d.ts +0 -0
- /package/dist/{auth → core/auth}/storage.js +0 -0
- /package/dist/{cache → core/cache}/summary.d.ts +0 -0
- /package/dist/{cache → core/cache}/summary.js +0 -0
- /package/dist/{cache → core/cache}/types.js +0 -0
- /package/dist/{config.d.ts → core/config.d.ts} +0 -0
- /package/dist/{config.js → core/config.js} +0 -0
- /package/dist/{discovery.d.ts → core/discovery.d.ts} +0 -0
- /package/dist/{plan-limits.d.ts → core/plan-limits.d.ts} +0 -0
- /package/dist/{plan-limits.js → core/plan-limits.js} +0 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default System Prompts for CryptoQuant AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Pre-configured system prompts for common use cases.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { CRYPTOQUANT_SYSTEM_PROMPT } from '@cryptoquant_official/mcp/ai-sdk'
|
|
9
|
+
*
|
|
10
|
+
* const result = streamText({
|
|
11
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
12
|
+
* system: CRYPTOQUANT_SYSTEM_PROMPT,
|
|
13
|
+
* messages,
|
|
14
|
+
* tools: createCryptoQuantTools({ cryptoquantApiKey: process.env.CRYPTOQUANT_API_KEY! }),
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Default system prompt for CryptoQuant-powered AI assistants.
|
|
20
|
+
*
|
|
21
|
+
* Includes:
|
|
22
|
+
* - Role definition as crypto market analyst
|
|
23
|
+
* - Available tools and their purposes
|
|
24
|
+
* - Common metrics with brief descriptions
|
|
25
|
+
* - Step-by-step analysis workflow
|
|
26
|
+
* - Detailed interpretation thresholds
|
|
27
|
+
*/
|
|
28
|
+
export declare const CRYPTOQUANT_SYSTEM_PROMPT = "You are a crypto market analyst assistant powered by CryptoQuant on-chain data.\n\n## Available Tools\n1. **initialize** - Initialize CryptoQuant session (required before querying data)\n2. **discover_endpoints** - Find available data endpoints for specific assets/categories\n3. **query_data** - Fetch on-chain metrics with customizable parameters\n4. **describe_metric** - Get detailed metric explanations and thresholds\n5. **market_summary** - Get quick market status overview\n6. **trading_signal** - Calculate buy/sell/hold signals with confidence scores\n7. **whale_activity** - Track large holder movements and institutional flows\n\n## Common Metrics\n- **MVRV**: Market Value to Realized Value (valuation indicator)\n- **SOPR**: Spent Output Profit Ratio (profit/loss indicator)\n- **NUPL**: Net Unrealized Profit/Loss (sentiment indicator)\n- **Exchange Netflow**: Coins moving in/out of exchanges (accumulation/distribution)\n- **Funding Rate**: Perpetual futures funding (derivatives sentiment)\n\n## Analysis Workflow\n1. First initialize the session if not done\n2. Query the relevant metrics for the user's question\n3. Provide clear interpretation with context\n4. Mention key thresholds and what they mean\n5. Consider multiple metrics for confirmation\n\n\nYou are a crypto market analyst with access to CryptoQuant on-chain data.\n\n## Key Metrics Interpretation\n\n### Valuation (MVRV)\n- < 1.0: \uD83D\uDFE2 Undervalued (buy zone)\n- 1.0-2.5: \uD83D\uDFE1 Fair value\n- > 3.5: \uD83D\uDD34 Overheated (sell zone)\n\n### Profit Behavior (SOPR)\n- < 0.95: \uD83D\uDFE2 Capitulation (contrarian buy)\n- 0.95-1.05: \uD83D\uDFE1 Normal\n- > 1.10: \uD83D\uDD34 Heavy profit taking\n\n### Exchange Flows (Netflow)\n- < -1,000 BTC: \uD83D\uDFE2 Accumulation\n- \u00B11,000 BTC: \uD83D\uDFE1 Neutral\n- > +5,000 BTC: \uD83D\uDD34 Distribution\n\n### Funding Rate\n- < -0.03%: \uD83D\uDFE2 Shorts overcrowded\n- \u00B10.01%: \uD83D\uDFE1 Neutral\n- > 0.05%: \uD83D\uDD34 Longs overcrowded\n\n## Trading Signal Weights\n- MVRV: 30%\n- SOPR: 25%\n- Netflow: 25%\n- Funding: 20%\n\nScore > 70: BUY | 40-70: HOLD | < 40: SELL\n\n## Important Notes\n- No single metric is definitive - use multiple confirmations\n- Context matters - same values mean different things in bull vs bear\n- This is not financial advice - metrics are informational only\n\n";
|
|
29
|
+
/**
|
|
30
|
+
* Minimal system prompt for CryptoQuant tools.
|
|
31
|
+
* Use this when you want a lighter prompt without detailed interpretation guidance.
|
|
32
|
+
*/
|
|
33
|
+
export declare const CRYPTOQUANT_MINIMAL_PROMPT = "You are a crypto market analyst assistant powered by CryptoQuant on-chain data.\n\nAvailable tools:\n1. initialize - Initialize CryptoQuant session (required before querying data)\n2. discover_endpoints - Find available data endpoints\n3. query_data - Fetch on-chain metrics\n4. describe_metric - Get metric explanations\n\nWhen analyzing data:\n1. First initialize the session if not done\n2. Query the relevant metrics\n3. Provide clear interpretation with context\n4. Mention key thresholds and what they mean\n";
|
|
34
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/ai-sdk/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAIH;;;;;;;;;GASG;AACH,eAAO,MAAM,yBAAyB,2zEA0BrC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,ugBAatC,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default System Prompts for CryptoQuant AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Pre-configured system prompts for common use cases.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { CRYPTOQUANT_SYSTEM_PROMPT } from '@cryptoquant_official/mcp/ai-sdk'
|
|
9
|
+
*
|
|
10
|
+
* const result = streamText({
|
|
11
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
12
|
+
* system: CRYPTOQUANT_SYSTEM_PROMPT,
|
|
13
|
+
* messages,
|
|
14
|
+
* tools: createCryptoQuantTools({ cryptoquantApiKey: process.env.CRYPTOQUANT_API_KEY! }),
|
|
15
|
+
* })
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
import { INTERPRETATION_SYSTEM_PROMPT } from "../shared/metrics-data.generated.js";
|
|
19
|
+
/**
|
|
20
|
+
* Default system prompt for CryptoQuant-powered AI assistants.
|
|
21
|
+
*
|
|
22
|
+
* Includes:
|
|
23
|
+
* - Role definition as crypto market analyst
|
|
24
|
+
* - Available tools and their purposes
|
|
25
|
+
* - Common metrics with brief descriptions
|
|
26
|
+
* - Step-by-step analysis workflow
|
|
27
|
+
* - Detailed interpretation thresholds
|
|
28
|
+
*/
|
|
29
|
+
export const CRYPTOQUANT_SYSTEM_PROMPT = `You are a crypto market analyst assistant powered by CryptoQuant on-chain data.
|
|
30
|
+
|
|
31
|
+
## Available Tools
|
|
32
|
+
1. **initialize** - Initialize CryptoQuant session (required before querying data)
|
|
33
|
+
2. **discover_endpoints** - Find available data endpoints for specific assets/categories
|
|
34
|
+
3. **query_data** - Fetch on-chain metrics with customizable parameters
|
|
35
|
+
4. **describe_metric** - Get detailed metric explanations and thresholds
|
|
36
|
+
5. **market_summary** - Get quick market status overview
|
|
37
|
+
6. **trading_signal** - Calculate buy/sell/hold signals with confidence scores
|
|
38
|
+
7. **whale_activity** - Track large holder movements and institutional flows
|
|
39
|
+
|
|
40
|
+
## Common Metrics
|
|
41
|
+
- **MVRV**: Market Value to Realized Value (valuation indicator)
|
|
42
|
+
- **SOPR**: Spent Output Profit Ratio (profit/loss indicator)
|
|
43
|
+
- **NUPL**: Net Unrealized Profit/Loss (sentiment indicator)
|
|
44
|
+
- **Exchange Netflow**: Coins moving in/out of exchanges (accumulation/distribution)
|
|
45
|
+
- **Funding Rate**: Perpetual futures funding (derivatives sentiment)
|
|
46
|
+
|
|
47
|
+
## Analysis Workflow
|
|
48
|
+
1. First initialize the session if not done
|
|
49
|
+
2. Query the relevant metrics for the user's question
|
|
50
|
+
3. Provide clear interpretation with context
|
|
51
|
+
4. Mention key thresholds and what they mean
|
|
52
|
+
5. Consider multiple metrics for confirmation
|
|
53
|
+
|
|
54
|
+
${INTERPRETATION_SYSTEM_PROMPT}
|
|
55
|
+
`;
|
|
56
|
+
/**
|
|
57
|
+
* Minimal system prompt for CryptoQuant tools.
|
|
58
|
+
* Use this when you want a lighter prompt without detailed interpretation guidance.
|
|
59
|
+
*/
|
|
60
|
+
export const CRYPTOQUANT_MINIMAL_PROMPT = `You are a crypto market analyst assistant powered by CryptoQuant on-chain data.
|
|
61
|
+
|
|
62
|
+
Available tools:
|
|
63
|
+
1. initialize - Initialize CryptoQuant session (required before querying data)
|
|
64
|
+
2. discover_endpoints - Find available data endpoints
|
|
65
|
+
3. query_data - Fetch on-chain metrics
|
|
66
|
+
4. describe_metric - Get metric explanations
|
|
67
|
+
|
|
68
|
+
When analyzing data:
|
|
69
|
+
1. First initialize the session if not done
|
|
70
|
+
2. Query the relevant metrics
|
|
71
|
+
3. Provide clear interpretation with context
|
|
72
|
+
4. Mention key thresholds and what they mean
|
|
73
|
+
`;
|
|
74
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/ai-sdk/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,4BAA4B,EAAE,MAAM,qCAAqC,CAAC;AAEnF;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;EAyBvC,4BAA4B;CAC7B,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;CAazC,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schemas for CryptoQuant tools
|
|
3
|
+
*
|
|
4
|
+
* Uses AI SDK's jsonSchema instead of Zod to ensure Anthropic API compatibility.
|
|
5
|
+
* This avoids the "tools.0.custom.input_schema.type: Field required" error
|
|
6
|
+
* caused by zod version conflicts between packages.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/anthropics/claude-agent-sdk-typescript/issues/71
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Schema for initialize tool
|
|
12
|
+
*/
|
|
13
|
+
export declare const initializeSchema: import("ai").Schema<InitializeParams>;
|
|
14
|
+
export type InitializeParams = {
|
|
15
|
+
api_key?: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Schema for discover_endpoints tool
|
|
19
|
+
*/
|
|
20
|
+
export declare const discoverEndpointsSchema: import("ai").Schema<DiscoverEndpointsParams>;
|
|
21
|
+
export type DiscoverEndpointsParams = {
|
|
22
|
+
asset?: "btc" | "eth" | "alt" | "stablecoin" | "erc20" | "trx" | "xrp";
|
|
23
|
+
category?: string;
|
|
24
|
+
query?: string;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Schema for query_data tool
|
|
28
|
+
*/
|
|
29
|
+
export declare const queryDataSchema: import("ai").Schema<QueryDataParams>;
|
|
30
|
+
export type QueryDataParams = {
|
|
31
|
+
endpoint: string;
|
|
32
|
+
window?: "hour" | "day" | "block";
|
|
33
|
+
limit?: number;
|
|
34
|
+
from?: string;
|
|
35
|
+
to?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Schema for describe_metric tool
|
|
39
|
+
*/
|
|
40
|
+
export declare const describeMetricSchema: import("ai").Schema<DescribeMetricParams>;
|
|
41
|
+
export type DescribeMetricParams = {
|
|
42
|
+
metric_id: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Schema for market_summary tool
|
|
46
|
+
*/
|
|
47
|
+
export declare const marketSummarySchema: import("ai").Schema<MarketSummaryParams>;
|
|
48
|
+
export type MarketSummaryParams = {
|
|
49
|
+
asset?: "btc" | "eth";
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Schema for trading_signal tool
|
|
53
|
+
*/
|
|
54
|
+
export declare const tradingSignalSchema: import("ai").Schema<TradingSignalParams>;
|
|
55
|
+
export type TradingSignalParams = {
|
|
56
|
+
asset?: "btc" | "eth";
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Schema for whale_activity tool
|
|
60
|
+
*/
|
|
61
|
+
export declare const whaleActivitySchema: import("ai").Schema<WhaleActivityParams>;
|
|
62
|
+
export type WhaleActivityParams = {
|
|
63
|
+
asset?: "btc" | "eth";
|
|
64
|
+
timeframe?: "24h" | "7d" | "30d";
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/ai-sdk/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;GAEG;AACH,eAAO,MAAM,gBAAgB,uCAU3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,8CAmBlC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,sCA0B1B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,OAAO,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;CACb,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,2CAU/B,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0CAU9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0CAU9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,0CAe9B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,SAAS,CAAC,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;CAClC,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON Schemas for CryptoQuant tools
|
|
3
|
+
*
|
|
4
|
+
* Uses AI SDK's jsonSchema instead of Zod to ensure Anthropic API compatibility.
|
|
5
|
+
* This avoids the "tools.0.custom.input_schema.type: Field required" error
|
|
6
|
+
* caused by zod version conflicts between packages.
|
|
7
|
+
*
|
|
8
|
+
* @see https://github.com/anthropics/claude-agent-sdk-typescript/issues/71
|
|
9
|
+
*/
|
|
10
|
+
import { jsonSchema } from "ai";
|
|
11
|
+
/**
|
|
12
|
+
* Schema for initialize tool
|
|
13
|
+
*/
|
|
14
|
+
export const initializeSchema = jsonSchema({
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {
|
|
17
|
+
api_key: {
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "CryptoQuant API key (optional if already provided in config)",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
required: [],
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Schema for discover_endpoints tool
|
|
26
|
+
*/
|
|
27
|
+
export const discoverEndpointsSchema = jsonSchema({
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {
|
|
30
|
+
asset: {
|
|
31
|
+
type: "string",
|
|
32
|
+
enum: ["btc", "eth", "alt", "stablecoin", "erc20", "trx", "xrp"],
|
|
33
|
+
description: "Asset to filter by (e.g., btc, eth)",
|
|
34
|
+
},
|
|
35
|
+
category: {
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "Category filter (e.g., market-data, exchange-flows, network-data)",
|
|
38
|
+
},
|
|
39
|
+
query: {
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Search term to filter endpoints by name or path",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
required: [],
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Schema for query_data tool
|
|
48
|
+
*/
|
|
49
|
+
export const queryDataSchema = jsonSchema({
|
|
50
|
+
type: "object",
|
|
51
|
+
properties: {
|
|
52
|
+
endpoint: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "API endpoint path (e.g., /v1/btc/market-data/mvrv)",
|
|
55
|
+
},
|
|
56
|
+
window: {
|
|
57
|
+
type: "string",
|
|
58
|
+
enum: ["hour", "day", "block"],
|
|
59
|
+
description: "Time window granularity",
|
|
60
|
+
},
|
|
61
|
+
limit: {
|
|
62
|
+
type: "number",
|
|
63
|
+
description: "Number of data points to return (default: 30, max: 1000)",
|
|
64
|
+
},
|
|
65
|
+
from: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description: "Start date in ISO 8601 format (e.g., 2024-01-01)",
|
|
68
|
+
},
|
|
69
|
+
to: {
|
|
70
|
+
type: "string",
|
|
71
|
+
description: "End date in ISO 8601 format",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
required: ["endpoint"],
|
|
75
|
+
});
|
|
76
|
+
/**
|
|
77
|
+
* Schema for describe_metric tool
|
|
78
|
+
*/
|
|
79
|
+
export const describeMetricSchema = jsonSchema({
|
|
80
|
+
type: "object",
|
|
81
|
+
properties: {
|
|
82
|
+
metric_id: {
|
|
83
|
+
type: "string",
|
|
84
|
+
description: "Metric ID to describe (e.g., mvrv, sopr, nupl, netflow)",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
required: ["metric_id"],
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Schema for market_summary tool
|
|
91
|
+
*/
|
|
92
|
+
export const marketSummarySchema = jsonSchema({
|
|
93
|
+
type: "object",
|
|
94
|
+
properties: {
|
|
95
|
+
asset: {
|
|
96
|
+
type: "string",
|
|
97
|
+
enum: ["btc", "eth"],
|
|
98
|
+
description: "Asset to analyze (default: btc)",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
required: [],
|
|
102
|
+
});
|
|
103
|
+
/**
|
|
104
|
+
* Schema for trading_signal tool
|
|
105
|
+
*/
|
|
106
|
+
export const tradingSignalSchema = jsonSchema({
|
|
107
|
+
type: "object",
|
|
108
|
+
properties: {
|
|
109
|
+
asset: {
|
|
110
|
+
type: "string",
|
|
111
|
+
enum: ["btc", "eth"],
|
|
112
|
+
description: "Asset to analyze (default: btc)",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
required: [],
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Schema for whale_activity tool
|
|
119
|
+
*/
|
|
120
|
+
export const whaleActivitySchema = jsonSchema({
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: {
|
|
123
|
+
asset: {
|
|
124
|
+
type: "string",
|
|
125
|
+
enum: ["btc", "eth"],
|
|
126
|
+
description: "Asset to analyze (default: btc)",
|
|
127
|
+
},
|
|
128
|
+
timeframe: {
|
|
129
|
+
type: "string",
|
|
130
|
+
enum: ["24h", "7d", "30d"],
|
|
131
|
+
description: "Timeframe for analysis (default: 24h)",
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
required: [],
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/ai-sdk/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEhC;;GAEG;AACH,MAAM,CAAC,MAAM,gB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@@
|
|
|
1
|
+
/**
|
|
2
|
+
* CryptoQuant tools for Vercel AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Usage with streamText:
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { createCryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
7
|
+
*
|
|
8
|
+
* const result = streamText({
|
|
9
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
10
|
+
* tools: createCryptoQuantTools({ cryptoquantApiKey: 'cq-...' }),
|
|
11
|
+
* maxSteps: 5,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { CryptoQuantToolsConfig } from "./types.js";
|
|
16
|
+
/**
|
|
17
|
+
* Create CryptoQuant tools for use with Vercel AI SDK's streamText/generateText
|
|
18
|
+
*
|
|
19
|
+
* @param config - Configuration including CryptoQuant API key
|
|
20
|
+
* @returns Object containing all CryptoQuant tools
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // In your Next.js API route
|
|
25
|
+
* import { streamText } from 'ai'
|
|
26
|
+
* import { anthropic } from '@ai-sdk/anthropic'
|
|
27
|
+
* import { createCryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
28
|
+
*
|
|
29
|
+
* export async function POST(req: Request) {
|
|
30
|
+
* const { messages } = await req.json()
|
|
31
|
+
*
|
|
32
|
+
* const result = streamText({
|
|
33
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
34
|
+
* messages,
|
|
35
|
+
* tools: createCryptoQuantTools({
|
|
36
|
+
* cryptoquantApiKey: process.env.CRYPTOQUANT_API_KEY!,
|
|
37
|
+
* }),
|
|
38
|
+
* maxSteps: 5, // Allow multi-step tool execution
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* return result.toDataStreamResponse()
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function createCryptoQuantTools(config: CryptoQuantToolsConfig): {
|
|
46
|
+
/**
|
|
47
|
+
* Initialize CryptoQuant session
|
|
48
|
+
* Must be called before querying data
|
|
49
|
+
*/
|
|
50
|
+
initialize: import("ai").Tool<import("ai").Schema<import("./schemas.js").InitializeParams>, import("./types.js").InitializeResult> & {
|
|
51
|
+
execute: (args: import("./schemas.js").InitializeParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").InitializeResult>;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Discover available API endpoints
|
|
55
|
+
* Filter by asset (btc, eth) and/or category (market-data, exchange-flows)
|
|
56
|
+
*/
|
|
57
|
+
discover_endpoints: import("ai").Tool<import("ai").Schema<import("./schemas.js").DiscoverEndpointsParams>, import("./types.js").DiscoverResult> & {
|
|
58
|
+
execute: (args: import("./schemas.js").DiscoverEndpointsParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").DiscoverResult>;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Query on-chain data from CryptoQuant API
|
|
62
|
+
* Common endpoints: /v1/btc/market-data/mvrv, /v1/btc/market-indicator/sopr
|
|
63
|
+
*/
|
|
64
|
+
query_data: import("ai").Tool<import("ai").Schema<import("./schemas.js").QueryDataParams>, import("./types.js").QueryResult> & {
|
|
65
|
+
execute: (args: import("./schemas.js").QueryDataParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").QueryResult>;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Get explanation of a specific metric
|
|
69
|
+
* Includes thresholds and interpretation guidance
|
|
70
|
+
*/
|
|
71
|
+
describe_metric: import("ai").Tool<import("ai").Schema<import("./schemas.js").DescribeMetricParams>, import("./types.js").DescribeResult> & {
|
|
72
|
+
execute: (args: import("./schemas.js").DescribeMetricParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").DescribeResult>;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Quick market status summary
|
|
76
|
+
* Analyzes MVRV, SOPR, and exchange netflow to provide overall market sentiment
|
|
77
|
+
*/
|
|
78
|
+
market_summary: import("ai").Tool<import("ai").Schema<import("./schemas.js").MarketSummaryParams>, import("./types.js").MarketSummaryResult> & {
|
|
79
|
+
execute: (args: import("./schemas.js").MarketSummaryParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").MarketSummaryResult>;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Generate trading signal with confidence score
|
|
83
|
+
* Uses weighted metrics: MVRV (30%), SOPR (25%), Netflow (25%), Funding (20%)
|
|
84
|
+
*/
|
|
85
|
+
trading_signal: import("ai").Tool<import("ai").Schema<import("./schemas.js").TradingSignalParams>, import("./types.js").TradingSignalResult> & {
|
|
86
|
+
execute: (args: import("./schemas.js").TradingSignalParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").TradingSignalResult>;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Monitor whale (large holder) activity
|
|
90
|
+
* Tracks exchange flows and whale ratio
|
|
91
|
+
*/
|
|
92
|
+
whale_activity: import("ai").Tool<import("ai").Schema<import("./schemas.js").WhaleActivityParams>, import("./types.js").WhaleActivityResult> & {
|
|
93
|
+
execute: (args: import("./schemas.js").WhaleActivityParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").WhaleActivityResult>;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Pre-configured tools using CRYPTOQUANT_API_KEY environment variable
|
|
98
|
+
*
|
|
99
|
+
* Convenient for serverless environments where env vars are set.
|
|
100
|
+
* For explicit configuration, use createCryptoQuantTools() instead.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* import { cryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
105
|
+
*
|
|
106
|
+
* const result = streamText({
|
|
107
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
108
|
+
* messages,
|
|
109
|
+
* tools: cryptoQuantTools,
|
|
110
|
+
* maxSteps: 5,
|
|
111
|
+
* })
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare const cryptoQuantTools: {
|
|
115
|
+
/**
|
|
116
|
+
* Initialize CryptoQuant session
|
|
117
|
+
* Must be called before querying data
|
|
118
|
+
*/
|
|
119
|
+
initialize: import("ai").Tool<import("ai").Schema<import("./schemas.js").InitializeParams>, import("./types.js").InitializeResult> & {
|
|
120
|
+
execute: (args: import("./schemas.js").InitializeParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").InitializeResult>;
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Discover available API endpoints
|
|
124
|
+
* Filter by asset (btc, eth) and/or category (market-data, exchange-flows)
|
|
125
|
+
*/
|
|
126
|
+
discover_endpoints: import("ai").Tool<import("ai").Schema<import("./schemas.js").DiscoverEndpointsParams>, import("./types.js").DiscoverResult> & {
|
|
127
|
+
execute: (args: import("./schemas.js").DiscoverEndpointsParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").DiscoverResult>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Query on-chain data from CryptoQuant API
|
|
131
|
+
* Common endpoints: /v1/btc/market-data/mvrv, /v1/btc/market-indicator/sopr
|
|
132
|
+
*/
|
|
133
|
+
query_data: import("ai").Tool<import("ai").Schema<import("./schemas.js").QueryDataParams>, import("./types.js").QueryResult> & {
|
|
134
|
+
execute: (args: import("./schemas.js").QueryDataParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").QueryResult>;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Get explanation of a specific metric
|
|
138
|
+
* Includes thresholds and interpretation guidance
|
|
139
|
+
*/
|
|
140
|
+
describe_metric: import("ai").Tool<import("ai").Schema<import("./schemas.js").DescribeMetricParams>, import("./types.js").DescribeResult> & {
|
|
141
|
+
execute: (args: import("./schemas.js").DescribeMetricParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").DescribeResult>;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Quick market status summary
|
|
145
|
+
* Analyzes MVRV, SOPR, and exchange netflow to provide overall market sentiment
|
|
146
|
+
*/
|
|
147
|
+
market_summary: import("ai").Tool<import("ai").Schema<import("./schemas.js").MarketSummaryParams>, import("./types.js").MarketSummaryResult> & {
|
|
148
|
+
execute: (args: import("./schemas.js").MarketSummaryParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").MarketSummaryResult>;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Generate trading signal with confidence score
|
|
152
|
+
* Uses weighted metrics: MVRV (30%), SOPR (25%), Netflow (25%), Funding (20%)
|
|
153
|
+
*/
|
|
154
|
+
trading_signal: import("ai").Tool<import("ai").Schema<import("./schemas.js").TradingSignalParams>, import("./types.js").TradingSignalResult> & {
|
|
155
|
+
execute: (args: import("./schemas.js").TradingSignalParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").TradingSignalResult>;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Monitor whale (large holder) activity
|
|
159
|
+
* Tracks exchange flows and whale ratio
|
|
160
|
+
*/
|
|
161
|
+
whale_activity: import("ai").Tool<import("ai").Schema<import("./schemas.js").WhaleActivityParams>, import("./types.js").WhaleActivityResult> & {
|
|
162
|
+
execute: (args: import("./schemas.js").WhaleActivityParams, options: import("ai").ToolExecutionOptions) => PromiseLike<import("./types.js").WhaleActivityResult>;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/ai-sdk/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAsBH,OAAO,KAAK,EAAE,sBAAsB,EAAwB,MAAM,YAAY,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB;IAMjE;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;EAUN;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,gBAAgB;IA/GzB;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;IAUH;;;OAGG;;;;CAgCL,CAAC"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CryptoQuant tools for Vercel AI SDK
|
|
3
|
+
*
|
|
4
|
+
* Usage with streamText:
|
|
5
|
+
* ```typescript
|
|
6
|
+
* import { createCryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
7
|
+
*
|
|
8
|
+
* const result = streamText({
|
|
9
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
10
|
+
* tools: createCryptoQuantTools({ cryptoquantApiKey: 'cq-...' }),
|
|
11
|
+
* maxSteps: 5,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import { tool } from "ai";
|
|
16
|
+
import { executeDescribeMetric, executeDiscoverEndpoints, executeInitialize, executeMarketSummary, executeQueryData, executeTradingSignal, executeWhaleActivity, } from "./execute.js";
|
|
17
|
+
import { describeMetricSchema, discoverEndpointsSchema, initializeSchema, marketSummarySchema, queryDataSchema, tradingSignalSchema, whaleActivitySchema, } from "./schemas.js";
|
|
18
|
+
/**
|
|
19
|
+
* Create CryptoQuant tools for use with Vercel AI SDK's streamText/generateText
|
|
20
|
+
*
|
|
21
|
+
* @param config - Configuration including CryptoQuant API key
|
|
22
|
+
* @returns Object containing all CryptoQuant tools
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // In your Next.js API route
|
|
27
|
+
* import { streamText } from 'ai'
|
|
28
|
+
* import { anthropic } from '@ai-sdk/anthropic'
|
|
29
|
+
* import { createCryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
30
|
+
*
|
|
31
|
+
* export async function POST(req: Request) {
|
|
32
|
+
* const { messages } = await req.json()
|
|
33
|
+
*
|
|
34
|
+
* const result = streamText({
|
|
35
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
36
|
+
* messages,
|
|
37
|
+
* tools: createCryptoQuantTools({
|
|
38
|
+
* cryptoquantApiKey: process.env.CRYPTOQUANT_API_KEY!,
|
|
39
|
+
* }),
|
|
40
|
+
* maxSteps: 5, // Allow multi-step tool execution
|
|
41
|
+
* })
|
|
42
|
+
*
|
|
43
|
+
* return result.toDataStreamResponse()
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export function createCryptoQuantTools(config) {
|
|
48
|
+
const context = {
|
|
49
|
+
cryptoquantApiKey: config.cryptoquantApiKey,
|
|
50
|
+
};
|
|
51
|
+
return {
|
|
52
|
+
/**
|
|
53
|
+
* Initialize CryptoQuant session
|
|
54
|
+
* Must be called before querying data
|
|
55
|
+
*/
|
|
56
|
+
initialize: tool({
|
|
57
|
+
description: "Initialize CryptoQuant session. Must be called before querying data.",
|
|
58
|
+
parameters: initializeSchema,
|
|
59
|
+
execute: async (params) => {
|
|
60
|
+
return executeInitialize(params, context);
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
/**
|
|
64
|
+
* Discover available API endpoints
|
|
65
|
+
* Filter by asset (btc, eth) and/or category (market-data, exchange-flows)
|
|
66
|
+
*/
|
|
67
|
+
discover_endpoints: tool({
|
|
68
|
+
description: "Discover available API endpoints. Filter by asset (btc, eth, alt, stablecoin, erc20) and/or category (market-data, exchange-flows, network-data, etc.)",
|
|
69
|
+
parameters: discoverEndpointsSchema,
|
|
70
|
+
execute: async (params) => {
|
|
71
|
+
return executeDiscoverEndpoints(params);
|
|
72
|
+
},
|
|
73
|
+
}),
|
|
74
|
+
/**
|
|
75
|
+
* Query on-chain data from CryptoQuant API
|
|
76
|
+
* Common endpoints: /v1/btc/market-data/mvrv, /v1/btc/market-indicator/sopr
|
|
77
|
+
*/
|
|
78
|
+
query_data: tool({
|
|
79
|
+
description: "Query on-chain data from CryptoQuant API. Common endpoints: /v1/btc/market-data/mvrv (MVRV ratio), /v1/btc/market-indicator/sopr (SOPR), /v1/btc/exchange-flows/netflow (Exchange netflow)",
|
|
80
|
+
parameters: queryDataSchema,
|
|
81
|
+
execute: async (params) => {
|
|
82
|
+
return executeQueryData(params, context);
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
/**
|
|
86
|
+
* Get explanation of a specific metric
|
|
87
|
+
* Includes thresholds and interpretation guidance
|
|
88
|
+
*/
|
|
89
|
+
describe_metric: tool({
|
|
90
|
+
description: "Get explanation of a specific metric including thresholds and interpretation guidance. Use when user asks 'what is X?' about metrics like MVRV, SOPR, NUPL, etc.",
|
|
91
|
+
parameters: describeMetricSchema,
|
|
92
|
+
execute: async (params) => {
|
|
93
|
+
return executeDescribeMetric(params);
|
|
94
|
+
},
|
|
95
|
+
}),
|
|
96
|
+
/**
|
|
97
|
+
* Quick market status summary
|
|
98
|
+
* Analyzes MVRV, SOPR, and exchange netflow to provide overall market sentiment
|
|
99
|
+
*/
|
|
100
|
+
market_summary: tool({
|
|
101
|
+
description: "Get quick market status summary using key on-chain metrics (MVRV, SOPR, Netflow). Returns overall market sentiment with bullish/bearish signals.",
|
|
102
|
+
parameters: marketSummarySchema,
|
|
103
|
+
execute: async (params) => {
|
|
104
|
+
return executeMarketSummary(params, context);
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
/**
|
|
108
|
+
* Generate trading signal with confidence score
|
|
109
|
+
* Uses weighted metrics: MVRV (30%), SOPR (25%), Netflow (25%), Funding (20%)
|
|
110
|
+
*/
|
|
111
|
+
trading_signal: tool({
|
|
112
|
+
description: "Generate Buy/Sell/Hold trading signal with confidence score based on weighted on-chain metrics. Returns signal (STRONG BUY/BUY/HOLD/CAUTION/SELL) with detailed breakdown.",
|
|
113
|
+
parameters: tradingSignalSchema,
|
|
114
|
+
execute: async (params) => {
|
|
115
|
+
return executeTradingSignal(params, context);
|
|
116
|
+
},
|
|
117
|
+
}),
|
|
118
|
+
/**
|
|
119
|
+
* Monitor whale (large holder) activity
|
|
120
|
+
* Tracks exchange flows and whale ratio
|
|
121
|
+
*/
|
|
122
|
+
whale_activity: tool({
|
|
123
|
+
description: "Monitor whale (large holder) activity including exchange flows and whale ratio. Identifies accumulation or distribution patterns by large players.",
|
|
124
|
+
parameters: whaleActivitySchema,
|
|
125
|
+
execute: async (params) => {
|
|
126
|
+
return executeWhaleActivity(params, context);
|
|
127
|
+
},
|
|
128
|
+
}),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Pre-configured tools using CRYPTOQUANT_API_KEY environment variable
|
|
133
|
+
*
|
|
134
|
+
* Convenient for serverless environments where env vars are set.
|
|
135
|
+
* For explicit configuration, use createCryptoQuantTools() instead.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* import { cryptoQuantTools } from '@cryptoquant_official/mcp/ai-sdk'
|
|
140
|
+
*
|
|
141
|
+
* const result = streamText({
|
|
142
|
+
* model: anthropic('claude-sonnet-4-20250514'),
|
|
143
|
+
* messages,
|
|
144
|
+
* tools: cryptoQuantTools,
|
|
145
|
+
* maxSteps: 5,
|
|
146
|
+
* })
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
export const cryptoQuantTools = createCryptoQuantTools({
|
|
150
|
+
cryptoquantApiKey: process.env.CRYPTOQUANT_API_KEY || "",
|
|
151
|
+
});
|
|
152
|
+
//# sour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