@dreamcash-org/mcp 0.1.2 → 0.2.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 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 confirmed by you in your own
7
- wallet, or, if you let it, on its own within limits you set.**
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. Each trade
12
- > then waits for you; trading on its own needs this package.
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 gives you a link to review exactly what will be signed, and
24
- confirm it in your wallet. Requests you don't confirm expire after 15
25
- minutes. Trades pay the same fees as in the app.
26
- - **Trade on its own**, if you choose it when you connect: your main wallet
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. Ask your agent to connect to Dreamcash. It gives you a link and a short
90
- code, valid for 10 minutes.
91
- 2. Open the link, sign in with the account you use in the Dreamcash app and
92
- enter the code.
93
- 3. Check that the key address the page shows is the one your agent told you.
94
- 4. Choose **ask me before each trade**, or **trade on its own** with its
95
- limits (by default $1,000 per order, 10x leverage, $5,000 a day) and how
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 confirm is
102
- signed in your own wallet, on a page that shows exactly what you sign. Read
103
- it before you confirm: an agent can be wrong, or be misled by what it reads.
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
- - **Enter only codes your agent showed you just now.** Never one someone sent
119
- you: entering it would connect their agent to your account.
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** this machine, delete the key file. A key you let trade
123
- stays approved on Hyperliquid until it expires, or until you approve another
124
- AI key, which replaces it. Pairing again makes a new key in
125
- `agent-key.json.pending`; the key before it keeps working until you approve
126
- the new one.
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
@@ -707,7 +707,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
707
707
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
708
708
  THE SOFTWARE.
709
709
 
710
- ## @noble/hashes 2.3.0 (MIT)
710
+ ## @noble/hashes 1.8.0 (MIT)
711
711
 
712
712
  The MIT License (MIT)
713
713
 
@@ -731,7 +731,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
731
731
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
732
732
  THE SOFTWARE.
733
733
 
734
- ## @noble/hashes 1.8.0 (MIT)
734
+ ## @noble/hashes 2.3.0 (MIT)
735
735
 
736
736
  The MIT License (MIT)
737
737
 
@@ -21456,7 +21456,7 @@ import { createHash } from "node:crypto";
21456
21456
  // package.json
21457
21457
  var package_default = {
21458
21458
  name: "@dreamcash-org/mcp",
21459
- version: "0.1.2",
21459
+ version: "0.2.0",
21460
21460
  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
21461
  license: "MIT",
21462
21462
  keywords: [
@@ -21577,16 +21577,15 @@ var agentApi = (baseUrl, account) => {
21577
21577
  return answer;
21578
21578
  };
21579
21579
  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
21580
  return {
21582
21581
  get: (id) => call("GET", tradeRequest(id)),
21583
21582
  claim: (id) => call("POST", tradeRequest(id, "/claim"), {}),
21584
21583
  sent: (id) => call("POST", tradeRequest(id, "/sent"), {}),
21585
21584
  notSent: (id, reason) => call("POST", tradeRequest(id, "/not-sent"), { reason: reason.slice(0, 200) }),
21586
- createPairing: (clientName) => call("POST", link(), {
21585
+ pair: (code, clientName) => call("POST", "/api/ai-agent/links/pair", {
21586
+ code,
21587
21587
  clientName: clientName.slice(0, AI_CLIENT_NAME_MAX_LENGTH)
21588
- }),
21589
- pairingStatus: (code) => call("GET", link(code))
21588
+ })
21590
21589
  };
21591
21590
  };
21592
21591
 
@@ -26168,7 +26167,6 @@ var newAgentAccount = async (file = defaultKeyFile()) => {
26168
26167
  return account;
26169
26168
  };
26170
26169
  var adoptPendingKey = (file) => rename(pendingKeyFile(file), file);
26171
- var dropPendingKey = (file) => rm(pendingKeyFile(file), { force: true });
26172
26170
  // ../hyperliquid-orders/src/trade.ts
26173
26171
  var OUTCOME_PRICE_DECIMALS = 5;
26174
26172
  // ../hyperliquid-orders/src/plan.ts
@@ -48705,30 +48703,36 @@ var executeTradeRequest = async ({
48705
48703
  };
48706
48704
 
48707
48705
  // src/dreamcashServer.ts
48708
- var PAIRING_WAIT_MS = 25000;
48709
- var PAIRING_POLL_MS = 2000;
48710
- 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: call it and write the code and link it gives you out in full in your reply (the user may not see tool results), then call it again until it says connected. You then get tools to read their account (balances, positions, orders, history, PnL, XP, vaults) and Hyperliquid markets, and to ask for trades, or, if the user lets 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.
48706
+ 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.
48711
48707
 
48712
48708
  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. What you suggest is your own analysis, not advice from Dreamcash.`;
48713
48709
  var CONNECT_TOOL = {
48714
48710
  name: "connect_dreamcash",
48715
48711
  title: "Connect to Dreamcash",
48716
- description: "Connects you to the user's Dreamcash account. The first call answers a code: write pair_url and the code out in full in your reply, and ask the user to open the link and enter the code. Then call this again: it waits up to 25 s for them and answers connected. again: true starts over with a new key, e.g. to change what you may do; the key before it keeps working until the user approves the new one.",
48712
+ 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; the key before it keeps working until the new one pairs.",
48717
48713
  inputSchema: {
48718
48714
  type: "object",
48719
48715
  properties: {
48716
+ code: {
48717
+ type: "string",
48718
+ description: 'The code the user read off their Dreamcash app, e.g. "K7QM2P".'
48719
+ },
48720
48720
  again: {
48721
48721
  type: "boolean",
48722
- description: "Pair again with a new key."
48722
+ description: "Pair a new key."
48723
48723
  },
48724
48724
  agent_name: {
48725
48725
  type: "string",
48726
- description: 'How the user sees you on the pairing page, e.g. "Grok Bot".'
48726
+ description: 'How the user sees you in their app, e.g. "Grok Bot".'
48727
48727
  }
48728
48728
  }
48729
48729
  },
48730
48730
  annotations: { readOnlyHint: false, openWorldHint: true }
48731
48731
  };
48732
+ var ASK_FOR_THE_CODE = {
48733
+ connected: false,
48734
+ 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.`
48735
+ };
48732
48736
  var text = (value, isError = false) => ({
48733
48737
  content: [{ type: "text", text: JSON.stringify(value) }],
48734
48738
  ...isError && { isError: true }
@@ -48745,19 +48749,19 @@ class KeyNotSaved extends Error {
48745
48749
  var NOT_CONNECTED = {
48746
48750
  code: "not_connected",
48747
48751
  what_happened: "This agent isn't connected to a Dreamcash account.",
48748
- what_to_do: "Call connect_dreamcash and give the user the code it answers.",
48752
+ what_to_do: "Ask the user for the code their Dreamcash app shows under Settings › Connected AI, then call connect_dreamcash with it.",
48749
48753
  can_retry: "after_user_action"
48750
48754
  };
48751
48755
  var DISCONNECTED = {
48752
48756
  code: "disconnected",
48753
48757
  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 and give them the new code.",
48758
+ 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
48759
  can_retry: "after_user_action"
48756
48760
  };
48757
48761
  var USER_APPROVES_KEY = {
48758
48762
  code: "user_approves_key",
48759
48763
  what_happened: "This request approves your own key to trade, which only the user can sign. Your key signed nothing.",
48760
- what_to_do: "Write confirm_url out in full in your reply, ask the user to open it and approve it, then call get_trade_request with request_id.",
48764
+ 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
48765
  can_retry: "after_user_action"
48762
48766
  };
48763
48767
  var unreachable = (error2) => ({
@@ -48853,7 +48857,6 @@ var createDreamcashServer = ({
48853
48857
  let account;
48854
48858
  let pairingKey;
48855
48859
  let upstream;
48856
- let shownCode;
48857
48860
  let toolsStale = true;
48858
48861
  const connectUpstream = async (key) => {
48859
48862
  const client = new Client({
@@ -48883,8 +48886,7 @@ var createDreamcashServer = ({
48883
48886
  upstream = await upstreamFor(account);
48884
48887
  return upstream;
48885
48888
  };
48886
- const connected = async (client, tradeRequestId) => {
48887
- shownCode = undefined;
48889
+ const connected = async (client) => {
48888
48890
  if (toolsStale) {
48889
48891
  await server.notification({ method: "notifications/tools/list_changed" });
48890
48892
  }
@@ -48894,21 +48896,17 @@ var createDreamcashServer = ({
48894
48896
  key_address: account?.address,
48895
48897
  tools: tools.map((tool) => tool.name),
48896
48898
  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
- }
48899
+ next_step: "Call how_to_use_dreamcash: it explains every tool, what you may do and how to behave."
48901
48900
  });
48902
48901
  };
48903
48902
  const freshAccount = async (file) => {
48904
- shownCode = undefined;
48905
48903
  try {
48906
48904
  return await newAgentAccount(file);
48907
48905
  } catch (error2) {
48908
48906
  throw new KeyNotSaved(file, error2);
48909
48907
  }
48910
48908
  };
48911
- const finishPairing = async (key, tradeRequestId) => {
48909
+ const finishPairing = async (key) => {
48912
48910
  await adoptPendingKey(keyFile).catch((error2) => {
48913
48911
  throw new KeyNotSaved(keyFile, error2);
48914
48912
  });
@@ -48920,71 +48918,35 @@ var createDreamcashServer = ({
48920
48918
  if (!client) {
48921
48919
  return failure2({
48922
48920
  code: "pairing_not_accepted",
48923
- what_happened: "The user approved the code, but Dreamcash doesn't accept this agent's key.",
48924
- what_to_do: "Call connect_dreamcash with again: true and give the user the new code.",
48921
+ what_happened: "The code paired, but Dreamcash doesn't accept this agent's key.",
48922
+ what_to_do: "Ask the user for a new code from their Dreamcash app, then call connect_dreamcash with it and again: true.",
48925
48923
  can_retry: "after_user_action"
48926
48924
  });
48927
48925
  }
48928
- return connected(client, tradeRequestId);
48926
+ return connected(client);
48929
48927
  };
48930
48928
  const connect = async ({
48929
+ code,
48931
48930
  again = false,
48932
48931
  agent_name
48933
48932
  }) => {
48934
48933
  if (again) {
48935
48934
  pairingKey = await freshAccount(pendingFile);
48936
- } else if (!pairingKey) {
48937
- pairingKey = await storedAgentAccount(pendingFile);
48935
+ } else {
48936
+ pairingKey ??= await storedAgentAccount(pendingFile);
48938
48937
  if (pairingKey && await upstreamFor(pairingKey)) {
48939
48938
  return finishPairing(pairingKey);
48940
48939
  }
48941
- }
48942
- if (!pairingKey) {
48943
- const client = await linked();
48940
+ const client = pairingKey && code ? undefined : await linked();
48944
48941
  if (client)
48945
48942
  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
48943
  }
48944
+ if (!code)
48945
+ return text(ASK_FOR_THE_CODE);
48946
+ pairingKey ??= await freshAccount(pendingFile);
48956
48947
  const clientName = agent_name ?? server.getClientVersion()?.name ?? "Your AI";
48957
- const pairing = await api2.createPairing(clientName);
48958
- const pairingStep = {
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);
48948
+ await agentApi(apiUrl, pairingKey).pair(code, clientName);
48949
+ return finishPairing(pairingKey);
48988
48950
  };
48989
48951
  const executeWithKey = async (id, asked, key) => {
48990
48952
  const { info, exchangeSignedBy } = createTradeRequestClients();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamcash-org/mcp",
3
- "version": "0.1.2",
3
+ "version": "0.2.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": [