Skip to content

Codebuddy Integration

Integrate MCP Wallet with Codebuddy to enable AI-powered wallet management directly from Tencent's AI coding assistant.

Overview

Codebuddy is Tencent AI's coding assistant that supports MCP integration. This guide shows you how to connect MCP Wallet to Codebuddy CLI using HTTP transport and OAuth 2.1 authentication.

Features:

  • ✅ HTTP Transport (Direct integration, no adapter needed)
  • ✅ OAuth 2.1 authentication with PKCE
  • ✅ Balance checking
  • ✅ Transaction sending
  • ✅ Transaction monitoring
  • ✅ Multi-token support
  • ✅ Code-integrated wallet access

Prerequisites

Before you begin, ensure you have:

  1. MCP Wallet installed and running

  2. Wallet created and unlocked

  3. Node.js v18 or higher (optional, for npm installation)

    • Required if installing via npm
    • Download: Node.js
  4. API access enabled

    • Settings → Accounts → Enable API toggle

Installation

Step 1: Install Codebuddy CLI

If you haven't installed Codebuddy CLI yet:

bash
npm install -g @tencent-ai/codebuddy-code

Or with yarn:

bash
yarn global add @tencent-ai/codebuddy-code

Verify installation:

bash
codebuddy --version

Step 2: Start MCP Wallet

  1. Launch MCP Wallet application
  2. Unlock your wallet with your password
  3. The MCP server starts automatically on port 8580
  4. Verify in SettingsMCP Server:

Configuration

Step 3: Add MCP Wallet to Codebuddy

Run this single command to add MCP Wallet:

bash
codebuddy mcp add --transport http mcp-wallet http://localhost:8580/mcp

This will add MCP Wallet to your Codebuddy CLI configuration.

Alternative: Manual Configuration

If the command doesn't work, you can manually edit the config file:

File: ~/.codebuddy/config.json

json
{
  "mcpServers": {
    "mcp-wallet": {
      "serverUrl": "http://localhost:8580/mcp",
      "oauth": {
        "clientId": "codebuddy"
      }
    }
  }
}

Or with the url property (some versions use this):

json
{
  "mcpServers": {
    "mcp-wallet": {
      "url": "http://localhost:8580/mcp",
      "oauth": {
        "clientId": "codebuddy"
      }
    }
  }
}

Key points:

  • URL points to MCP Wallet on port :8580
  • No transport specified (HTTP is default for modern MCP clients)
  • OAuth client ID is "codebuddy"
  • OAuth endpoints are auto-discovered via metadata

Authorization

Step 4: Authorize Codebuddy

When Codebuddy CLI first uses MCP Wallet, it will trigger OAuth authorization:

  1. Codebuddy opens your browser with authorization page
  2. MCP Wallet shows authorization dialog
  3. Review the permissions:
    • Client: codebuddy
    • Permissions: wallet:read wallet:write
    • Account: Your wallet address
  4. Click "Approve" to grant access
  5. Browser redirects to success page (you can close it)
  6. Done! Codebuddy can now access your wallet

What happens during authorization:

  • OAuth 2.1 Authorization Code Flow with PKCE
  • Access token issued (valid for 1 hour)
  • Refresh token issued (valid for 30 days)
  • Tokens automatically refreshed when needed

Usage

Step 5: Try It Out

Start using Codebuddy with your wallet:

Start Codebuddy chat:

bash
codebuddy chat

Check wallet address:

> What's my wallet address?

Your wallet address is 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb

Check BNB balance:

> How much BNB do I have in my wallet?

You have 0.892 BNB in your wallet.

Check token balances:

> Check my USDT balance

You have 50.00 USDT in your wallet.

Send transaction:

> Send 0.01 BNB to 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb

Sending 0.01 BNB to 0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb...
Transaction sent successfully!
Transaction hash: 0x4952c33d1689cd57090d537052a1bc2efbc206cd65e36be048f04e4840cc75b7

Check transaction status:

> What's the status of transaction 0x4952c3...?

Transaction 0x4952c3... is confirmed.
Block: 42345678
Status: Success

Features

Supported Operations

OperationDescriptionExample
Get AddressView wallet address"What's my wallet address?"
Get BalanceCheck token balances"How much BNB do I have?"
Send TransactionTransfer tokens"Send 0.1 BNB to 0x..."
Transaction StatusCheck tx status"Is tx 0x... confirmed?"

Code Integration

Codebuddy can integrate wallet operations into your code:

Example 1: Check balance before deployment

> I'm deploying a contract. Do I have enough BNB?

Let me check your balance...
You have 0.892 BNB. That should be enough for deployment.

Example 2: Automated payments

> Send 0.05 BNB to the contract deployer address

Sending 0.05 BNB to 0x...
Transaction sent: 0x4952c3...

Security

Best Practices

  1. Start with testnet - Test integration on BSC Testnet first
  2. Use dedicated account - Create separate account for AI access
  3. Monitor transactions - Review AI-initiated transactions regularly
  4. Limited funds - Keep only needed amount in AI account
  5. Revoke when done - Disable API access when not using Codebuddy

What Codebuddy Can Access

Allowed ✅:

  • Read wallet address
  • Read token balances
  • Send transactions (after OAuth approval)
  • Check transaction status

Not Allowed ❌:

  • Access password or seed phrase
  • Export private keys
  • Modify security settings
  • Delete accounts
  • Change password

Revoking Access

You can revoke Codebuddy's access anytime:

  1. Open MCP Wallet
  2. Go to SettingsAuthorized AI Clients
  3. Find "codebuddy" in the list
  4. Click "Revoke All"
  5. All active tokens are immediately invalidated

Or simply:

  1. Go to SettingsAccounts
  2. Disable the "Enable API" toggle
  3. All AI access is disabled immediately

Troubleshooting

Codebuddy Can't Connect

Problem: Connection failed or Cannot connect to MCP server

Solutions:

  1. Verify MCP Wallet is running and unlocked
  2. Check API access is enabled: SettingsAccounts → Enable API
  3. Verify MCP server status: SettingsMCP Server → Should show "Running"
  4. Test connection manually:
    bash
    curl http://localhost:8580/mcp
  5. Check firewall allows port 8580

Authorization Fails

Problem: OAuth authorization doesn't work

Solutions:

  1. Make sure MCP Wallet is unlocked
  2. Check that browser opens authorization page
  3. Click "Auth" button on authorization page first
  4. Then approve in MCP Wallet dialog
  5. Click "Redirect" button on success page
  6. Restart Codebuddy and try again

Transactions Rejected

Problem: Transactions fail or are rejected

Possible Causes & Solutions:

Insufficient balance:

  • Check you have enough tokens + gas fees
  • Use > How much BNB do I have? to verify

Wrong network:

  • Verify you're on correct network (testnet vs mainnet)
  • Check SettingsNetwork in MCP Wallet

API disabled:

  • Make sure API access is still enabled
  • SettingsAccounts → Enable API toggle

Wallet locked:

  • Unlock wallet in MCP Wallet app
  • MCP server stops when wallet is locked

Token Expired

Problem: Authorization failed or Invalid token errors

Solutions:

  1. Tokens expire after 1 hour (access token) or 30 days (refresh token)
  2. Codebuddy should auto-refresh - if not, re-authorize:
    • Use Codebuddy's wallet tools again
    • MCP Wallet will show re-authorization dialog
    • Approve to get new tokens
  3. Or revoke and re-authorize manually:
    • MCP Wallet → Settings → Authorized AI Clients → Revoke
    • Restart Codebuddy chat session

Advanced Usage

Multiple Accounts

If you have multiple accounts in MCP Wallet:

  1. Switch account in SettingsAccounts
  2. Set the active AI account
  3. Codebuddy will use the newly selected account
  4. No re-authorization needed

Custom OAuth Client ID

If you want to use a different client ID:

Edit: ~/.codebuddy/config.json

json
{
  "mcpServers": {
    "mcp-wallet": {
      "serverUrl": "http://localhost:8580/mcp",
      "oauth": {
        "clientId": "my-custom-codebuddy"
      }
    }
  }
}

This will appear as "my-custom-codebuddy" in MCP Wallet's authorized clients list.

Monitoring API Usage

Track Codebuddy's wallet access:

  1. Transaction History

    • Open Transactions tab
    • Filter by "AI-initiated"
    • View all transactions made by Codebuddy
  2. Authorized Clients

    • SettingsAuthorized AI Clients
    • See active sessions
    • View last access time
    • Revoke specific tokens

FAQ

Do I need the SSE Adapter?

No! Codebuddy now supports HTTP transport directly, so you don't need the SSE Adapter. Just connect Codebuddy directly to MCP Wallet on port 8580.

Can I use Codebuddy with multiple wallets?

Yes! If you run multiple MCP Wallet instances on different ports, you can configure Codebuddy to use either:

json
{
  "mcpServers": {
    "mcp-wallet-main": {
      "serverUrl": "http://localhost:8580/mcp"
    },
    "mcp-wallet-test": {
      "serverUrl": "http://localhost:9580/mcp"
    }
  }
}

Is it safe to give Codebuddy access?

Yes, if you follow best practices:

  • Start with testnet to understand behavior
  • Use dedicated account with limited funds
  • Monitor transaction history regularly
  • Revoke access when not using Codebuddy

OAuth 2.1 ensures Codebuddy only has temporary, revocable access and cannot access your seed phrase or private keys.

How long do I stay authorized?

  • Access tokens: Valid for 1 hour
  • Refresh tokens: Valid for 30 days
  • Codebuddy auto-refreshes tokens when needed
  • You only need to re-authorize after 30 days or if you revoke access

Next Steps

Now that Codebuddy is integrated:

Need Help?


Questions? See FAQ or join Telegram Community

MCP Wallet - Secure crypto wallet with AI integration