@dimcool/mcp 0.1.10 → 0.1.12

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.
Files changed (2) hide show
  1. package/dist/index.js +217 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -22861,10 +22861,12 @@ var Wallet = class {
22861
22861
  */
22862
22862
  async getBalances() {
22863
22863
  try {
22864
- const response = await this.http.get(
22865
- "/wallets/me/balance"
22866
- );
22867
- return response;
22864
+ const raw = await this.http.get("/wallets/me/balance");
22865
+ const usdcDollars = raw.usdc / 1e6;
22866
+ return {
22867
+ ...raw,
22868
+ usdcFormatted: `$${usdcDollars.toFixed(2)}`
22869
+ };
22868
22870
  } catch (error) {
22869
22871
  this.logger.error("Failed to get balances", {
22870
22872
  error: error instanceof Error ? error.message : String(error)
@@ -25211,24 +25213,35 @@ import { z } from "zod";
25211
25213
  function registerAuthTools(server2, client) {
25212
25214
  server2.tool(
25213
25215
  "dim_login",
25214
- "Authenticate with DIM using the configured wallet. Must be called before using any other tools. Returns user profile info.",
25216
+ "Authenticate with DIM using the configured wallet. After login: set a username with dim_set_username, check balance with dim_get_balance, list games with dim_list_games, or apply a referral code with dim_apply_referral_code for a 10% fee discount.",
25215
25217
  {},
25216
25218
  async () => {
25217
25219
  try {
25218
25220
  const result = await client.authenticate();
25219
- const response = {
25220
- success: true,
25221
- userId: result.userId,
25222
- username: result.username,
25223
- walletAddress: client.walletAddress
25224
- };
25221
+ const nextSteps = [];
25222
+ if (result.username == null || result.username === "") {
25223
+ nextSteps.push(
25224
+ "No username set \u2014 call dim_set_username to claim one"
25225
+ );
25226
+ }
25227
+ nextSteps.push("Check your balance with dim_get_balance");
25228
+ nextSteps.push("Explore available games with dim_list_games");
25225
25229
  try {
25226
25230
  const summary = await client.sdk.referrals.getSummary();
25227
25231
  if (!summary.hasReferrer) {
25228
- response.referralHint = "You have no referrer yet. Use dim_apply_referral_code to apply one and get a 10% fee discount.";
25232
+ nextSteps.push(
25233
+ "No referrer yet \u2014 call dim_apply_referral_code for 10% fee discount"
25234
+ );
25229
25235
  }
25230
25236
  } catch {
25231
25237
  }
25238
+ const response = {
25239
+ success: true,
25240
+ userId: result.userId,
25241
+ username: result.username ?? null,
25242
+ walletAddress: client.walletAddress,
25243
+ nextSteps
25244
+ };
25232
25245
  return {
25233
25246
  content: [
25234
25247
  {
@@ -25616,7 +25629,7 @@ import { z as z4 } from "zod";
25616
25629
  function registerWalletTools(server2, client) {
25617
25630
  server2.tool(
25618
25631
  "dim_get_balance",
25619
- "Get the wallet balance for the authenticated user. Returns SOL and USDC amounts. USDC amounts are in minor units (1 USDC = 1,000,000 minor units).",
25632
+ "Get the wallet balance for the authenticated user. Returns SOL and USDC (usdc in minor units; usdcFormatted is always present, e.g. $0.00 or $1.50, so you do not need to convert).",
25620
25633
  {},
25621
25634
  async () => {
25622
25635
  try {
@@ -25774,7 +25787,7 @@ import { z as z5 } from "zod";
25774
25787
  function registerGamesTools(server2, client) {
25775
25788
  server2.tool(
25776
25789
  "dim_list_games",
25777
- "List all available game types on DIM with player counts and descriptions. Games include: Rock-Paper-Scissors, Chess, Tic-Tac-Toe, Connect Four, Nim, Dots and Boxes.",
25790
+ "List all available game types on DIM with player counts and descriptions. Games include: Rock-Paper-Scissors, Chess, Tic-Tac-Toe, Connect Four.",
25778
25791
  {},
25779
25792
  async () => {
25780
25793
  try {
@@ -25820,18 +25833,19 @@ function registerGamesTools(server2, client) {
25820
25833
  );
25821
25834
  server2.tool(
25822
25835
  "dim_create_lobby",
25823
- "Create a new game lobby. The agent becomes the lobby creator. Other players can join, or you can join the matchmaking queue to find an opponent. Bet amount is in USDC minor units (1 USDC = 1,000,000). A 1% fee (min 1 cent) is charged per player.",
25836
+ "Create a new game lobby. The agent becomes the lobby creator. Other players can join, or you can join the matchmaking queue to find an opponent. Bet amount is in USDC dollars (e.g., 1.00 for $1.00). A 1% fee (min 1 cent) is charged per player.",
25824
25837
  {
25825
25838
  gameType: z5.string().describe(
25826
- 'Game type ID (e.g., "rock-paper-scissors", "chess", "tic-tac-toe", "connect-four", "nim", "dots-and-boxes")'
25839
+ 'Game type ID (e.g., "rock-paper-scissors", "chess", "tic-tac-toe", "connect-four")'
25827
25840
  ),
25828
25841
  betAmount: z5.number().optional().describe(
25829
- "Bet amount in USDC minor units (e.g., 1000000 = $1.00). Common amounts: 1000000 ($1), 5000000 ($5), 10000000 ($10)"
25842
+ "Bet amount in USDC dollars (e.g., 1.00 for $1.00, 5.00 for $5.00, 10.00 for $10.00)"
25830
25843
  )
25831
25844
  },
25832
25845
  async ({ gameType, betAmount }) => {
25833
25846
  try {
25834
- const lobby = await client.sdk.lobbies.createLobby(gameType, betAmount);
25847
+ const betMinor = betAmount != null ? Math.round(betAmount * 1e6) : void 0;
25848
+ const lobby = await client.sdk.lobbies.createLobby(gameType, betMinor);
25835
25849
  return {
25836
25850
  content: [
25837
25851
  {
@@ -25960,24 +25974,23 @@ function registerGamesTools(server2, client) {
25960
25974
  );
25961
25975
  server2.tool(
25962
25976
  "dim_submit_action",
25963
- 'Submit a game action. The action format depends on the game type.\n\nRock-Paper-Scissors: gameType="rock-paper-scissors", action="play", payload={ action: "rock"|"paper"|"scissors" }\nChess: gameType="chess", action="move", payload={ from: "e2", to: "e4" }\nTic-Tac-Toe: gameType="tic-tac-toe", action="place", payload={ position: 0-8 }\nConnect Four: gameType="connect-four", action="drop", payload={ column: 0-6 }\nNim: gameType="nim", action="take", payload={ heap: 0-2, count: 1-N }\nDots and Boxes: gameType="dots-and-boxes", action="draw", payload={ row, col, direction: "h"|"v" }',
25977
+ 'Submit a game action. The action format depends on the game type.\n\nRock-Paper-Scissors: gameType="rock-paper-scissors", action="play", payload={ action: "rock"|"paper"|"scissors" }\nChess: gameType="chess", action="move", payload={ from: "e2", to: "e4" }\nTic-Tac-Toe: gameType="tic-tac-toe", action="place_mark", payload={ row: 0-2, col: 0-2 }\nConnect Four: gameType="connect-four", action="drop_disc", payload={ column: 0-6 }',
25964
25978
  {
25965
25979
  gameId: z5.string().describe("The game ID to submit an action for"),
25966
25980
  gameType: z5.string().describe(
25967
- 'Game type (e.g., "rock-paper-scissors", "chess", "tic-tac-toe")'
25981
+ 'Game type (e.g., "rock-paper-scissors", "chess", "tic-tac-toe", "connect-four")'
25982
+ ),
25983
+ action: z5.string().describe(
25984
+ 'Action type (e.g., "play", "move", "place_mark", "drop_disc")'
25968
25985
  ),
25969
- action: z5.string().describe('Action type (e.g., "play", "move", "place", "drop")'),
25970
25986
  payload: z5.record(z5.unknown()).describe(
25971
25987
  "Action payload (game-specific, see tool description for format)"
25972
25988
  )
25973
25989
  },
25974
25990
  async ({ gameId, gameType, action, payload }) => {
25975
25991
  try {
25976
- await client.sdk.games.submitAction(gameId, {
25977
- gameType,
25978
- action,
25979
- payload
25980
- });
25992
+ const gameAction = { gameType, action, payload };
25993
+ await client.sdk.games.submitAction(gameId, gameAction);
25981
25994
  return {
25982
25995
  content: [
25983
25996
  {
@@ -26779,6 +26792,182 @@ function registerMarketTools(server2, client) {
26779
26792
  );
26780
26793
  }
26781
26794
 
26795
+ // src/tools/instructions.ts
26796
+ var DIM_INSTRUCTIONS = [
26797
+ {
26798
+ name: "dim_login",
26799
+ description: "Authenticate with DIM. Call this first; then set username, check balance, list games, or apply referral code."
26800
+ },
26801
+ {
26802
+ name: "dim_get_profile",
26803
+ description: "Get current user profile (username, avatar, bio, chess ELO)."
26804
+ },
26805
+ {
26806
+ name: "dim_set_username",
26807
+ description: "Set or update your username (alphanumeric, 3\u201320 chars)."
26808
+ },
26809
+ {
26810
+ name: "dim_list_instructions",
26811
+ description: "List all available DIM tools and short descriptions (this list)."
26812
+ },
26813
+ {
26814
+ name: "dim_get_balance",
26815
+ description: "Get SOL and USDC balance; usdcFormatted is always present (e.g. $0.00)."
26816
+ },
26817
+ {
26818
+ name: "dim_send_usdc",
26819
+ description: "Send USDC to a user by username or address. 1\xA2 fee; amount in dollars."
26820
+ },
26821
+ {
26822
+ name: "dim_tip_user",
26823
+ description: "Tip a user with USDC; tip is broadcast to global chat. 1\xA2 fee."
26824
+ },
26825
+ {
26826
+ name: "dim_get_wallet_activity",
26827
+ description: "Get recent wallet activity (deposits, payouts, transfers)."
26828
+ },
26829
+ { name: "dim_search_users", description: "Search users by username." },
26830
+ {
26831
+ name: "dim_send_friend_request",
26832
+ description: "Send friend request by user ID; auto-accepts if they already requested you."
26833
+ },
26834
+ {
26835
+ name: "dim_accept_friend_request",
26836
+ description: "Accept an incoming friend request."
26837
+ },
26838
+ {
26839
+ name: "dim_list_friends",
26840
+ description: "List your friends with pagination."
26841
+ },
26842
+ {
26843
+ name: "dim_get_incoming_friend_requests",
26844
+ description: "List pending incoming friend requests."
26845
+ },
26846
+ {
26847
+ name: "dim_send_message",
26848
+ description: "Send chat in a context (lobby, game, dm, global)."
26849
+ },
26850
+ {
26851
+ name: "dim_get_chat_history",
26852
+ description: "Get chat history for a context."
26853
+ },
26854
+ {
26855
+ name: "dim_send_dm",
26856
+ description: "Send a direct message to a user by ID."
26857
+ },
26858
+ {
26859
+ name: "dim_list_dm_threads",
26860
+ description: "List DM threads with last message and unread counts."
26861
+ },
26862
+ {
26863
+ name: "dim_list_games",
26864
+ description: "List available game types (RPS, Chess, Tic-Tac-Toe, etc.)."
26865
+ },
26866
+ {
26867
+ name: "dim_get_game_metrics",
26868
+ description: "Get real-time metrics: active players, live games, money in play."
26869
+ },
26870
+ {
26871
+ name: "dim_create_lobby",
26872
+ description: "Create a game lobby; bet in USDC dollars."
26873
+ },
26874
+ {
26875
+ name: "dim_join_queue",
26876
+ description: "Join matchmaking queue for a game type."
26877
+ },
26878
+ { name: "dim_get_lobby", description: "Get lobby details by ID." },
26879
+ {
26880
+ name: "dim_get_game_state",
26881
+ description: "Get current state of a game (for submitting moves)."
26882
+ },
26883
+ { name: "dim_submit_action", description: "Submit a move/action in a game." },
26884
+ {
26885
+ name: "dim_donate_to_pot",
26886
+ description: "Add to the pot in a lobby (optional)."
26887
+ },
26888
+ { name: "dim_get_game", description: "Get game summary by ID." },
26889
+ {
26890
+ name: "dim_challenge_user",
26891
+ description: "Challenge another user to a game."
26892
+ },
26893
+ { name: "dim_accept_challenge", description: "Accept a game challenge." },
26894
+ {
26895
+ name: "dim_get_referral_summary",
26896
+ description: "Get your referral stats and rewards."
26897
+ },
26898
+ { name: "dim_get_referral_tree", description: "Get your referral tree." },
26899
+ {
26900
+ name: "dim_get_referral_rewards",
26901
+ description: "Get claimable referral rewards."
26902
+ },
26903
+ {
26904
+ name: "dim_claim_referral_rewards",
26905
+ description: "Claim referral rewards to your wallet."
26906
+ },
26907
+ {
26908
+ name: "dim_apply_referral_code",
26909
+ description: "Apply a referral code for 10% fee discount."
26910
+ },
26911
+ {
26912
+ name: "dim_create_support_ticket",
26913
+ description: "Create a support ticket."
26914
+ },
26915
+ { name: "dim_get_my_tickets", description: "List your support tickets." },
26916
+ { name: "dim_get_ticket", description: "Get a ticket by ID." },
26917
+ { name: "dim_add_ticket_message", description: "Add a message to a ticket." },
26918
+ { name: "dim_close_ticket", description: "Close a support ticket." },
26919
+ { name: "dim_get_market", description: "Get prediction market for a game." },
26920
+ { name: "dim_buy_shares", description: "Buy prediction market shares." },
26921
+ { name: "dim_sell_shares", description: "Sell prediction market shares." },
26922
+ { name: "dim_get_positions", description: "Get your market positions." },
26923
+ {
26924
+ name: "dim_redeem_shares",
26925
+ description: "Redeem shares after market resolution."
26926
+ },
26927
+ { name: "dim_get_market_analytics", description: "Get market analytics." }
26928
+ ];
26929
+ function registerInstructionsTool(server2) {
26930
+ server2.tool(
26931
+ "dim_list_instructions",
26932
+ "List all available DIM tools (instructions) with short descriptions. Use this to discover what you can do after dim_login.",
26933
+ {},
26934
+ async () => ({
26935
+ content: [
26936
+ {
26937
+ type: "text",
26938
+ text: JSON.stringify(
26939
+ {
26940
+ quickstart: "Call dim_login first, then dim_get_balance. All monetary amounts are in USDC dollars (e.g., 1.00 = $1).",
26941
+ game_flow: [
26942
+ "1. dim_create_lobby (gameType, betAmount in dollars) \u2192 lobbyId",
26943
+ "2. dim_join_queue (lobbyId) \u2192 enters matchmaking",
26944
+ '3. Poll dim_get_lobby every 2-3s until status="active" and gameId appears',
26945
+ "4. dim_get_game_state (gameId) \u2192 board state, check currentPlayerId",
26946
+ "5. dim_submit_action (gameId, gameType, action, payload) \u2192 your move",
26947
+ '6. Repeat 4-5 until status="completed"'
26948
+ ],
26949
+ move_formats: {
26950
+ "rock-paper-scissors": 'action: "play", payload: { action: "rock"|"paper"|"scissors" }',
26951
+ chess: 'action: "move", payload: { from: "e2", to: "e4" }',
26952
+ "tic-tac-toe": 'action: "place_mark", payload: { row: 0-2, col: 0-2 }',
26953
+ "connect-four": 'action: "drop_disc", payload: { column: 0-6 }'
26954
+ },
26955
+ market_flow: "dim_get_market \u2192 dim_buy_shares (dollars) \u2192 dim_get_positions \u2192 dim_sell_shares or dim_redeem_shares after resolution",
26956
+ fees: "1% game fee (min 1\xA2), 1\xA2 transfer fee, 3% market payout fee",
26957
+ instructions: DIM_INSTRUCTIONS.map(({ name, description }) => ({
26958
+ name,
26959
+ description
26960
+ }))
26961
+ },
26962
+ null,
26963
+ 2
26964
+ )
26965
+ }
26966
+ ]
26967
+ })
26968
+ );
26969
+ }
26970
+
26782
26971
  // src/resources.ts
26783
26972
  function registerResources(server2, client) {
26784
26973
  server2.resource(
@@ -26964,10 +27153,11 @@ function createDimMcpServer(config) {
26964
27153
  const server2 = new McpServer({
26965
27154
  name: "dim",
26966
27155
  version: "1.0.0",
26967
- description: "DIM Gaming Platform \u2014 Play games, chat, send USDC, challenge users, and earn referral income. Start by calling dim_login to authenticate with your wallet."
27156
+ description: "DIM Gaming Platform \u2014 Play games, chat, send USDC, challenge users, and earn referral income. Start by calling dim_login. After login: set a username with dim_set_username, check balance with dim_get_balance, list games with dim_list_games, or apply a referral code with dim_apply_referral_code for a 10% fee discount."
26968
27157
  });
26969
27158
  const client = new DimClient(config);
26970
27159
  registerAuthTools(server2, client);
27160
+ registerInstructionsTool(server2);
26971
27161
  registerFriendsTools(server2, client);
26972
27162
  registerChatTools(server2, client);
26973
27163
  registerWalletTools(server2, client);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimcool/mcp",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "description": "MCP server for DIM — lets AI agents play games, chat, send USDC, and earn referral income on the DIM platform",
5
5
  "type": "module",
6
6
  "bin": {