@tongateway/mcp 0.3.0 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +30 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2,8 +2,29 @@
2
2
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { z } from 'zod';
5
+ import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
6
+ import { join } from 'node:path';
7
+ import { homedir } from 'node:os';
5
8
  const API_URL = process.env.AGENT_GATEWAY_API_URL ?? 'https://api.tongateway.ai';
6
- let TOKEN = process.env.AGENT_GATEWAY_TOKEN || '';
9
+ const TOKEN_FILE = join(homedir(), '.tongateway', 'token');
10
+ function loadToken() {
11
+ if (process.env.AGENT_GATEWAY_TOKEN)
12
+ return process.env.AGENT_GATEWAY_TOKEN;
13
+ try {
14
+ return readFileSync(TOKEN_FILE, 'utf-8').trim();
15
+ }
16
+ catch {
17
+ return '';
18
+ }
19
+ }
20
+ function saveToken(token) {
21
+ try {
22
+ mkdirSync(join(homedir(), '.tongateway'), { recursive: true });
23
+ writeFileSync(TOKEN_FILE, token, 'utf-8');
24
+ }
25
+ catch { }
26
+ }
27
+ let TOKEN = loadToken();
7
28
  async function apiCall(path, options = {}) {
8
29
  const headers = {
9
30
  'Content-Type': 'application/json',
@@ -91,8 +112,9 @@ server.tool('get_auth_token', 'Check if the user has completed wallet authentica
91
112
  ],
92
113
  };
93
114
  }
94
- // Store the token for future API calls
115
+ // Store the token for future API calls and persist to disk
95
116
  TOKEN = data.token;
117
+ saveToken(TOKEN);
96
118
  return {
97
119
  content: [
98
120
  {
@@ -119,7 +141,8 @@ server.tool('request_transfer', 'Request a TON transfer from the wallet owner. T
119
141
  to: z.string().describe('Destination TON address'),
120
142
  amountNano: z.string().describe('Amount in nanoTON (1 TON = 1000000000)'),
121
143
  payloadBoc: z.string().optional().describe('Optional BOC-encoded payload for the transaction'),
122
- }, async ({ to, amountNano, payloadBoc }) => {
144
+ stateInit: z.string().optional().describe('Optional stateInit BOC for deploying new contracts'),
145
+ }, async ({ to, amountNano, payloadBoc, stateInit }) => {
123
146
  if (!TOKEN) {
124
147
  return {
125
148
  content: [{ type: 'text', text: 'No token configured. Use request_auth first to authenticate.' }],
@@ -130,6 +153,8 @@ server.tool('request_transfer', 'Request a TON transfer from the wallet owner. T
130
153
  const body = { to, amountNano };
131
154
  if (payloadBoc)
132
155
  body.payloadBoc = payloadBoc;
156
+ if (stateInit)
157
+ body.stateInit = stateInit;
133
158
  const result = await apiCall('/v1/safe/tx/transfer', {
134
159
  method: 'POST',
135
160
  body: JSON.stringify(body),
@@ -180,6 +205,8 @@ server.tool('get_request_status', 'Check the status of a previously submitted tr
180
205
  `To: ${result.to}`,
181
206
  `Amount: ${result.amountNano} nanoTON`,
182
207
  result.txHash ? `TX Hash: ${result.txHash}` : null,
208
+ result.broadcastResult ? `Broadcast: ${result.broadcastResult}` : null,
209
+ result.broadcastError ? `Error: ${result.broadcastError}` : null,
183
210
  `Created: ${new Date(result.createdAt).toISOString()}`,
184
211
  `Expires: ${new Date(result.expiresAt).toISOString()}`,
185
212
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tongateway/mcp",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "MCP server for Agent Gateway — lets AI agents request TON blockchain transfers",
5
5
  "license": "MIT",
6
6
  "repository": {