使用说明
TON Connect MCP Server
A TypeScript Model Context Protocol server for interacting with TON wallets through TON Connect. An MCP client launches the server locally over stdio; wallet connection and transaction approval happen in the user's wallet.
Capabilities
- Discover wallets and establish or disconnect a TON Connect session.
- Read the connected wallet's address, chain, and public key.
- Request TON transactions with optional comments, payloads, and contract state initialization.
- Build jetton and NFT transfer payloads with
@ton/ton.
The current entry point uses one wallet connection per process and in-memory storage. Restarting the process clears its session storage. It does not expose an HTTP server or use Redis.
Build from source
Requirements: Node.js 18 or newer and npm.
git clone https://github.com/nakazanie-ton/ton-connect-mcp.git
cd ton-connect-mcp
npm ci
npm run build
Configure an MCP client that supports stdio with an absolute path to the compiled entry point:
{
"mcpServers": {
"ton-connect": {
"command": "node",
"args": ["/absolute/path/to/ton-connect-mcp/dist/index.js"]
}
}
}
The exact configuration location depends on the client. The client starts and communicates with the process over standard input/output.
For development, npm run dev runs src/index.ts through tsx. npm start runs the compiled server.
Configuration
| Variable | Purpose |
|---|---|
TONCONNECT_MANIFEST_URL |
Optional HTTPS URL for your application's TON Connect manifest. Defaults to Palette Finance's public manifest. |
DEBUG_TON_CONNECT |
Enables wallet status messages on stderr when set to a non-empty value. |
For your own integration, use a manifest that identifies your application. See tonconnect-manifest.example.json. The default is https://app.palette.finance/tonconnect-manifest.json.
PORT and REDIS_URL are not read by the current stdio entry point.
Tools
| Tool | Parameters | Behavior |
|---|---|---|
list_wallets |
None | Lists wallets from the TON Connect registry. |
connect_wallet |
wallet_name (required) |
Returns a connection link for the selected wallet. |
get_wallet_status |
None | Reads the current connection and account details. |
disconnect_wallet |
None | Disconnects the current wallet. |
send_transaction |
to, amount; optional payload, state_init, valid_until, comment |
Requests a transaction for approval in the connected wallet. |
build_jetton_transfer_payload |
recipient_address, jetton_amount; optional response_address, forward_ton_amount, forward_payload |
Returns a base64 BOC payload for a jetton transfer. |
build_nft_transfer_payload |
new_owner_address; optional response_address, forward_amount, forward_payload |
Returns a base64 BOC payload for an NFT transfer. |
sign_proof |
payload |
Reports TON proof support and connection-time requirements; it does not perform a separate signing operation. |
send_transaction.amount is a string in nanoTON. Jetton amounts are strings in the token's smallest units. Payload builders return data; sending it is a separate operation.
The current entry point does not register a sign_data tool. TON proof authentication is not a completed connection flow in this implementation.
Wallet workflow
- Call
list_walletsand choose a wallet name. - Call
connect_walletwith that name. - Open the returned link and approve the connection in the wallet.
- Call
get_wallet_statusto confirm the connected account. - Review any transaction's recipient, amount, payload, and network in the wallet before approval.
- Use
disconnect_walletwhen finished.
For jetton transfers, send the built payload to the sender's jetton wallet contract, not directly to the recipient. For NFTs, send it to the NFT item contract. The TON amount attached to either transaction covers execution and forwarding; the required amount depends on the contract.
Source layout
- src/index.ts: active server entry point, tool registration, and single TON Connect instance.
- src/storage.ts: in-memory TON Connect storage.
- src/wallet-manager.ts: additional wallet-management implementation; the current entry point creates its connector directly.
There is no automated test suite or CI workflow in the current repository. The build command compiles TypeScript; it does not verify a live wallet interaction.
License
MIT.