tchcash
v0.1.2
Published
ThaiChain wallet + MPP payment proxy for AI agents
Maintainers
Readme
tchcash
ThaiChain wallet + MPP payment proxy for AI agents
tchcash is an MCP server that runs locally on your machine, acting as a wallet client for AI agents. It enables agents to automatically pay for MPP/x402 APIs on ThaiChain without manual intervention.
Features
- ✅ Automatic wallet creation - Creates a new wallet and saves to
.tchcash/wallet.json - ✅ Balance checking - Verify TCH balance before using paid APIs
- ✅ Automatic payment handling - Uses mppx SDK to handle 402 Payment Required flow
- ✅ MCP stdio transport - Compatible with Claude, Cursor, and other MCP clients
- ✅ ThaiChain native - Supports TCH (TIP-20 token) on ThaiChain (chainId: 7)
Installation
Option 1: Install from npm (Recommended)
# Using npm
npm install -g tchcash
# Using pnpm
pnpm add -g tchcash
# Or run directly with npx
npx tchcashOption 2: Local Development
# Clone repository
git clone https://github.com/thaichain/tchcash.git
cd tchcash
# Install dependencies
pnpm install
# Build
pnpm build
# Link locally (for testing)
pnpm link --globalThen use in MCP config:
{
"mcpServers": {
"tchcash": {
"command": "tchcash"
}
}
}Usage
Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"tchcash": {
"command": "tchcash"
}
}
}Cursor
Add to .cursor/mcp.json:
{
"mcpServers": {
"tchcash": {
"command": "tchcash"
}
}
}ZCode
Create .mcp.json in project:
{
"tchcash": {
"command": "tchcash"
}
}MCP Tools
setup_wallet
Creates a new ThaiChain wallet or loads an existing one. The wallet is automatically saved to .tchcash/wallet.json on your local machine.
Parameters:
force_new(optional, boolean) - If true, creates a new wallet even if one exists
Example:
{
"name": "setup_wallet",
"arguments": {}
}check_balance
Checks the TCH balance of the wallet saved in .tchcash/wallet.json.
Parameters: None
Example:
{
"name": "check_balance",
"arguments": {}
}fetch_market_data
Fetches crypto market data (BTC, ETH, TCH prices) from tchmpp server. tchcash automatically pays $0.01 from the wallet.
Parameters: None
Example:
{
"name": "fetch_market_data",
"arguments": {}
}fetch_weather
Fetches weather data for Bangkok, Thailand. tchcash automatically pays $0.005 from the wallet.
Parameters: None
Example:
{
"name": "fetch_weather",
"arguments": {}
}fetch_data
Fetches sample data. tchcash automatically pays $0.01 from the wallet.
Parameters: None
Example:
{
"name": "fetch_data",
"arguments": {}
}fetch_url
Calls any paid API on tchmpp server. tchcash automatically pays from the wallet.
Parameters:
path(string, required) - URL path (e.g.,/api/v1/marketor/api/v1/generate)method(optional, string) - HTTP method (GET, POST), default: GETbody(optional, string) - Request body (JSON string) for POST requests
Example:
{
"name": "fetch_url",
"arguments": {
"path": "/api/v1/generate",
"method": "POST",
"body": "{\"prompt\":\"Hello\"}"
}
}Workflow
- Setup wallet - Call
setup_walletto create a wallet - Fund wallet - Tell user to transfer TCH to the address (recommended 10 TCH)
- Check balance - Call
check_balanceto verify funds - Call APIs - Call
fetch_market_data,fetch_weather, etc.
Architecture
┌─────────┐ ┌──────────────────┐ ┌──────────────┐
│ Agent │ ───► │ tchcash MCP │ ───► │ tchmpp │
│ (Claude)│ stdio│ - wallet store │ HTTP │ (Cloudflare) │
│ │ ◄─── │ - mppx SDK │ ◄─── │ │
└─────────┘ └──────────────────┘ └──────────────┘
Handles 402 challenge
Signs + broadcasts TX
Sends proof backSecurity
- Private key is saved to
.tchcash/wallet.jsonon your local machine - NEVER commit this file to Git (it's in
.gitignore) - tchcash does NOT send private keys to external servers
- mppx SDK handles payment locally on your machine only
Chain Information
- Name: ThaiChain
- Chain ID: 7
- CAIP-2: eip155:7
- RPC: https://rpc.thaichain.org
- Explorer: https://exp.thaichain.org
- Token: TCH (TIP-20, 6 decimals)
Development
# Install dependencies
pnpm install
# Build
pnpm build
# Run dev
pnpm dev
# Type check
pnpm typecheckLicense
MIT
