A Model Context Protocol (MCP) server that provides onchain tools for AI applications like Claude Desktop and Cursor, allowing them to interact with the Base Network and Coinbase API.
A Model Context Protocol (MCP) server that provides onchain tools for AI applications like Claude Desktop and Cursor, allowing them to interact with the Base Network and Coinbase API.
This MCP server extends any MCP client's capabilities by providing tools to do anything on Base:
The server interacts with Base, powered by Base Developer Tools and AgentKit.
Base MCP is designed to be extensible, allowing you to add your own third-party protocols, tools, and data sources. This section provides an overview of how to extend the Base MCP server with new capabilities.
If you want to add a new tool to the Base MCP server, follow these steps:
src/tools
directory for your toolindex.ts
: Define and export your toolsschemas.ts
: Define input schemas for your toolshandlers.ts
: Implement the functionality of your toolssrc/tools/index.ts
The Base MCP server follows this structure for tools:
src/
├── tools/
│ ├── index.ts (exports toolsets)
│ ├── [TOOL_NAME]/ <-------------------------- ADD DIR HERE
│ │ ├── index.ts (defines and exports tools)
│ │ ├── schemas.ts (defines input schema)
│ │ └── handlers.ts (implements tool functionality)
│ └── utils/ (shared tool utilities)
When developing new tools for Base MCP:
For more detailed information on contributing to Base MCP, including adding new tools and protocols, see the CONTRIBUTING.md file.
# Install globally
npm install -g base-mcp
# Or install locally in your project
npm install base-mcp
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
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
Test the MCP server to verify it's working correctly:
npm test
This script will verify that your MCP server is working correctly by testing the connection and available tools.
See the examples.md file for detailed examples of how to interact with the Base MCP tools through Claude.
To add this MCP server to Claude Desktop:
Create or edit the Claude Desktop configuration file at:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.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.
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": []
}
}
}
Restart Claude Desktop for the changes to take effect.
Retrieves the address for your wallet.
Example query to Claude:
"What's my wallet address?"
Lists all balances for your wallet.
Example query to Claude:
"Show me my wallet balances."
Transfers funds from your wallet to another address.
Parameters:
destination
: The address to which to transfer fundsassetId
: The asset ID to transferamount
: The amount of funds to transferExample query to Claude:
"Transfer 0.01 ETH to 0x1234567890abcdef1234567890abcdef12345678."
Deploys a smart contract to the blockchain.
Parameters:
constructorArgs
: The arguments for the contract constructorcontractName
: The name of the contract to deploysolidityInputJson
: The JSON input for the Solidity compiler containing contract source and settingssolidityVersion
: The version of the solidity compilerExample query to Claude:
"Deploy a simple ERC20 token contract for me."
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."
Calls a contract function on the blockchain.
Parameters:
contractAddress
: The address of the contract to callfunctionName
: The name of the function to callfunctionArgs
: The arguments to pass to the functionabi
: The ABI of the contractvalue
: The value of ETH to send with the transaction (optional)Example query to Claude:
"Call the balanceOf function on the contract at 0x1234567890abcdef1234567890abcdef12345678."
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 residencesubdivision
: 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?"
Gets a URL for onramping funds via Coinbase.
Parameters:
amountUsd
: The amount of funds to onrampassetId
: The asset ID to onrampExample query to Claude:
"I want to onramp $100 worth of ETH."
Gets the balance of an ERC20 token.
Parameters:
contractAddress
: The address of the ERC20 contractExample query to Claude:
"What's my balance of the token at 0x1234567890abcdef1234567890abcdef12345678?"
Transfers an ERC20 token to another address.
Parameters:
contractAddress
: The address of the ERC20 contracttoAddress
: The address of the recipientamount
: The amount of tokens to transferExample query to Claude:
"Transfer 10 USDC to 0x1234567890abcdef1234567890abcdef12345678."
Buys OpenRouter credits with USDC.
Parameters:
amountUsd
: The amount of credits to buy, in USDExample query to Claude:
"Buy $20 worth of OpenRouter credits."
If you encounter issues:
Contributions are welcome! Please feel free to submit a Pull Request.
For detailed guidelines on contributing to Base MCP, including:
Please refer to our comprehensive CONTRIBUTING.md guide.
Basic contribution steps:
git checkout -b feature/amazing-feature
)git commit -m 'Add some amazing feature'
)git push origin feature/amazing-feature
)Please make sure your code follows the existing style and includes appropriate tests.