Base Blockchain MCP server

Enables Claude to interact with the Base blockchain and Coinbase API for cryptocurrency operations including wallet management, fund transfers, and smart contract deployments.
Back to servers
Provider
Base
Release date
Dec 17, 2024
Language
TypeScript
Package
Stats
2.2K downloads
249 stars

The Base MCP Server provides onchain tools for AI applications like Claude Desktop and Cursor, enabling them to interact with the Base Network and Coinbase API. It unlocks capabilities like retrieving wallet addresses, managing funds, deploying smart contracts, and interacting with various protocols on the Base blockchain.

Installation

Option 1: Install from npm (Recommended)

# Install globally
npm install -g base-mcp

# Or install locally in your project
npm install base-mcp

Option 2: Install from Source

# Clone this repository
git clone https://github.com/base/base-mcp.git
cd base-mcp

# Install dependencies
npm install

# Build the project
npm run build

# Optionally, link it globally
npm link

Configuration

Create a .env file with your credentials:

# Coinbase API credentials
# You can obtain these from the Coinbase Developer Portal: https://cdp.coinbase.com/
COINBASE_API_KEY_NAME=your_api_key_name
COINBASE_API_PRIVATE_KEY=your_private_key

# Wallet seed phrase (12 or 24 words)
# This is the mnemonic phrase for your wallet
SEED_PHRASE=your seed phrase here

# Coinbase Project ID (for onramp functionality)
# You can obtain this from the Coinbase Developer Portal
COINBASE_PROJECT_ID=your_project_id

# OpenRouter API Key (optional for buying OpenRouter credits)
# You can obtain this from https://openrouter.ai/keys
OPENROUTER_API_KEY=your_openrouter_api_key

Testing

Test the MCP server to verify it's working correctly:

npm test

Integration with Claude Desktop

To add this MCP server to Claude Desktop:

  1. Create or edit the Claude Desktop configuration file at:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
    • Linux: ~/.config/Claude/claude_desktop_config.json

    You can easily access this file via the Claude Desktop app by navigating to Claude > Settings > Developer > Edit Config.

  2. Add the following configuration:

{
  "mcpServers": {
    "base-mcp": {
      "command": "npx",
      "args": ["base-mcp@latest"],
      "env": {
        "COINBASE_API_KEY_NAME": "your_api_key_name",
        "COINBASE_API_PRIVATE_KEY": "your_private_key",
        "SEED_PHRASE": "your seed phrase here",
        "COINBASE_PROJECT_ID": "your_project_id",
        "OPENROUTER_API_KEY": "your_openrouter_api_key"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
  1. Restart Claude Desktop for the changes to take effect.

Available Tools

get-address

Retrieves the address for your wallet.

Example query to Claude: "What's my wallet address?"

list-balances

Lists all balances for your wallet.

Example query to Claude: "Show me my wallet balances."

transfer-funds

Transfers funds from your wallet to another address.

Parameters:

  • destination: The address to which to transfer funds
  • assetId: The asset ID to transfer
  • amount: The amount of funds to transfer

Example query to Claude: "Transfer 0.01 ETH to 0x1234567890abcdef1234567890abcdef12345678."

deploy-contract

Deploys a smart contract to the blockchain.

Parameters:

  • constructorArgs: The arguments for the contract constructor
  • contractName: The name of the contract to deploy
  • solidityInputJson: The JSON input for the Solidity compiler containing contract source and settings
  • solidityVersion: The version of the solidity compiler

Example query to Claude: "Deploy a simple ERC20 token contract for me."

get_morpho_vaults

Gets the vaults for a given asset on Morpho.

Parameters:

  • assetSymbol: Asset symbol by which to filter vaults (optional)

Example query to Claude: "Show me the available Morpho vaults for USDC."

call_contract

Calls a contract function on the blockchain.

Parameters:

  • contractAddress: The address of the contract to call
  • functionName: The name of the function to call
  • functionArgs: The arguments to pass to the function
  • abi: The ABI of the contract
  • value: The value of ETH to send with the transaction (optional)

Example query to Claude: "Call the balanceOf function on the contract at 0x1234567890abcdef1234567890abcdef12345678."

get_onramp_assets

Gets the assets available for onramping in a given country/subdivision.

Parameters:

  • country: ISO 3166-1 two-digit country code string representing the purchasing user's country of residence
  • subdivision: ISO 3166-2 two-digit country subdivision code (required for US)

Example query to Claude: "What assets can I onramp in the US, specifically in New York?"

onramp

Gets a URL for onramping funds via Coinbase.

Parameters:

  • amountUsd: The amount of funds to onramp
  • assetId: The asset ID to onramp

Example query to Claude: "I want to onramp $100 worth of ETH."

erc20_balance

Gets the balance of an ERC20 token.

Parameters:

  • contractAddress: The address of the ERC20 contract

Example query to Claude: "What's my balance of the token at 0x1234567890abcdef1234567890abcdef12345678?"

erc20_transfer

Transfers an ERC20 token to another address.

Parameters:

  • contractAddress: The address of the ERC20 contract
  • toAddress: The address of the recipient
  • amount: The amount of tokens to transfer

Example query to Claude: "Transfer 10 USDC to 0x1234567890abcdef1234567890abcdef12345678."

buy_openrouter_credits

Buys OpenRouter credits with USDC.

Parameters:

  • amountUsd: The amount of credits to buy, in USD

Example query to Claude: "Buy $20 worth of OpenRouter credits."

Security Considerations

  • The configuration file contains sensitive information (API keys and seed phrases). Ensure it's properly secured and not shared.
  • Consider using environment variables or a secure credential manager instead of hardcoding sensitive information.
  • Be cautious when transferring funds or deploying contracts, as these operations are irreversible on the blockchain.
  • When using the onramp functionality, ensure you're on a secure connection.
  • Verify all transaction details before confirming, especially when transferring funds or buying credits.

Troubleshooting

If you encounter issues:

  • Check that your Coinbase API credentials are correct
  • Verify that your seed phrase is valid
  • Ensure you're on the correct network (Base Mainnet)
  • Check the Claude Desktop logs for any error messages

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later