flash-trade-mcp 0.2.1 → 0.2.2
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/dist/index.js +49 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -49229,6 +49229,25 @@ function registerHealthTools(server, client) {
|
|
|
49229
49229
|
}
|
|
49230
49230
|
|
|
49231
49231
|
// src/tools/markets.ts
|
|
49232
|
+
var VIRTUAL_CUSTODY_MAP = {
|
|
49233
|
+
"6bthDsp8pcGBGKVKCKZjV5JfuSUNRo62RG4hQHj1u4CK": { symbol: "BNB", pool: "Crypto.1", maxLeverage: "60.00" },
|
|
49234
|
+
A8SKWb3pwbFUtxLQhnpUTfy7CkxBpWGvTLYyJyWHCMWv: { symbol: "PYTH", pool: "Governance.1", maxLeverage: "60.00" },
|
|
49235
|
+
"5JtPiHFmkb1nv1Qvs3sryLgXmjs8p5iQexAseC2Ljjzg": { symbol: "KMNO", pool: "Governance.1", maxLeverage: "60.00" },
|
|
49236
|
+
"9GeU2eX2B8nLCJr7FKhXeR73fM2ULBwUXZqHov9iipxz": { symbol: "MET", pool: "Governance.1", maxLeverage: "15.00" },
|
|
49237
|
+
"7WWSRZSgFmp7UDfD1KHWYJ2CqXVbpCdQ5cQfgBxjpFeL": { symbol: "EUR", pool: "Virtual.1", maxLeverage: "550.00" },
|
|
49238
|
+
Ah1Kd146CtAexGvbVNWRMQ8aXJTJDf4AopNLQZKGfYck: { symbol: "GBP", pool: "Virtual.1", maxLeverage: "550.00" },
|
|
49239
|
+
ERiMNq88WEByvDUKsPsvkJRnvsDrPPhbWedn59cDfvXY: { symbol: "USDJPY", pool: "Virtual.1", maxLeverage: "550.00" },
|
|
49240
|
+
"2zB3Uv3SoFGe17UiGjPGrwBRA7edH3YRwtHWQES7KkqP": { symbol: "USDCNH", pool: "Virtual.1", maxLeverage: "550.00" },
|
|
49241
|
+
"3j1xiP6GckKCzsTm6sni5iy6zrpZX5BWZGbKCq5buk4d": { symbol: "XAU", pool: "Virtual.1", maxLeverage: "120.00" },
|
|
49242
|
+
GMqeFJ8LG5BcrRtVgvfQuA7giBETcY76ikC8h5hPh59h: { symbol: "XAG", pool: "Virtual.1", maxLeverage: "130.00" },
|
|
49243
|
+
"5mggznCHoC98t2xXNYPVR8cqNhRhYdhV7qGWqMoY6YSJ": { symbol: "CRUDEOIL", pool: "Virtual.1", maxLeverage: "7.00" },
|
|
49244
|
+
A2C8A9QMEQ1XAWjLSe7zUNRXSjDqQA4cpYzLYGvDZS1u: { symbol: "AMZN", pool: "Equity.1", maxLeverage: "12.00" },
|
|
49245
|
+
CK6ByFWy3fMbymx55SGhWi4yEv4HebdtdbLMwfPTZDwK: { symbol: "AAPL", pool: "Equity.1", maxLeverage: "12.00" },
|
|
49246
|
+
GDudQbq15yQuhvZ2N63qiYdQBiMipooeArcUgcwizd5b: { symbol: "AMD", pool: "Equity.1", maxLeverage: "12.00" },
|
|
49247
|
+
HbwAAHzRwNqrZMD9WzMJBYGnKqUrDLcodD9rvaEkPYXK: { symbol: "NVDA", pool: "Equity.1", maxLeverage: "12.00" },
|
|
49248
|
+
RQNURQjDbq2Yah2udtFTNT7TjR15vsPV3oJNnwYher8: { symbol: "TSLA", pool: "Equity.1", maxLeverage: "12.00" },
|
|
49249
|
+
ArnD1faZVVkkewX4HUSoDuht46egAtVvhDTFMJn3DkFo: { symbol: "SAMO", pool: "Community.3", maxLeverage: "50.00" }
|
|
49250
|
+
};
|
|
49232
49251
|
function buildCustodySymbolMap(poolData) {
|
|
49233
49252
|
const map3 = new Map;
|
|
49234
49253
|
for (const pool of poolData.pools) {
|
|
@@ -49240,6 +49259,11 @@ function buildCustodySymbolMap(poolData) {
|
|
|
49240
49259
|
});
|
|
49241
49260
|
}
|
|
49242
49261
|
}
|
|
49262
|
+
for (const [pubkey, info] of Object.entries(VIRTUAL_CUSTODY_MAP)) {
|
|
49263
|
+
if (!map3.has(pubkey)) {
|
|
49264
|
+
map3.set(pubkey, info);
|
|
49265
|
+
}
|
|
49266
|
+
}
|
|
49243
49267
|
return map3;
|
|
49244
49268
|
}
|
|
49245
49269
|
function formatMarketsSummary(markets, custodyInfo) {
|
|
@@ -56772,9 +56796,13 @@ var $VersionedTransaction = VersionedTransaction;
|
|
|
56772
56796
|
|
|
56773
56797
|
// src/tools/sign-and-send.ts
|
|
56774
56798
|
import fs from "node:fs";
|
|
56799
|
+
function sanitizeError(e) {
|
|
56800
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
56801
|
+
return msg.replace(/\[[\d,\s]{20,}\]/g, "[REDACTED]").replace(/[0-9a-fA-F]{40,}/g, "[REDACTED]").replace(/[123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz]{40,}/g, "[REDACTED]");
|
|
56802
|
+
}
|
|
56775
56803
|
function registerSignAndSendTool(server) {
|
|
56776
56804
|
server.registerTool("sign_and_send", {
|
|
56777
|
-
description: "Sign and submit a base64-encoded unsigned Solana transaction using the locally configured keypair. " + "Call this AFTER a transaction tool (open_position, close_position, add_collateral, remove_collateral, reverse_position) " + "returns a transactionBase64 string AND the user has reviewed and approved the preview. " + "The keypair is read from KEYPAIR_PATH (default: ~/.config/solana/id.json). " + "Returns the confirmed transaction signature and a Solscan link. " + "IMPORTANT: Always show the transaction preview to the user and get their approval BEFORE calling this tool. " + "This tool signs with the local keypair and submits to Solana mainnet — the action is IRREVERSIBLE.",
|
|
56805
|
+
description: "Sign and submit a base64-encoded unsigned Solana transaction using the locally configured keypair. " + "Call this AFTER a transaction tool (open_position, close_position, add_collateral, remove_collateral, reverse_position) " + "returns a transactionBase64 string AND the user has reviewed and approved the preview. " + "The keypair is read from KEYPAIR_PATH (default: ~/.config/solana/id.json). " + "Returns the confirmed transaction signature and a Solscan link. " + "IMPORTANT: Always show the transaction preview to the user and get their approval BEFORE calling this tool. " + "This tool signs with the local keypair and submits to Solana mainnet — the action is IRREVERSIBLE. " + "NOTE: This tool never exposes private key material in its output.",
|
|
56778
56806
|
inputSchema: {
|
|
56779
56807
|
transaction_base64: exports_external.string().describe("The base64-encoded unsigned transaction returned by a transaction tool")
|
|
56780
56808
|
}
|
|
@@ -56783,12 +56811,26 @@ function registerSignAndSendTool(server) {
|
|
|
56783
56811
|
const keypairPath = process.env.KEYPAIR_PATH ?? `${process.env.HOME}/.config/solana/id.json`;
|
|
56784
56812
|
let keypair;
|
|
56785
56813
|
try {
|
|
56786
|
-
const
|
|
56814
|
+
const raw = fs.readFileSync(keypairPath, "utf-8");
|
|
56815
|
+
let keypairData;
|
|
56816
|
+
try {
|
|
56817
|
+
keypairData = JSON.parse(raw);
|
|
56818
|
+
} catch {
|
|
56819
|
+
return {
|
|
56820
|
+
content: [{ type: "text", text: `Keypair file at ${keypairPath} is not valid JSON.` }],
|
|
56821
|
+
isError: true
|
|
56822
|
+
};
|
|
56823
|
+
}
|
|
56824
|
+
if (!Array.isArray(keypairData) || keypairData.length !== 64) {
|
|
56825
|
+
return {
|
|
56826
|
+
content: [{ type: "text", text: `Keypair file at ${keypairPath} does not contain a valid 64-byte Solana keypair.` }],
|
|
56827
|
+
isError: true
|
|
56828
|
+
};
|
|
56829
|
+
}
|
|
56787
56830
|
keypair = $Keypair.fromSecretKey(Uint8Array.from(keypairData));
|
|
56788
56831
|
} catch (e) {
|
|
56789
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
56790
56832
|
return {
|
|
56791
|
-
content: [{ type: "text", text: `Failed to load keypair from ${keypairPath}: ${
|
|
56833
|
+
content: [{ type: "text", text: `Failed to load keypair from ${keypairPath}: ${sanitizeError(e)}` }],
|
|
56792
56834
|
isError: true
|
|
56793
56835
|
};
|
|
56794
56836
|
}
|
|
@@ -56797,9 +56839,8 @@ function registerSignAndSendTool(server) {
|
|
|
56797
56839
|
const txBytes = Buffer.from(params.transaction_base64, "base64");
|
|
56798
56840
|
tx = $VersionedTransaction.deserialize(txBytes);
|
|
56799
56841
|
} catch (e) {
|
|
56800
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
56801
56842
|
return {
|
|
56802
|
-
content: [{ type: "text", text: `Failed to decode transaction: ${
|
|
56843
|
+
content: [{ type: "text", text: `Failed to decode transaction: ${sanitizeError(e)}` }],
|
|
56803
56844
|
isError: true
|
|
56804
56845
|
};
|
|
56805
56846
|
}
|
|
@@ -56826,15 +56867,13 @@ Signature: ${signature2}` }],
|
|
|
56826
56867
|
const lines = [
|
|
56827
56868
|
"=== Transaction Confirmed ===",
|
|
56828
56869
|
`Signature: ${signature2}`,
|
|
56829
|
-
`Wallet: ${keypair.publicKey.toBase58()}`,
|
|
56830
56870
|
`Explorer: https://solscan.io/tx/${signature2}`
|
|
56831
56871
|
];
|
|
56832
56872
|
return { content: [{ type: "text", text: lines.join(`
|
|
56833
56873
|
`) }] };
|
|
56834
56874
|
} catch (e) {
|
|
56835
|
-
const msg = e instanceof Error ? e.message : String(e);
|
|
56836
56875
|
return {
|
|
56837
|
-
content: [{ type: "text", text: `Transaction send failed: ${
|
|
56876
|
+
content: [{ type: "text", text: `Transaction send failed: ${sanitizeError(e)}` }],
|
|
56838
56877
|
isError: true
|
|
56839
56878
|
};
|
|
56840
56879
|
}
|
|
@@ -56933,7 +56972,7 @@ try {
|
|
|
56933
56972
|
const client = new FlashApiClient(config2);
|
|
56934
56973
|
const server = new McpServer({
|
|
56935
56974
|
name: "flash-trade",
|
|
56936
|
-
version: "0.2.
|
|
56975
|
+
version: "0.2.2"
|
|
56937
56976
|
}, {
|
|
56938
56977
|
capabilities: {
|
|
56939
56978
|
tools: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flash-trade-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "MCP server for Flash Trade — perpetual futures DEX on Solana. Provides AI agents with typed tools for trading, position management, and market data.",
|
|
5
5
|
"module": "src/index.ts",
|
|
6
6
|
"main": "dist/index.js",
|