helius-mcp 1.3.0 → 2.1.0
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/CHANGELOG.md +151 -79
- package/LICENSE +21 -21
- package/README.md +144 -132
- package/dist/http.d.ts +1 -1
- package/dist/index.js +2 -56
- package/dist/results/store.d.ts +8 -0
- package/dist/results/store.js +72 -0
- package/dist/results/types.d.ts +47 -0
- package/dist/results/types.js +1 -0
- package/dist/router/action-groups.d.ts +6 -0
- package/dist/router/action-groups.js +32 -0
- package/dist/router/action-handlers.d.ts +20 -0
- package/dist/router/action-handlers.js +125 -0
- package/dist/router/actions.d.ts +12 -0
- package/dist/router/actions.js +125 -0
- package/dist/router/catalog.d.ts +6 -0
- package/dist/router/catalog.js +394 -0
- package/dist/router/context.d.ts +5 -0
- package/dist/router/context.js +10 -0
- package/dist/router/dispatch.d.ts +4 -0
- package/dist/router/dispatch.js +276 -0
- package/dist/router/instructions.d.ts +1 -0
- package/dist/router/instructions.js +25 -0
- package/dist/router/register.d.ts +2 -0
- package/dist/router/register.js +15 -0
- package/dist/router/required-params.d.ts +9 -0
- package/dist/router/required-params.js +68 -0
- package/dist/router/responses.d.ts +29 -0
- package/dist/router/responses.js +186 -0
- package/dist/router/schemas.d.ts +224 -0
- package/dist/router/schemas.js +204 -0
- package/dist/router/telemetry.d.ts +27 -0
- package/dist/router/telemetry.js +52 -0
- package/dist/router/types.d.ts +46 -0
- package/dist/router/types.js +1 -0
- package/dist/scripts/validate-catalog.d.ts +2 -2
- package/dist/scripts/validate-catalog.js +10 -10
- package/dist/tools/accounts.js +5 -5
- package/dist/tools/assets.js +5 -5
- package/dist/tools/auth.js +392 -319
- package/dist/tools/config.js +3 -3
- package/dist/tools/das-extras.js +6 -6
- package/dist/tools/docs.js +55 -41
- package/dist/tools/enhanced-websockets.js +13 -13
- package/dist/tools/fees.js +3 -3
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +2 -80
- package/dist/tools/laserstream.js +20 -23
- package/dist/tools/network.js +10 -4
- package/dist/tools/plans.d.ts +0 -5
- package/dist/tools/plans.js +167 -12
- package/dist/tools/product-catalog.d.ts +1 -0
- package/dist/tools/product-catalog.js +52 -17
- package/dist/tools/recommend.d.ts +0 -1
- package/dist/tools/recommend.js +9 -28
- package/dist/tools/shared.d.ts +1 -0
- package/dist/tools/shared.js +21 -13
- package/dist/tools/solana-knowledge.js +23 -7
- package/dist/tools/staking.d.ts +2 -0
- package/dist/tools/staking.js +268 -0
- package/dist/tools/transactions.js +256 -3
- package/dist/tools/transfers.js +38 -43
- package/dist/tools/wallet.js +77 -17
- package/dist/tools/webhooks.js +3 -3
- package/dist/tools/zk-compression.d.ts +2 -0
- package/dist/tools/zk-compression.js +781 -0
- package/dist/utils/config.d.ts +2 -2
- package/dist/utils/config.js +68 -6
- package/dist/utils/errors.d.ts +10 -1
- package/dist/utils/errors.js +46 -12
- package/dist/utils/feedback.js +1 -4
- package/dist/utils/helius.js +25 -14
- package/dist/utils/ows.d.ts +74 -0
- package/dist/utils/ows.js +155 -0
- package/dist/utils/resilience.d.ts +39 -0
- package/dist/utils/resilience.js +130 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +63 -64
- package/system-prompts/helius/claude.system.md +200 -170
- package/system-prompts/helius/full.md +3236 -2869
- package/system-prompts/helius/openai.developer.md +200 -170
- package/system-prompts/helius-dflow/claude.system.md +324 -290
- package/system-prompts/helius-dflow/full.md +4160 -3648
- package/system-prompts/helius-dflow/openai.developer.md +324 -290
- package/system-prompts/helius-jupiter/claude.system.md +333 -0
- package/system-prompts/helius-jupiter/full.md +5133 -0
- package/system-prompts/helius-jupiter/openai.developer.md +333 -0
- package/system-prompts/helius-okx/claude.system.md +182 -0
- package/system-prompts/helius-okx/full.md +584 -0
- package/system-prompts/helius-okx/openai.developer.md +182 -0
- package/system-prompts/helius-phantom/claude.system.md +345 -333
- package/system-prompts/helius-phantom/full.md +5649 -5473
- package/system-prompts/helius-phantom/openai.developer.md +345 -333
- package/system-prompts/svm/claude.system.md +159 -159
- package/system-prompts/svm/full.md +631 -631
- package/system-prompts/svm/openai.developer.md +159 -159
- package/dist/scripts/test-htmltotext.d.ts +0 -5
- package/dist/scripts/test-htmltotext.js +0 -67
- package/dist/scripts/test-solana-knowledge.d.ts +0 -9
- package/dist/scripts/test-solana-knowledge.js +0 -272
- package/dist/scripts/validate-templates.d.ts +0 -12
- package/dist/scripts/validate-templates.js +0 -94
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
4
|
import { registerTools } from './tools/index.js';
|
|
5
|
+
import { ROUTER_INSTRUCTIONS } from './router/instructions.js';
|
|
5
6
|
import { setApiKey, setSessionSecretKey, setSessionWalletAddress } from './utils/helius.js';
|
|
6
7
|
import { getSharedApiKey, loadKeypairFromDisk } from './utils/config.js';
|
|
7
8
|
import { captureClientInfo, captureWalletAddress } from './utils/feedback.js';
|
|
@@ -12,62 +13,7 @@ const server = new McpServer({
|
|
|
12
13
|
name: 'helius-mcp',
|
|
13
14
|
version
|
|
14
15
|
}, {
|
|
15
|
-
instructions:
|
|
16
|
-
|
|
17
|
-
## Tool Routing
|
|
18
|
-
|
|
19
|
-
| Intent | Tool | Credits |
|
|
20
|
-
|--------|------|---------|
|
|
21
|
-
| SOL balance | getBalance | 1 |
|
|
22
|
-
| token balances by wallet | getTokenBalances | 10/pg |
|
|
23
|
-
| full portfolio + USD | getWalletBalances | 100 |
|
|
24
|
-
| parse tx by signature | parseTransactions | 100 |
|
|
25
|
-
| wallet transaction history | getTransactionHistory | ~110 |
|
|
26
|
-
| balance deltas/tx | getWalletHistory | 100 |
|
|
27
|
-
| sends/receives | getWalletTransfers | 100 |
|
|
28
|
-
| asset by mint (single or batch) | getAsset | 10 |
|
|
29
|
-
| wallet NFTs | getAssetsByOwner | 10 |
|
|
30
|
-
| filtered asset search / by creator or authority | searchAssets | 10 |
|
|
31
|
-
| collection NFTs | getAssetsByGroup | 10 |
|
|
32
|
-
| asset tx history (by mint) | getSignaturesForAsset | 10 |
|
|
33
|
-
| edition prints of master NFT | getNftEditions | 10 |
|
|
34
|
-
| cNFT Merkle proof (single or batch) | getAssetProof, getAssetProofBatch | 10 |
|
|
35
|
-
| raw account inspection (single or batch) | getAccountInfo | 1 |
|
|
36
|
-
| token holders by mint | getTokenHolders | ~20 |
|
|
37
|
-
| token accounts by mint or owner | getTokenAccounts | 10 |
|
|
38
|
-
| program accounts / protocol state | getProgramAccounts | 10 |
|
|
39
|
-
| network status / epoch / block height | getNetworkStatus | 3 |
|
|
40
|
-
| block data by slot | getBlock | 1 |
|
|
41
|
-
| plans/pricing | getHeliusPlanInfo | 0 |
|
|
42
|
-
| plan comparison | compareHeliusPlans | 0 |
|
|
43
|
-
| plan upgrade / billing | previewUpgrade, upgradePlan, payRenewal | 0 |
|
|
44
|
-
| rate limits/credits | getRateLimitInfo | 0 |
|
|
45
|
-
| API docs by topic | lookupHeliusDocs | 0 |
|
|
46
|
-
| error diagnosis | troubleshootError | 0 |
|
|
47
|
-
| tx sending / Jito / SWQoS | getSenderInfo | 0 |
|
|
48
|
-
| webhook setup guide | getWebhookGuide | 0 |
|
|
49
|
-
| streaming latency | getLatencyComparison | 0 |
|
|
50
|
-
| pump.fun tokens | getPumpFunGuide | 0 |
|
|
51
|
-
| project architecture / stack selection | recommendStack | 0 |
|
|
52
|
-
| Solana SIMDs / protocol proposals | getSIMD, listSIMDs | 0 |
|
|
53
|
-
| Solana source / docs search | searchSolanaDocs, readSolanaSourceFile | 0 |
|
|
54
|
-
| Helius blog posts | fetchHeliusBlog | 0 |
|
|
55
|
-
| wallet identity | getWalletIdentity | 100 |
|
|
56
|
-
| batch wallet identity | batchWalletIdentity | 100 |
|
|
57
|
-
| funding source | getWalletFundedBy | 100 |
|
|
58
|
-
| event notifications (any plan) | createWebhook | 100 |
|
|
59
|
-
| live streaming (WS, Business+) | transactionSubscribe, accountSubscribe | — |
|
|
60
|
-
| production streaming (gRPC, Pro) | laserstreamSubscribe | — |
|
|
61
|
-
| Account setup | getStarted → generateKeypair → agenticSignup | — |
|
|
62
|
-
|
|
63
|
-
Rules:
|
|
64
|
-
- For pricing, start with getHeliusPlanInfo — NOT lookupHeliusDocs.
|
|
65
|
-
- For errors, use troubleshootError first.
|
|
66
|
-
- When a user describes ANY project they want to build ("I want to build/make/create...", "help me build...", "I need a..."), call recommendStack immediately with their description — do not ask clarifying questions first. After recommendations, use getHeliusPlanInfo for pricing and lookupHeliusDocs for API details.
|
|
67
|
-
- "send SOL" / "transfer SOL" → transferSol (~3 credits). "send tokens" / "transfer USDC/BONK/etc" → transferToken (~13 credits). Both require a configured keypair (generateKeypair) and use Helius Sender.
|
|
68
|
-
|
|
69
|
-
## Feedback
|
|
70
|
-
Every tool accepts \`_feedback\` and \`_model\` params. Always include \`_model\` with your LLM model identifier (e.g. "claude-sonnet-4-20250514", "gpt-4o"). After each tool call, assess the response and include \`_feedback\` on your next call — what worked, what was confusing, what data was missing or could be improved.`
|
|
16
|
+
instructions: ROUTER_INSTRUCTIONS
|
|
71
17
|
});
|
|
72
18
|
registerTools(server);
|
|
73
19
|
// Capture MCP client identity (Cursor, Claude Code, etc.) after handshake
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { StoredResult } from './types.js';
|
|
2
|
+
export declare function putStoredResult(input: Omit<StoredResult, 'resultId' | 'createdAt' | 'expiresAt' | 'payloadSize'>): StoredResult;
|
|
3
|
+
export declare function getStoredResult(resultId: string, ownerSessionKey: string): StoredResult | null;
|
|
4
|
+
export declare function clearStoredResults(): void;
|
|
5
|
+
export declare function getStoredResultStats(): {
|
|
6
|
+
count: number;
|
|
7
|
+
totalPayloadBytes: number;
|
|
8
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
const MAX_RESULTS = 10;
|
|
3
|
+
const MAX_TOTAL_PAYLOAD_BYTES = 250 * 1024;
|
|
4
|
+
const RESULT_TTL_MS = 5 * 60 * 1000;
|
|
5
|
+
const results = new Map();
|
|
6
|
+
function estimateBytes(value) {
|
|
7
|
+
return Buffer.byteLength(JSON.stringify(value), 'utf8');
|
|
8
|
+
}
|
|
9
|
+
function sweepExpired(now = Date.now()) {
|
|
10
|
+
for (const [resultId, result] of results) {
|
|
11
|
+
if (result.expiresAt <= now) {
|
|
12
|
+
results.delete(resultId);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function currentTotalBytes() {
|
|
17
|
+
let total = 0;
|
|
18
|
+
for (const result of results.values()) {
|
|
19
|
+
total += result.payloadSize;
|
|
20
|
+
}
|
|
21
|
+
return total;
|
|
22
|
+
}
|
|
23
|
+
function touch(resultId, result) {
|
|
24
|
+
results.delete(resultId);
|
|
25
|
+
results.set(resultId, result);
|
|
26
|
+
}
|
|
27
|
+
function evictToFit() {
|
|
28
|
+
sweepExpired();
|
|
29
|
+
while (results.size > MAX_RESULTS || currentTotalBytes() > MAX_TOTAL_PAYLOAD_BYTES) {
|
|
30
|
+
const oldest = results.keys().next().value;
|
|
31
|
+
if (!oldest) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
results.delete(oldest);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export function putStoredResult(input) {
|
|
38
|
+
const createdAt = Date.now();
|
|
39
|
+
const payloadSize = estimateBytes(input.payload);
|
|
40
|
+
const stored = {
|
|
41
|
+
...input,
|
|
42
|
+
resultId: randomUUID(),
|
|
43
|
+
createdAt,
|
|
44
|
+
expiresAt: createdAt + RESULT_TTL_MS,
|
|
45
|
+
payloadSize,
|
|
46
|
+
};
|
|
47
|
+
results.set(stored.resultId, stored);
|
|
48
|
+
evictToFit();
|
|
49
|
+
return stored;
|
|
50
|
+
}
|
|
51
|
+
export function getStoredResult(resultId, ownerSessionKey) {
|
|
52
|
+
sweepExpired();
|
|
53
|
+
const result = results.get(resultId);
|
|
54
|
+
if (!result) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (result.ownerSessionKey !== ownerSessionKey) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
touch(resultId, result);
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
export function clearStoredResults() {
|
|
64
|
+
results.clear();
|
|
65
|
+
}
|
|
66
|
+
export function getStoredResultStats() {
|
|
67
|
+
sweepExpired();
|
|
68
|
+
return {
|
|
69
|
+
count: results.size,
|
|
70
|
+
totalPayloadBytes: currentTotalBytes(),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { RoutedPublicToolName } from '../router/action-groups.js';
|
|
2
|
+
import type { ActionName } from '../router/actions.js';
|
|
3
|
+
import type { DetailLevel, ResponseFamily } from '../router/types.js';
|
|
4
|
+
export type TransactionHistoryContinuation = {
|
|
5
|
+
kind: 'signaturesQuick';
|
|
6
|
+
nextBefore?: string;
|
|
7
|
+
lastSeenSignature?: string;
|
|
8
|
+
until?: string;
|
|
9
|
+
} | {
|
|
10
|
+
kind: 'historyApi';
|
|
11
|
+
paginationToken?: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'rawApi';
|
|
14
|
+
paginationToken?: string;
|
|
15
|
+
};
|
|
16
|
+
export type ContinuationState = {
|
|
17
|
+
model: 'none';
|
|
18
|
+
} | {
|
|
19
|
+
model: 'page';
|
|
20
|
+
nextPage?: number;
|
|
21
|
+
} | {
|
|
22
|
+
model: 'transactionHistory';
|
|
23
|
+
next?: TransactionHistoryContinuation;
|
|
24
|
+
};
|
|
25
|
+
export type ActionRecipe = {
|
|
26
|
+
publicTool: RoutedPublicToolName;
|
|
27
|
+
action: ActionName;
|
|
28
|
+
params: Record<string, unknown>;
|
|
29
|
+
responseFamily: ResponseFamily;
|
|
30
|
+
defaultDetail: DetailLevel;
|
|
31
|
+
};
|
|
32
|
+
export type ResultPayload = {
|
|
33
|
+
recipe: ActionRecipe;
|
|
34
|
+
continuation: ContinuationState;
|
|
35
|
+
sectionHints?: string[];
|
|
36
|
+
};
|
|
37
|
+
export type StoredResult = {
|
|
38
|
+
resultId: string;
|
|
39
|
+
kind: ResponseFamily;
|
|
40
|
+
ownerSessionKey: string;
|
|
41
|
+
summary: string;
|
|
42
|
+
availableExpansions: string[];
|
|
43
|
+
createdAt: number;
|
|
44
|
+
expiresAt: number;
|
|
45
|
+
payload: ResultPayload;
|
|
46
|
+
payloadSize: number;
|
|
47
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ActionName } from './actions.js';
|
|
2
|
+
export declare const PUBLIC_TOOL_NAMES: readonly ["heliusAccount", "heliusWallet", "heliusAsset", "heliusTransaction", "heliusChain", "heliusStreaming", "heliusKnowledge", "heliusWrite", "heliusCompression", "expandResult"];
|
|
3
|
+
export type PublicToolName = typeof PUBLIC_TOOL_NAMES[number];
|
|
4
|
+
export type RoutedPublicToolName = Exclude<PublicToolName, 'expandResult'>;
|
|
5
|
+
export declare const ACTION_GROUPS: Record<RoutedPublicToolName, readonly ActionName[]>;
|
|
6
|
+
export declare function findPublicToolForAction(action: ActionName): RoutedPublicToolName;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HELIUS_ACCOUNT_ACTIONS, HELIUS_ASSET_ACTIONS, HELIUS_CHAIN_ACTIONS, HELIUS_COMPRESSION_ACTIONS, HELIUS_KNOWLEDGE_ACTIONS, HELIUS_STREAMING_ACTIONS, HELIUS_TRANSACTION_ACTIONS, HELIUS_WALLET_ACTIONS, HELIUS_WRITE_ACTIONS, } from './actions.js';
|
|
2
|
+
export const PUBLIC_TOOL_NAMES = [
|
|
3
|
+
'heliusAccount',
|
|
4
|
+
'heliusWallet',
|
|
5
|
+
'heliusAsset',
|
|
6
|
+
'heliusTransaction',
|
|
7
|
+
'heliusChain',
|
|
8
|
+
'heliusStreaming',
|
|
9
|
+
'heliusKnowledge',
|
|
10
|
+
'heliusWrite',
|
|
11
|
+
'heliusCompression',
|
|
12
|
+
'expandResult',
|
|
13
|
+
];
|
|
14
|
+
export const ACTION_GROUPS = {
|
|
15
|
+
heliusAccount: HELIUS_ACCOUNT_ACTIONS,
|
|
16
|
+
heliusWallet: HELIUS_WALLET_ACTIONS,
|
|
17
|
+
heliusAsset: HELIUS_ASSET_ACTIONS,
|
|
18
|
+
heliusTransaction: HELIUS_TRANSACTION_ACTIONS,
|
|
19
|
+
heliusChain: HELIUS_CHAIN_ACTIONS,
|
|
20
|
+
heliusStreaming: HELIUS_STREAMING_ACTIONS,
|
|
21
|
+
heliusKnowledge: HELIUS_KNOWLEDGE_ACTIONS,
|
|
22
|
+
heliusWrite: HELIUS_WRITE_ACTIONS,
|
|
23
|
+
heliusCompression: HELIUS_COMPRESSION_ACTIONS,
|
|
24
|
+
};
|
|
25
|
+
export function findPublicToolForAction(action) {
|
|
26
|
+
for (const [tool, actions] of Object.entries(ACTION_GROUPS)) {
|
|
27
|
+
if (actions.includes(action)) {
|
|
28
|
+
return tool;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`No public tool mapping found for action "${action}"`);
|
|
32
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import type { ActionName } from './actions.js';
|
|
3
|
+
export type ActionHandlerResponse = {
|
|
4
|
+
content?: Array<{
|
|
5
|
+
type?: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
}>;
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
structuredContent?: unknown;
|
|
10
|
+
};
|
|
11
|
+
export type ActionHandler = (params: Record<string, unknown>, extra: unknown) => Promise<ActionHandlerResponse> | ActionHandlerResponse;
|
|
12
|
+
export type ActionHandlerDefinition = {
|
|
13
|
+
name: ActionName;
|
|
14
|
+
description?: string;
|
|
15
|
+
inputSchema?: unknown;
|
|
16
|
+
handler: ActionHandler;
|
|
17
|
+
};
|
|
18
|
+
export declare function registerActionHandlers(server: McpServer): void;
|
|
19
|
+
export declare function getActionHandlers(): Map<ActionName, ActionHandlerDefinition>;
|
|
20
|
+
export declare function callActionHandler(action: ActionName, params: Record<string, unknown>, extra: unknown): Promise<ActionHandlerResponse>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { registerAuthTools } from '../tools/auth.js';
|
|
3
|
+
import { registerConfigTools } from '../tools/config.js';
|
|
4
|
+
import { registerPlanTools } from '../tools/plans.js';
|
|
5
|
+
import { registerBalanceTools } from '../tools/balance.js';
|
|
6
|
+
import { registerTransactionTools } from '../tools/transactions.js';
|
|
7
|
+
import { registerAssetTools } from '../tools/assets.js';
|
|
8
|
+
import { registerAccountTools } from '../tools/accounts.js';
|
|
9
|
+
import { registerFeeTools } from '../tools/fees.js';
|
|
10
|
+
import { registerNetworkTools } from '../tools/network.js';
|
|
11
|
+
import { registerBlockTools } from '../tools/blocks.js';
|
|
12
|
+
import { registerTokenTools } from '../tools/tokens.js';
|
|
13
|
+
import { registerDasExtraTools } from '../tools/das-extras.js';
|
|
14
|
+
import { registerWebhookTools } from '../tools/webhooks.js';
|
|
15
|
+
import { registerEnhancedWebSocketTools } from '../tools/enhanced-websockets.js';
|
|
16
|
+
import { registerLaserstreamTools } from '../tools/laserstream.js';
|
|
17
|
+
import { registerWalletTools } from '../tools/wallet.js';
|
|
18
|
+
import { registerDocsTools } from '../tools/docs.js';
|
|
19
|
+
import { registerGuideTools } from '../tools/guides.js';
|
|
20
|
+
import { registerRecommendTools } from '../tools/recommend.js';
|
|
21
|
+
import { registerSolanaKnowledgeTools } from '../tools/solana-knowledge.js';
|
|
22
|
+
import { registerTransferTools } from '../tools/transfers.js';
|
|
23
|
+
import { registerZkCompressionTools } from '../tools/zk-compression.js';
|
|
24
|
+
import { registerStakingTools } from '../tools/staking.js';
|
|
25
|
+
function isZodType(value) {
|
|
26
|
+
return typeof value === 'object' && value !== null && typeof value.safeParse === 'function';
|
|
27
|
+
}
|
|
28
|
+
function buildRuntimeSchema(inputSchema) {
|
|
29
|
+
if (isZodType(inputSchema) && 'passthrough' in inputSchema && typeof inputSchema.passthrough === 'function') {
|
|
30
|
+
return inputSchema.passthrough();
|
|
31
|
+
}
|
|
32
|
+
if (!inputSchema || typeof inputSchema !== 'object' || Array.isArray(inputSchema)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const rawShape = {};
|
|
36
|
+
for (const [key, value] of Object.entries(inputSchema)) {
|
|
37
|
+
if (isZodType(value)) {
|
|
38
|
+
rawShape[key] = value;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (Object.keys(rawShape).length === 0) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
return z.object(rawShape).passthrough();
|
|
45
|
+
}
|
|
46
|
+
function materializeActionParams(tool, params) {
|
|
47
|
+
const schema = buildRuntimeSchema(tool.inputSchema);
|
|
48
|
+
if (!schema) {
|
|
49
|
+
return params;
|
|
50
|
+
}
|
|
51
|
+
const parsed = schema.safeParse(params);
|
|
52
|
+
if (parsed.success) {
|
|
53
|
+
return parsed.data;
|
|
54
|
+
}
|
|
55
|
+
const issue = parsed.error.issues[0];
|
|
56
|
+
const path = issue?.path?.length ? issue.path.join('.') : 'input';
|
|
57
|
+
const message = `Invalid parameters for ${tool.name}: ${path} ${issue?.message ?? 'is invalid'}`.trim();
|
|
58
|
+
throw new Error(message);
|
|
59
|
+
}
|
|
60
|
+
class ActionHandlerCollector {
|
|
61
|
+
tools = new Map();
|
|
62
|
+
tool(name, ...rest) {
|
|
63
|
+
let description;
|
|
64
|
+
let inputSchema;
|
|
65
|
+
if (typeof rest[0] === 'string') {
|
|
66
|
+
description = rest.shift();
|
|
67
|
+
}
|
|
68
|
+
if (rest.length > 1 && typeof rest[0] === 'object' && rest[0] !== null) {
|
|
69
|
+
inputSchema = rest.shift();
|
|
70
|
+
}
|
|
71
|
+
const handler = rest[0];
|
|
72
|
+
if (typeof handler !== 'function') {
|
|
73
|
+
throw new Error(`Action handler "${name}" is missing a callable handler`);
|
|
74
|
+
}
|
|
75
|
+
this.tools.set(name, {
|
|
76
|
+
name: name,
|
|
77
|
+
description,
|
|
78
|
+
inputSchema,
|
|
79
|
+
handler: handler,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
let cachedActionHandlers = null;
|
|
84
|
+
export function registerActionHandlers(server) {
|
|
85
|
+
registerAuthTools(server);
|
|
86
|
+
registerConfigTools(server);
|
|
87
|
+
registerPlanTools(server);
|
|
88
|
+
registerBalanceTools(server);
|
|
89
|
+
registerTransactionTools(server);
|
|
90
|
+
registerAssetTools(server);
|
|
91
|
+
registerAccountTools(server);
|
|
92
|
+
registerFeeTools(server);
|
|
93
|
+
registerNetworkTools(server);
|
|
94
|
+
registerBlockTools(server);
|
|
95
|
+
registerTokenTools(server);
|
|
96
|
+
registerDasExtraTools(server);
|
|
97
|
+
registerWebhookTools(server);
|
|
98
|
+
registerEnhancedWebSocketTools(server);
|
|
99
|
+
registerLaserstreamTools(server);
|
|
100
|
+
registerWalletTools(server);
|
|
101
|
+
registerDocsTools(server);
|
|
102
|
+
registerGuideTools(server);
|
|
103
|
+
registerRecommendTools(server);
|
|
104
|
+
registerSolanaKnowledgeTools(server);
|
|
105
|
+
registerTransferTools(server);
|
|
106
|
+
registerZkCompressionTools(server);
|
|
107
|
+
registerStakingTools(server);
|
|
108
|
+
}
|
|
109
|
+
export function getActionHandlers() {
|
|
110
|
+
if (cachedActionHandlers) {
|
|
111
|
+
return cachedActionHandlers;
|
|
112
|
+
}
|
|
113
|
+
const collector = new ActionHandlerCollector();
|
|
114
|
+
registerActionHandlers(collector);
|
|
115
|
+
cachedActionHandlers = collector.tools;
|
|
116
|
+
return cachedActionHandlers;
|
|
117
|
+
}
|
|
118
|
+
export async function callActionHandler(action, params, extra) {
|
|
119
|
+
const tool = getActionHandlers().get(action);
|
|
120
|
+
if (!tool) {
|
|
121
|
+
throw new Error(`No action handler registered for action "${action}"`);
|
|
122
|
+
}
|
|
123
|
+
const normalizedParams = materializeActionParams(tool, params);
|
|
124
|
+
return await Promise.resolve(tool.handler(normalizedParams, extra));
|
|
125
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const HELIUS_ACCOUNT_ACTIONS: readonly ["getStarted", "setHeliusApiKey", "generateKeypair", "signup", "getAccountStatus", "getAccountPlan", "getHeliusPlanInfo", "compareHeliusPlans", "previewUpgrade", "upgradePlan", "payRenewal", "purchaseCredits"];
|
|
2
|
+
export declare const HELIUS_WALLET_ACTIONS: readonly ["getBalance", "getTokenBalances", "getWalletBalances", "getWalletBalanceAt", "getWalletHistory", "getWalletTransfers", "getWalletIdentity", "batchWalletIdentity", "getWalletFundedBy"];
|
|
3
|
+
export declare const HELIUS_ASSET_ACTIONS: readonly ["getAsset", "getAssetsByOwner", "searchAssets", "getAssetsByGroup", "getAssetProof", "getAssetProofBatch", "getSignaturesForAsset", "getNftEditions", "getTokenHolders"];
|
|
4
|
+
export declare const HELIUS_TRANSACTION_ACTIONS: readonly ["parseTransactions", "getTransactionHistory", "getTransfersByAddress"];
|
|
5
|
+
export declare const HELIUS_CHAIN_ACTIONS: readonly ["getAccountInfo", "getTokenAccounts", "getProgramAccounts", "getBlock", "getNetworkStatus", "getPriorityFeeEstimate", "simulateTransaction", "getStakeAccounts", "getWithdrawableAmount"];
|
|
6
|
+
export declare const HELIUS_STREAMING_ACTIONS: readonly ["createWebhook", "getAllWebhooks", "getWebhookByID", "updateWebhook", "deleteWebhook", "transactionSubscribe", "accountSubscribe", "laserstreamSubscribe"];
|
|
7
|
+
export declare const HELIUS_KNOWLEDGE_ACTIONS: readonly ["lookupHeliusDocs", "listHeliusDocTopics", "getHeliusCreditsInfo", "getRateLimitInfo", "troubleshootError", "recommendStack", "getSIMD", "listSIMDs", "searchSolanaDocs", "readSolanaSourceFile", "fetchHeliusBlog", "getPumpFunGuide", "getSenderInfo", "getWebhookGuide", "getLatencyComparison", "getEnhancedWebSocketInfo", "getLaserstreamInfo"];
|
|
8
|
+
export declare const HELIUS_WRITE_ACTIONS: readonly ["transferSol", "transferToken", "stakeSOL", "unstakeSOL", "withdrawStake"];
|
|
9
|
+
export declare const HELIUS_COMPRESSION_ACTIONS: readonly ["getCompressedAccount", "getCompressedAccountsByOwner", "getMultipleCompressedAccounts", "getCompressedBalance", "getCompressedBalanceByOwner", "getCompressedMintTokenHolders", "getCompressedTokenAccountBalance", "getCompressedTokenAccountsByOwner", "getCompressedTokenAccountsByDelegate", "getCompressedTokenBalancesByOwnerV2", "getCompressedAccountProof", "getMultipleCompressedAccountProofs", "getMultipleNewAddressProofs", "getCompressionSignaturesForAccount", "getCompressionSignaturesForAddress", "getCompressionSignaturesForOwner", "getCompressionSignaturesForTokenOwner", "getLatestCompressionSignatures", "getLatestNonVotingSignatures", "getTransactionWithCompressionInfo", "getValidityProof", "getIndexerHealth", "getIndexerSlot"];
|
|
10
|
+
export declare const ACTION_NAMES: readonly ["getStarted", "setHeliusApiKey", "generateKeypair", "signup", "getAccountStatus", "getAccountPlan", "getHeliusPlanInfo", "compareHeliusPlans", "previewUpgrade", "upgradePlan", "payRenewal", "purchaseCredits", "getBalance", "getTokenBalances", "getWalletBalances", "getWalletBalanceAt", "getWalletHistory", "getWalletTransfers", "getWalletIdentity", "batchWalletIdentity", "getWalletFundedBy", "getAsset", "getAssetsByOwner", "searchAssets", "getAssetsByGroup", "getAssetProof", "getAssetProofBatch", "getSignaturesForAsset", "getNftEditions", "getTokenHolders", "parseTransactions", "getTransactionHistory", "getTransfersByAddress", "getAccountInfo", "getTokenAccounts", "getProgramAccounts", "getBlock", "getNetworkStatus", "getPriorityFeeEstimate", "simulateTransaction", "getStakeAccounts", "getWithdrawableAmount", "createWebhook", "getAllWebhooks", "getWebhookByID", "updateWebhook", "deleteWebhook", "transactionSubscribe", "accountSubscribe", "laserstreamSubscribe", "lookupHeliusDocs", "listHeliusDocTopics", "getHeliusCreditsInfo", "getRateLimitInfo", "troubleshootError", "recommendStack", "getSIMD", "listSIMDs", "searchSolanaDocs", "readSolanaSourceFile", "fetchHeliusBlog", "getPumpFunGuide", "getSenderInfo", "getWebhookGuide", "getLatencyComparison", "getEnhancedWebSocketInfo", "getLaserstreamInfo", "transferSol", "transferToken", "stakeSOL", "unstakeSOL", "withdrawStake", "getCompressedAccount", "getCompressedAccountsByOwner", "getMultipleCompressedAccounts", "getCompressedBalance", "getCompressedBalanceByOwner", "getCompressedMintTokenHolders", "getCompressedTokenAccountBalance", "getCompressedTokenAccountsByOwner", "getCompressedTokenAccountsByDelegate", "getCompressedTokenBalancesByOwnerV2", "getCompressedAccountProof", "getMultipleCompressedAccountProofs", "getMultipleNewAddressProofs", "getCompressionSignaturesForAccount", "getCompressionSignaturesForAddress", "getCompressionSignaturesForOwner", "getCompressionSignaturesForTokenOwner", "getLatestCompressionSignatures", "getLatestNonVotingSignatures", "getTransactionWithCompressionInfo", "getValidityProof", "getIndexerHealth", "getIndexerSlot"];
|
|
11
|
+
export type ActionName = typeof ACTION_NAMES[number];
|
|
12
|
+
export declare const ACTION_NAME_SET: Set<string>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export const HELIUS_ACCOUNT_ACTIONS = [
|
|
2
|
+
'getStarted',
|
|
3
|
+
'setHeliusApiKey',
|
|
4
|
+
'generateKeypair',
|
|
5
|
+
'signup',
|
|
6
|
+
'getAccountStatus',
|
|
7
|
+
'getAccountPlan',
|
|
8
|
+
'getHeliusPlanInfo',
|
|
9
|
+
'compareHeliusPlans',
|
|
10
|
+
'previewUpgrade',
|
|
11
|
+
'upgradePlan',
|
|
12
|
+
'payRenewal',
|
|
13
|
+
'purchaseCredits',
|
|
14
|
+
];
|
|
15
|
+
export const HELIUS_WALLET_ACTIONS = [
|
|
16
|
+
'getBalance',
|
|
17
|
+
'getTokenBalances',
|
|
18
|
+
'getWalletBalances',
|
|
19
|
+
'getWalletBalanceAt',
|
|
20
|
+
'getWalletHistory',
|
|
21
|
+
'getWalletTransfers',
|
|
22
|
+
'getWalletIdentity',
|
|
23
|
+
'batchWalletIdentity',
|
|
24
|
+
'getWalletFundedBy',
|
|
25
|
+
];
|
|
26
|
+
export const HELIUS_ASSET_ACTIONS = [
|
|
27
|
+
'getAsset',
|
|
28
|
+
'getAssetsByOwner',
|
|
29
|
+
'searchAssets',
|
|
30
|
+
'getAssetsByGroup',
|
|
31
|
+
'getAssetProof',
|
|
32
|
+
'getAssetProofBatch',
|
|
33
|
+
'getSignaturesForAsset',
|
|
34
|
+
'getNftEditions',
|
|
35
|
+
'getTokenHolders',
|
|
36
|
+
];
|
|
37
|
+
export const HELIUS_TRANSACTION_ACTIONS = [
|
|
38
|
+
'parseTransactions',
|
|
39
|
+
'getTransactionHistory',
|
|
40
|
+
'getTransfersByAddress',
|
|
41
|
+
];
|
|
42
|
+
export const HELIUS_CHAIN_ACTIONS = [
|
|
43
|
+
'getAccountInfo',
|
|
44
|
+
'getTokenAccounts',
|
|
45
|
+
'getProgramAccounts',
|
|
46
|
+
'getBlock',
|
|
47
|
+
'getNetworkStatus',
|
|
48
|
+
'getPriorityFeeEstimate',
|
|
49
|
+
'simulateTransaction',
|
|
50
|
+
'getStakeAccounts',
|
|
51
|
+
'getWithdrawableAmount',
|
|
52
|
+
];
|
|
53
|
+
export const HELIUS_STREAMING_ACTIONS = [
|
|
54
|
+
'createWebhook',
|
|
55
|
+
'getAllWebhooks',
|
|
56
|
+
'getWebhookByID',
|
|
57
|
+
'updateWebhook',
|
|
58
|
+
'deleteWebhook',
|
|
59
|
+
'transactionSubscribe',
|
|
60
|
+
'accountSubscribe',
|
|
61
|
+
'laserstreamSubscribe',
|
|
62
|
+
];
|
|
63
|
+
export const HELIUS_KNOWLEDGE_ACTIONS = [
|
|
64
|
+
'lookupHeliusDocs',
|
|
65
|
+
'listHeliusDocTopics',
|
|
66
|
+
'getHeliusCreditsInfo',
|
|
67
|
+
'getRateLimitInfo',
|
|
68
|
+
'troubleshootError',
|
|
69
|
+
'recommendStack',
|
|
70
|
+
'getSIMD',
|
|
71
|
+
'listSIMDs',
|
|
72
|
+
'searchSolanaDocs',
|
|
73
|
+
'readSolanaSourceFile',
|
|
74
|
+
'fetchHeliusBlog',
|
|
75
|
+
'getPumpFunGuide',
|
|
76
|
+
'getSenderInfo',
|
|
77
|
+
'getWebhookGuide',
|
|
78
|
+
'getLatencyComparison',
|
|
79
|
+
'getEnhancedWebSocketInfo',
|
|
80
|
+
'getLaserstreamInfo',
|
|
81
|
+
];
|
|
82
|
+
export const HELIUS_WRITE_ACTIONS = [
|
|
83
|
+
'transferSol',
|
|
84
|
+
'transferToken',
|
|
85
|
+
'stakeSOL',
|
|
86
|
+
'unstakeSOL',
|
|
87
|
+
'withdrawStake',
|
|
88
|
+
];
|
|
89
|
+
export const HELIUS_COMPRESSION_ACTIONS = [
|
|
90
|
+
'getCompressedAccount',
|
|
91
|
+
'getCompressedAccountsByOwner',
|
|
92
|
+
'getMultipleCompressedAccounts',
|
|
93
|
+
'getCompressedBalance',
|
|
94
|
+
'getCompressedBalanceByOwner',
|
|
95
|
+
'getCompressedMintTokenHolders',
|
|
96
|
+
'getCompressedTokenAccountBalance',
|
|
97
|
+
'getCompressedTokenAccountsByOwner',
|
|
98
|
+
'getCompressedTokenAccountsByDelegate',
|
|
99
|
+
'getCompressedTokenBalancesByOwnerV2',
|
|
100
|
+
'getCompressedAccountProof',
|
|
101
|
+
'getMultipleCompressedAccountProofs',
|
|
102
|
+
'getMultipleNewAddressProofs',
|
|
103
|
+
'getCompressionSignaturesForAccount',
|
|
104
|
+
'getCompressionSignaturesForAddress',
|
|
105
|
+
'getCompressionSignaturesForOwner',
|
|
106
|
+
'getCompressionSignaturesForTokenOwner',
|
|
107
|
+
'getLatestCompressionSignatures',
|
|
108
|
+
'getLatestNonVotingSignatures',
|
|
109
|
+
'getTransactionWithCompressionInfo',
|
|
110
|
+
'getValidityProof',
|
|
111
|
+
'getIndexerHealth',
|
|
112
|
+
'getIndexerSlot',
|
|
113
|
+
];
|
|
114
|
+
export const ACTION_NAMES = [
|
|
115
|
+
...HELIUS_ACCOUNT_ACTIONS,
|
|
116
|
+
...HELIUS_WALLET_ACTIONS,
|
|
117
|
+
...HELIUS_ASSET_ACTIONS,
|
|
118
|
+
...HELIUS_TRANSACTION_ACTIONS,
|
|
119
|
+
...HELIUS_CHAIN_ACTIONS,
|
|
120
|
+
...HELIUS_STREAMING_ACTIONS,
|
|
121
|
+
...HELIUS_KNOWLEDGE_ACTIONS,
|
|
122
|
+
...HELIUS_WRITE_ACTIONS,
|
|
123
|
+
...HELIUS_COMPRESSION_ACTIONS,
|
|
124
|
+
];
|
|
125
|
+
export const ACTION_NAME_SET = new Set(ACTION_NAMES);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ActionName } from './actions.js';
|
|
2
|
+
import { type RoutedPublicToolName } from './action-groups.js';
|
|
3
|
+
import type { ActionCatalogEntry } from './types.js';
|
|
4
|
+
export declare const ACTION_CATALOG: Record<ActionName, ActionCatalogEntry>;
|
|
5
|
+
export declare function getActionCatalogEntry(action: ActionName): ActionCatalogEntry;
|
|
6
|
+
export declare function getActionsForTool(tool: RoutedPublicToolName): ActionName[];
|