@dreamcash-org/mcp 0.1.2 → 0.3.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/README.md +28 -27
- package/dist/dreamcash-mcp.js +85 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
Let your own AI agent work with your [Dreamcash](https://dreamcash.xyz)
|
|
4
4
|
account. Dreamcash is a trading app on Hyperliquid; this MCP server lets an
|
|
5
5
|
agent such as Claude Code, Grok Bot, Hermes, OpenClaw or Cursor read your
|
|
6
|
-
account and markets, and trade: **each trade
|
|
7
|
-
|
|
6
|
+
account and markets, and trade: **each trade approved by you in the Dreamcash
|
|
7
|
+
app, or, if you let it, on its own within limits you set.**
|
|
8
8
|
|
|
9
9
|
> Using a chat app that connects to remote MCP servers (Claude, ChatGPT,
|
|
10
10
|
> Grok, Gemini)? You don't need this package: add
|
|
11
|
-
> `https://api.dreamcash.xyz/mcp` as a custom connector instead
|
|
12
|
-
>
|
|
11
|
+
> `https://api.dreamcash.xyz/mcp` as a custom connector instead, and enter
|
|
12
|
+
> the code from the Dreamcash app (Settings › Connected AI) when it asks. Each
|
|
13
|
+
> trade then waits for you; trading on its own needs this package.
|
|
13
14
|
|
|
14
15
|
## What your agent can do
|
|
15
16
|
|
|
@@ -20,10 +21,10 @@ wallet, or, if you let it, on its own within limits you set.**
|
|
|
20
21
|
orders, cancel or change orders, take profit and stop loss, leverage and
|
|
21
22
|
margin, spot and prediction orders, vault deposits and withdrawals, moving
|
|
22
23
|
USDC between spot and perps, and withdrawing to one of your own wallets.
|
|
23
|
-
Each request
|
|
24
|
-
|
|
25
|
-
minutes. Trades pay the same fees as in the app.
|
|
26
|
-
- **Trade on its own**, if you
|
|
24
|
+
Each request sends a push to the Dreamcash app, where you review exactly
|
|
25
|
+
what will be signed and approve or refuse it. Requests you don't answer
|
|
26
|
+
expire after 15 minutes. Trades pay the same fees as in the app.
|
|
27
|
+
- **Trade on its own**, if you turn it on in the app: your main wallet
|
|
27
28
|
approves the agent's key on Hyperliquid once, for the days you pick (up to
|
|
28
29
|
180), and its orders, position changes and HLP moves on your main wallet go
|
|
29
30
|
through without asking you, within your limits per order, on leverage and
|
|
@@ -86,21 +87,19 @@ isn't found, use its full path, which `which npx` prints in your terminal
|
|
|
86
87
|
|
|
87
88
|
## Connect your account
|
|
88
89
|
|
|
89
|
-
1.
|
|
90
|
-
code, valid for 10 minutes.
|
|
91
|
-
2.
|
|
92
|
-
|
|
93
|
-
3.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
many days its key lasts. Then approve; for trading on its own, your wallet
|
|
97
|
-
then signs the key's approval on the next page.
|
|
90
|
+
1. In the Dreamcash app, open **Settings › Connected AI**. It shows a
|
|
91
|
+
6-character code, valid for 10 minutes.
|
|
92
|
+
2. Tell your agent to connect to Dreamcash with that code. It's connected
|
|
93
|
+
at once, and the app lists it under Connected AI.
|
|
94
|
+
3. To let it trade on its own, open it in Connected AI, pick its limits (by
|
|
95
|
+
default $1,000 per order, 10x leverage, $5,000 a day) and how many days its
|
|
96
|
+
key lasts, and approve its key with your main wallet.
|
|
98
97
|
|
|
99
98
|
## Safety
|
|
100
99
|
|
|
101
|
-
- **Dreamcash holds no key that can trade for you.** Everything you
|
|
102
|
-
signed in
|
|
103
|
-
|
|
100
|
+
- **Dreamcash holds no key that can trade for you.** Everything you approve is
|
|
101
|
+
signed in the Dreamcash app, which shows exactly what you sign. Read it
|
|
102
|
+
before you approve: an agent can be wrong, or be misled by what it reads.
|
|
104
103
|
- **The agent's key stays on its machine.** The first time it connects, this
|
|
105
104
|
server makes a key and saves it in `~/.dreamcash/agent-key.json`, readable
|
|
106
105
|
only by your user. Dreamcash never sees it. Every call the agent makes is
|
|
@@ -115,15 +114,16 @@ isn't found, use its full path, which `which npx` prints in your terminal
|
|
|
115
114
|
short key life. Before it signs a trade, this server checks that it is the
|
|
116
115
|
one the agent asked for, on your main wallet, at prices within 10% of
|
|
117
116
|
Hyperliquid's live price.
|
|
118
|
-
- **
|
|
119
|
-
|
|
117
|
+
- **Give your code only to your own agent.** Anyone who has it in its 10
|
|
118
|
+
minutes can connect their agent to your account; the app tells you each
|
|
119
|
+
time an AI connects.
|
|
120
120
|
- **What the agent sees**: the balances, positions and history of every
|
|
121
121
|
wallet in your Dreamcash account.
|
|
122
|
-
- **To disconnect**
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
`agent-key.json.pending`; the key before it keeps working until
|
|
126
|
-
|
|
122
|
+
- **To disconnect** it, swipe it away in Connected AI: the app also revokes
|
|
123
|
+
its key on Hyperliquid when it trades on its own. Deleting the key file
|
|
124
|
+
disconnects this machine too. Pairing again makes a new key in
|
|
125
|
+
`agent-key.json.pending`; the key before it keeps working until the new one
|
|
126
|
+
pairs.
|
|
127
127
|
|
|
128
128
|
## Troubleshooting
|
|
129
129
|
|
|
@@ -133,6 +133,7 @@ isn't found, use its full path, which `which npx` prints in your terminal
|
|
|
133
133
|
| `npx` not found | Use its full path (`which npx` prints it), as above. |
|
|
134
134
|
| `key_not_saved`, `key_unreadable` | Make the key file readable and writable by the user the agent runs as, or set `DREAMCASH_AGENT_KEY_FILE` to a file that is, then restart the agent. An app that runs servers in a sandbox (e.g. Gemini for Mac) may allow writes only to some folders: put the key file in one of them. Deleting a paired key file disconnects this machine. |
|
|
135
135
|
| No Dreamcash tools after connecting | Restart the agent or reload its MCP servers: some clients don't notice new tools by themselves. |
|
|
136
|
+
| `code_invalid` | The code expired or was used: read the one the app shows now (Settings › Connected AI) and give it to the agent. |
|
|
136
137
|
| `update_required` | Run the server as `npx -y @dreamcash-org/mcp@latest` once (npx may keep using a version it already downloaded), then restart the agent. |
|
|
137
138
|
|
|
138
139
|
## Settings
|
package/dist/dreamcash-mcp.js
CHANGED
|
@@ -21370,6 +21370,7 @@ var CALIBUR_EIP712_DOMAIN = {
|
|
|
21370
21370
|
salt: `0x${CALIBUR_ADDRESS.slice(2).padStart(64, "0")}`
|
|
21371
21371
|
};
|
|
21372
21372
|
// ../constants/src/hyperliquid/aiAgent.ts
|
|
21373
|
+
var AI_REPLY_STYLE = "How to reply: lead with the answer in a line or two, in the user's own words, and add detail only when asked. No tables or extra sections for a simple question. Never show tool or field names, and skip exchange mechanics the user didn't ask about. Say once in a chat, not in each reply, that what you suggest is your own analysis, not advice from Dreamcash. A liquidation price over 90% away means the position practically can't be liquidated: say that, not the number.";
|
|
21373
21374
|
var AI_CLIENT_NAME_MAX_LENGTH = 60;
|
|
21374
21375
|
var TRADE_REQUEST_TTL_MS = 15 * 60 * 1000;
|
|
21375
21376
|
var AI_AGENT_SIGNATURE_HEADER = "x-dreamcash-agent-signature";
|
|
@@ -21456,7 +21457,7 @@ import { createHash } from "node:crypto";
|
|
|
21456
21457
|
// package.json
|
|
21457
21458
|
var package_default = {
|
|
21458
21459
|
name: "@dreamcash-org/mcp",
|
|
21459
|
-
version: "0.
|
|
21460
|
+
version: "0.3.0",
|
|
21460
21461
|
description: "Connect your own AI agent to your Dreamcash account: it reads your account and trades, each trade confirmed by you or on its own within your limits.",
|
|
21461
21462
|
license: "MIT",
|
|
21462
21463
|
keywords: [
|
|
@@ -21577,16 +21578,15 @@ var agentApi = (baseUrl, account) => {
|
|
|
21577
21578
|
return answer;
|
|
21578
21579
|
};
|
|
21579
21580
|
const tradeRequest = (id, action = "") => `/api/ai-connections/agent/trade-requests/${encodeURIComponent(id)}${action}`;
|
|
21580
|
-
const link = (code = "") => `/api/ai-agent/links${code ? `/${encodeURIComponent(code)}` : ""}`;
|
|
21581
21581
|
return {
|
|
21582
21582
|
get: (id) => call("GET", tradeRequest(id)),
|
|
21583
21583
|
claim: (id) => call("POST", tradeRequest(id, "/claim"), {}),
|
|
21584
21584
|
sent: (id) => call("POST", tradeRequest(id, "/sent"), {}),
|
|
21585
21585
|
notSent: (id, reason) => call("POST", tradeRequest(id, "/not-sent"), { reason: reason.slice(0, 200) }),
|
|
21586
|
-
|
|
21586
|
+
pair: (code, clientName) => call("POST", "/api/ai-agent/links/pair", {
|
|
21587
|
+
code,
|
|
21587
21588
|
clientName: clientName.slice(0, AI_CLIENT_NAME_MAX_LENGTH)
|
|
21588
|
-
})
|
|
21589
|
-
pairingStatus: (code) => call("GET", link(code))
|
|
21589
|
+
})
|
|
21590
21590
|
};
|
|
21591
21591
|
};
|
|
21592
21592
|
|
|
@@ -26168,7 +26168,6 @@ var newAgentAccount = async (file = defaultKeyFile()) => {
|
|
|
26168
26168
|
return account;
|
|
26169
26169
|
};
|
|
26170
26170
|
var adoptPendingKey = (file) => rename(pendingKeyFile(file), file);
|
|
26171
|
-
var dropPendingKey = (file) => rm(pendingKeyFile(file), { force: true });
|
|
26172
26171
|
// ../hyperliquid-orders/src/trade.ts
|
|
26173
26172
|
var OUTCOME_PRICE_DECIMALS = 5;
|
|
26174
26173
|
// ../hyperliquid-orders/src/plan.ts
|
|
@@ -48598,7 +48597,8 @@ var SERVER_FILLED = new Set([
|
|
|
48598
48597
|
"orderType",
|
|
48599
48598
|
"reduceOnly",
|
|
48600
48599
|
"slippagePct",
|
|
48601
|
-
"percent"
|
|
48600
|
+
"percent",
|
|
48601
|
+
"marginMode"
|
|
48602
48602
|
]);
|
|
48603
48603
|
var checkAgentRequest = async ({
|
|
48604
48604
|
claimed,
|
|
@@ -48705,30 +48705,38 @@ var executeTradeRequest = async ({
|
|
|
48705
48705
|
};
|
|
48706
48706
|
|
|
48707
48707
|
// src/dreamcashServer.ts
|
|
48708
|
-
var
|
|
48709
|
-
|
|
48710
|
-
|
|
48708
|
+
var INSTRUCTIONS = `Dreamcash is a Hyperliquid trading app. This server connects you to the user's Dreamcash account. Until you're connected, connect_dreamcash is your only tool: ask the user for the 6-character code their Dreamcash app shows (Settings › Connected AI) and call it with that code. You then get tools to read their account (balances, positions, orders, history, PnL, XP, vaults) and Hyperliquid markets, and to ask for trades, which the user approves in their Dreamcash app, or, if they let you, to trade on your own with your own key, kept on this machine (Dreamcash never sees it). Once connected, call how_to_use_dreamcash first: it explains every tool, what you may do and how to behave.
|
|
48709
|
+
|
|
48710
|
+
Anything that fails answers {"error": {code, what_happened, what_to_do, tell_the_user, can_retry}}: do what_to_do, and pass tell_the_user on to the user. Amounts are USD unless stated.
|
|
48711
48711
|
|
|
48712
|
-
|
|
48712
|
+
${AI_REPLY_STYLE}`;
|
|
48713
48713
|
var CONNECT_TOOL = {
|
|
48714
48714
|
name: "connect_dreamcash",
|
|
48715
48715
|
title: "Connect to Dreamcash",
|
|
48716
|
-
description: "Connects you to the user's Dreamcash account
|
|
48716
|
+
description: "Connects you to the user's Dreamcash account with the 6-character code their Dreamcash app shows under Settings › Connected AI. Without a code it answers whether you're connected, and if not, what to ask the user. again: true pairs a new key, e.g. after the user disconnected you, which revoked your key at once (on Hyperliquid and at Dreamcash). If a new pairing fails, the package keeps the key it had, which works only while that connection is still on.",
|
|
48717
48717
|
inputSchema: {
|
|
48718
48718
|
type: "object",
|
|
48719
48719
|
properties: {
|
|
48720
|
+
code: {
|
|
48721
|
+
type: "string",
|
|
48722
|
+
description: 'The code the user read off their Dreamcash app, e.g. "K7QM2P".'
|
|
48723
|
+
},
|
|
48720
48724
|
again: {
|
|
48721
48725
|
type: "boolean",
|
|
48722
|
-
description: "Pair
|
|
48726
|
+
description: "Pair a new key."
|
|
48723
48727
|
},
|
|
48724
48728
|
agent_name: {
|
|
48725
48729
|
type: "string",
|
|
48726
|
-
description: 'How the user sees you
|
|
48730
|
+
description: 'How the user sees you in their app, e.g. "Grok Bot".'
|
|
48727
48731
|
}
|
|
48728
48732
|
}
|
|
48729
48733
|
},
|
|
48730
48734
|
annotations: { readOnlyHint: false, openWorldHint: true }
|
|
48731
48735
|
};
|
|
48736
|
+
var ASK_FOR_THE_CODE = {
|
|
48737
|
+
connected: false,
|
|
48738
|
+
next_step: `Ask the user for the code: in the Dreamcash app, Settings › Connected AI shows a 6-character code. Then call connect_dreamcash with it. No Dreamcash account yet? They get the app first (iPhone: ${DREAMCASH_APP_STORE_URL}, Android: ${DREAMCASH_PLAY_STORE_URL}) and make one there.`
|
|
48739
|
+
};
|
|
48732
48740
|
var text = (value, isError = false) => ({
|
|
48733
48741
|
content: [{ type: "text", text: JSON.stringify(value) }],
|
|
48734
48742
|
...isError && { isError: true }
|
|
@@ -48745,19 +48753,19 @@ class KeyNotSaved extends Error {
|
|
|
48745
48753
|
var NOT_CONNECTED = {
|
|
48746
48754
|
code: "not_connected",
|
|
48747
48755
|
what_happened: "This agent isn't connected to a Dreamcash account.",
|
|
48748
|
-
what_to_do: "
|
|
48756
|
+
what_to_do: "Ask the user for the code their Dreamcash app shows under Settings › Connected AI, then call connect_dreamcash with it.",
|
|
48749
48757
|
can_retry: "after_user_action"
|
|
48750
48758
|
};
|
|
48751
48759
|
var DISCONNECTED = {
|
|
48752
48760
|
code: "disconnected",
|
|
48753
48761
|
what_happened: "Dreamcash no longer accepts this agent: the user disconnected it, or it was never approved.",
|
|
48754
|
-
what_to_do: "If the user wants to connect again, call connect_dreamcash
|
|
48762
|
+
what_to_do: "If the user wants to connect again, ask them for a new code from their Dreamcash app (Settings › Connected AI) and call connect_dreamcash with it and again: true.",
|
|
48755
48763
|
can_retry: "after_user_action"
|
|
48756
48764
|
};
|
|
48757
48765
|
var USER_APPROVES_KEY = {
|
|
48758
48766
|
code: "user_approves_key",
|
|
48759
48767
|
what_happened: "This request approves your own key to trade, which only the user can sign. Your key signed nothing.",
|
|
48760
|
-
what_to_do: "
|
|
48768
|
+
what_to_do: "The user approves it in their Dreamcash app, which got a push for it: tell them, then call get_trade_request with request_id.",
|
|
48761
48769
|
can_retry: "after_user_action"
|
|
48762
48770
|
};
|
|
48763
48771
|
var unreachable = (error2) => ({
|
|
@@ -48811,6 +48819,43 @@ var guidanceFor = (error2) => {
|
|
|
48811
48819
|
}
|
|
48812
48820
|
return unreachable(error2);
|
|
48813
48821
|
};
|
|
48822
|
+
var withExecution = (content, executed) => content.map((block) => {
|
|
48823
|
+
if (block.type !== "text")
|
|
48824
|
+
return block;
|
|
48825
|
+
try {
|
|
48826
|
+
const answer = JSON.parse(block.text);
|
|
48827
|
+
if (answer.execute_with_agent_key !== true)
|
|
48828
|
+
return block;
|
|
48829
|
+
const { execute_with_agent_key: _carriedOut, ...asked } = answer;
|
|
48830
|
+
return {
|
|
48831
|
+
...block,
|
|
48832
|
+
text: JSON.stringify({
|
|
48833
|
+
...asked,
|
|
48834
|
+
status: "status" in executed && typeof executed.status === "string" ? executed.status : asked.status,
|
|
48835
|
+
executed_with_your_key: executed
|
|
48836
|
+
})
|
|
48837
|
+
};
|
|
48838
|
+
} catch {
|
|
48839
|
+
return block;
|
|
48840
|
+
}
|
|
48841
|
+
});
|
|
48842
|
+
var fillTotalsOf = (content) => {
|
|
48843
|
+
const text2 = content.find((block) => block.type === "text");
|
|
48844
|
+
if (!text2 || text2.type !== "text")
|
|
48845
|
+
return;
|
|
48846
|
+
try {
|
|
48847
|
+
const { result } = JSON.parse(text2.text);
|
|
48848
|
+
if (typeof result?.fees_usd !== "number")
|
|
48849
|
+
return;
|
|
48850
|
+
return {
|
|
48851
|
+
realized_pnl_usd: result.realized_pnl_usd,
|
|
48852
|
+
fees_usd: result.fees_usd,
|
|
48853
|
+
dreamcash_part_of_fees_usd: result.dreamcash_part_of_fees_usd
|
|
48854
|
+
};
|
|
48855
|
+
} catch {
|
|
48856
|
+
return;
|
|
48857
|
+
}
|
|
48858
|
+
};
|
|
48814
48859
|
var tradeRequestToExecute = (tool, args, result) => {
|
|
48815
48860
|
if (result.isError)
|
|
48816
48861
|
return;
|
|
@@ -48853,7 +48898,6 @@ var createDreamcashServer = ({
|
|
|
48853
48898
|
let account;
|
|
48854
48899
|
let pairingKey;
|
|
48855
48900
|
let upstream;
|
|
48856
|
-
let shownCode;
|
|
48857
48901
|
let toolsStale = true;
|
|
48858
48902
|
const connectUpstream = async (key) => {
|
|
48859
48903
|
const client = new Client({
|
|
@@ -48883,8 +48927,7 @@ var createDreamcashServer = ({
|
|
|
48883
48927
|
upstream = await upstreamFor(account);
|
|
48884
48928
|
return upstream;
|
|
48885
48929
|
};
|
|
48886
|
-
const connected = async (client
|
|
48887
|
-
shownCode = undefined;
|
|
48930
|
+
const connected = async (client) => {
|
|
48888
48931
|
if (toolsStale) {
|
|
48889
48932
|
await server.notification({ method: "notifications/tools/list_changed" });
|
|
48890
48933
|
}
|
|
@@ -48894,21 +48937,17 @@ var createDreamcashServer = ({
|
|
|
48894
48937
|
key_address: account?.address,
|
|
48895
48938
|
tools: tools.map((tool) => tool.name),
|
|
48896
48939
|
how_to_use: client.getInstructions(),
|
|
48897
|
-
next_step: "Call how_to_use_dreamcash: it explains every tool, what you may do and how to behave."
|
|
48898
|
-
...tradeRequestId && {
|
|
48899
|
-
note: "The user is approving your key to trade on its own; until they sign, each trade waits for them at a link."
|
|
48900
|
-
}
|
|
48940
|
+
next_step: "Call how_to_use_dreamcash: it explains every tool, what you may do and how to behave."
|
|
48901
48941
|
});
|
|
48902
48942
|
};
|
|
48903
48943
|
const freshAccount = async (file) => {
|
|
48904
|
-
shownCode = undefined;
|
|
48905
48944
|
try {
|
|
48906
48945
|
return await newAgentAccount(file);
|
|
48907
48946
|
} catch (error2) {
|
|
48908
48947
|
throw new KeyNotSaved(file, error2);
|
|
48909
48948
|
}
|
|
48910
48949
|
};
|
|
48911
|
-
const finishPairing = async (key
|
|
48950
|
+
const finishPairing = async (key) => {
|
|
48912
48951
|
await adoptPendingKey(keyFile).catch((error2) => {
|
|
48913
48952
|
throw new KeyNotSaved(keyFile, error2);
|
|
48914
48953
|
});
|
|
@@ -48920,71 +48959,35 @@ var createDreamcashServer = ({
|
|
|
48920
48959
|
if (!client) {
|
|
48921
48960
|
return failure2({
|
|
48922
48961
|
code: "pairing_not_accepted",
|
|
48923
|
-
what_happened: "The
|
|
48924
|
-
what_to_do: "
|
|
48962
|
+
what_happened: "The code paired, but Dreamcash doesn't accept this agent's key.",
|
|
48963
|
+
what_to_do: "Ask the user for a new code from their Dreamcash app, then call connect_dreamcash with it and again: true.",
|
|
48925
48964
|
can_retry: "after_user_action"
|
|
48926
48965
|
});
|
|
48927
48966
|
}
|
|
48928
|
-
return connected(client
|
|
48967
|
+
return connected(client);
|
|
48929
48968
|
};
|
|
48930
48969
|
const connect = async ({
|
|
48970
|
+
code,
|
|
48931
48971
|
again = false,
|
|
48932
48972
|
agent_name
|
|
48933
48973
|
}) => {
|
|
48934
48974
|
if (again) {
|
|
48935
48975
|
pairingKey = await freshAccount(pendingFile);
|
|
48936
|
-
} else
|
|
48937
|
-
pairingKey
|
|
48976
|
+
} else {
|
|
48977
|
+
pairingKey ??= await storedAgentAccount(pendingFile);
|
|
48938
48978
|
if (pairingKey && await upstreamFor(pairingKey)) {
|
|
48939
48979
|
return finishPairing(pairingKey);
|
|
48940
48980
|
}
|
|
48941
|
-
|
|
48942
|
-
if (!pairingKey) {
|
|
48943
|
-
const client = await linked();
|
|
48981
|
+
const client = pairingKey && code ? undefined : await linked();
|
|
48944
48982
|
if (client)
|
|
48945
48983
|
return connected(client);
|
|
48946
|
-
pairingKey = await freshAccount(pendingFile);
|
|
48947
|
-
}
|
|
48948
|
-
const key = pairingKey;
|
|
48949
|
-
const api2 = agentApi(apiUrl, key);
|
|
48950
|
-
if (shownCode) {
|
|
48951
|
-
const shown = await api2.pairingStatus(shownCode);
|
|
48952
|
-
if (shown.status === "approved") {
|
|
48953
|
-
return finishPairing(key, shown.tradeRequestId);
|
|
48954
|
-
}
|
|
48955
48984
|
}
|
|
48985
|
+
if (!code)
|
|
48986
|
+
return text(ASK_FOR_THE_CODE);
|
|
48987
|
+
pairingKey ??= await freshAccount(pendingFile);
|
|
48956
48988
|
const clientName = agent_name ?? server.getClientVersion()?.name ?? "Your AI";
|
|
48957
|
-
|
|
48958
|
-
|
|
48959
|
-
connected: false,
|
|
48960
|
-
code: pairing.code,
|
|
48961
|
-
pair_url: pairing.pairUrl,
|
|
48962
|
-
expires_at: pairing.expiresAt,
|
|
48963
|
-
key_address: key.address,
|
|
48964
|
-
next_step: `Tell the user: open the Dreamcash app, or get it and make an account (iPhone: ${DREAMCASH_APP_STORE_URL}, Android: ${DREAMCASH_PLAY_STORE_URL}). Then visit ${pairing.pairUrl}, sign in with that same account and enter ${pairing.code}. The page shows the key it pairs, which must be ${key.address}. Then call connect_dreamcash again.`
|
|
48965
|
-
};
|
|
48966
|
-
if (pairing.code !== shownCode) {
|
|
48967
|
-
shownCode = pairing.code;
|
|
48968
|
-
return text(pairingStep);
|
|
48969
|
-
}
|
|
48970
|
-
const deadline = Date.now() + PAIRING_WAIT_MS;
|
|
48971
|
-
let status = await api2.pairingStatus(pairing.code);
|
|
48972
|
-
while (status.status === "pending" && Date.now() < deadline) {
|
|
48973
|
-
await sleep3(PAIRING_POLL_MS);
|
|
48974
|
-
status = await api2.pairingStatus(pairing.code);
|
|
48975
|
-
}
|
|
48976
|
-
if (status.status === "pending")
|
|
48977
|
-
return text(pairingStep);
|
|
48978
|
-
if (status.status !== "approved") {
|
|
48979
|
-
pairingKey = undefined;
|
|
48980
|
-
await dropPendingKey(keyFile);
|
|
48981
|
-
return text({
|
|
48982
|
-
connected: false,
|
|
48983
|
-
status: status.status,
|
|
48984
|
-
next_step: "The new key wasn't paired. Call connect_dreamcash again if the user wants to connect."
|
|
48985
|
-
});
|
|
48986
|
-
}
|
|
48987
|
-
return finishPairing(key, status.tradeRequestId);
|
|
48989
|
+
await agentApi(apiUrl, pairingKey).pair(code, clientName);
|
|
48990
|
+
return finishPairing(pairingKey);
|
|
48988
48991
|
};
|
|
48989
48992
|
const executeWithKey = async (id, asked, key) => {
|
|
48990
48993
|
const { info, exchangeSignedBy } = createTradeRequestClients();
|
|
@@ -49037,17 +49040,16 @@ var createDreamcashServer = ({
|
|
|
49037
49040
|
const toExecute = tradeRequestToExecute(name, args, result);
|
|
49038
49041
|
if (!toExecute)
|
|
49039
49042
|
return result;
|
|
49043
|
+
const executed = await executeWithKey(toExecute.id, toExecute.asked, account);
|
|
49044
|
+
const totals = "status" in executed && executed.status === "executed" ? await client.callTool({
|
|
49045
|
+
name: "get_trade_request",
|
|
49046
|
+
arguments: { request_id: toExecute.id }
|
|
49047
|
+
}).then((readBack) => fillTotalsOf(readBack.content)).catch(() => {
|
|
49048
|
+
return;
|
|
49049
|
+
}) : undefined;
|
|
49040
49050
|
return {
|
|
49041
49051
|
...result,
|
|
49042
|
-
content:
|
|
49043
|
-
...result.content,
|
|
49044
|
-
{
|
|
49045
|
-
type: "text",
|
|
49046
|
-
text: JSON.stringify({
|
|
49047
|
-
executed_with_your_key: await executeWithKey(toExecute.id, toExecute.asked, account)
|
|
49048
|
-
})
|
|
49049
|
-
}
|
|
49050
|
-
]
|
|
49052
|
+
content: withExecution(result.content, { ...executed, ...totals })
|
|
49051
49053
|
};
|
|
49052
49054
|
} catch (error2) {
|
|
49053
49055
|
if (isUnauthorized(error2))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dreamcash-org/mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Connect your own AI agent to your Dreamcash account: it reads your account and trades, each trade confirmed by you or on its own within your limits.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|