Base Model Context Protocol (MCP) Server

repository·master·Indexed 43 days ago

https://github.com/base/base-mcp-legacy

A deprecated MCP server for building AI agents on Base, enabling tools for wallet operations, fund transfers, smart contract deployment, NFT management, and Morpho vault interactions. Version 1.0.14. Replaced by newer tools at docs.base.org.

Tokens
12.1K
Snippets
45
Records
58
Agent score
56%

What's inside Base MCP

  1. Explore Base MCP use cases

    master

    Base MCP enables AI applications (such as Claude and Cursor) to interact with the Base Network and Coinbase API. Use cases are categorized into Developer, End-User, and Business applications.

    Developer Use Cases

    • Smart Contract Development: Deploy contracts via plain English descriptions, build contract function callers, create ERC20 tokens, or launch NFT collections.
    • Everyday Applications: Build P2P payment apps (e.g., using MiniKit), group expense splitters, subscription managers, or donation buttons.
    • DeFi Tools: Create Morpho vault viewers, DeFi position managers, yield comparison tools, auto-compound helpers, or lending dashboards.

    End-User Use Cases

    • Personal Finance: Build crypto earning apps (using OnchainKit's Earn component), savings trackers, or spare change savers.
    • Family & Friends: Create shared family wallets, gift card senders, or chore reward systems.
    • Shopping & Payments: Implement quick checkout buttons, digital product stores, or tipping tools.
    • Community Projects: Build community fund pools, transparent charity platforms, or local event ticketing systems.

    Business Use Cases

    • Small Business Tools: Automate invoice payments, employee bonus distributions, vendor payments, or customer loyalty programs.
  2. Apply for the Base MCP Grants Program

    master

    Base provides funding, technical support, and marketing assistance for innovative projects built using Base MCP.

    Grant Categories

    • Developer Tools: Tools that simplify building on Base.
    • End-User Apps: Apps designed to onboard new users to Base.
    • Business Solutions: Projects solving real-world business problems.
    • Educational Tools: Projects helping users learn about Base.

    Application Process

    To apply, share your project on X or Warpcast and tag @buildonbase.

    Your demo should ideally include:

    1. Project description and use case.
    2. Technical approach (specifically how you leveraged Base MCP).
    3. Product roadmap and Go-To-Market (GTM) approach.

    Selection Criteria

    Proposals are evaluated based on innovation, technical feasibility, potential impact, team capability, and alignment with Base's mission.

  3. Perform basic wallet operations

    master

    Use the following tools to manage your Base wallet via Claude:

    • Get your address: Use get-address to retrieve your current Base wallet address.
    • Check balances: Use list-balances to view all current asset balances (e.g., ETH, USDC) in your wallet.
    • Request testnet ETH: Use get-testnet-eth to request ETH on the Base Sepolia testnet for development purposes.
    /* Example interactions */
    // "What's my wallet address on Base?" -> uses `get-address`
    // "Show me my wallet balances." -> uses `list-balances`
    // "I need some testnet ETH for development." -> uses `get-testnet-eth`
  4. Transfer funds and deploy contracts

    master

    Execute advanced blockchain operations using these tools:

    Transferring Funds

    Use transfer-funds to move assets between addresses.

    • destination: The recipient's wallet address.
    • assetId: The symbol of the asset (e.g., ETH).
    • amount: The quantity to transfer.

    Deploying a Smart Contract

    Use deploy-contract to deploy new contracts to the blockchain.

    • contractName: The name of the contract.
    • solidityInputJson: A JSON object containing the contract source code.
    • solidityVersion: The compiler version (e.g., 0.8.20).
    • constructorArgs: An array of arguments for the contract constructor.
    /* transfer-funds parameters */
    {
      "destination": "0x9876543210abcdef9876543210abcdef98765432",
      "assetId": "ETH",
      "amount": 0.01
    }
    
    /* deploy-contract parameters */
    {
      "contractName": "ERC20Token",
      "solidityInputJson": "...",
      "solidityVersion": "0.8.20",
      "constructorArgs": ["ExampleToken", "EXT", "1000000000000000000000000"]
    }
  5. Understand NFT data structures: NftData and FormattedNft

    master

    The library uses two primary types for representing NFT information:

    1. NftData: A flexible, raw representation of NFT data that may contain optional fields such as contract, tokenId, title, name, description, tokenType, media (an array of gateway/raw objects), image, or arbitrary metadata.

    2. FormattedNft: A standardized, flattened structure used for consistent consumption. It ensures that contractAddress, tokenId, title, description, tokenType, imageUrl, and metadata are all present and explicitly typed.

    export type NftData = {
      contract?: { address?: string };
      tokenId?: string;
      id?: { tokenId?: string };
      title?: string;
      name?: string;
      description?: string;
      tokenType?: string;
      media?: Array<{ gateway?: string; raw?: string }>;
      image?: string;
      metadata?: Record<string, unknown>;
    };
    
    export type FormattedNft = {
      contractAddress: string;
      tokenId: string;
      title: string;
      description: string;
      tokenType: string;
      imageUrl: string;
      metadata: Record<string, unknown>;
    };
  6. Run the Base MCP Server

    master

    The main function initializes and starts the Base MCP Server using the Model Context Protocol (MCP) over stdio transport. The server provides a set of tools derived from AgentKit that allow an AI agent to interact with the Base network, including Morpho, ERC20 tokens, NFTs, and on-ramp services.

    Required Environment Variables

    To run the server, you must provide the following environment variables:

    VariableDescription
    COINBASE_API_KEY_NAME or COINBASE_API_KEY_IDYour Coinbase API key name/ID
    COINBASE_API_PRIVATE_KEY or COINBASE_API_SECRETYour Coinbase API private key
    SEED_PHRASE(Required for wallet operations) The mnemonic phrase for the wallet
    CHAIN_ID(Optional) The chain ID to use. Defaults to Base. Supports Base and Base Sepolia

    Server Capabilities

    • Tools: The server exposes tools via the ListToolsRequestSchema and handles execution via CallToolRequestSchema.
    • Transport: Uses StdioServerTransport for communication.
    // To run the server, ensure environment variables are set and call main()
    import { main } from './src/main';
    
    main().catch(console.error);
  7. Initialize a new MCP server with the Base MCP CLI

    master

    The init command provides an interactive CLI wizard to set up a new Model Context Protocol (MCP) server. It automates the configuration of environment variables and client-specific settings for applications like Claude and Cursor.

    Workflow

    1. API Keys: The CLI prompts for mandatory Coinbase Developer Platform (CDP) credentials:
      • CDP Key ID: Must be a valid UUID.
      • CDP Secret: The secret associated with your CDP key.
      • Mnemonic Phrase: An optional seed phrase. If left blank, the CLI will automatically generate a new one for you.
    2. Additional Integrations: You can optionally select and configure keys for third-party tools:
      • OpenRouter (OPENROUTER_API_KEY)
      • Alchemy (NFTs) (ALCHEMY_API_KEY)
      • Flaunch (PINATA_JWT)
      • Neynar (Farcaster) (NEYNAR_API_KEY)
    3. Client Configuration: Select which MCP clients to configure (e.g., Claude, Cursor). The CLI will then write the necessary configuration files to those applications using your provided keys.
  8. Configure Base MCP for Cursor

    master

    You can configure the Base MCP server to work within the Cursor editor by updating the Cursor MCP configuration file located at ~/.cursor/mcp.json. This process adds a base server entry that runs via npx -y base-mcp@latest and injects necessary environment variables for authentication.

    To configure the server, you must provide the following credentials via the configureCursor function:

    • cdpKeyId: The Coinbase CDP Key ID.
    • cdpSecret: The Coinbase CDP Private Key.
    • mnemonicPhrase: The seed phrase for wallet access.
    • optionalKeys: An object containing additional environment variables to be passed to the MCP server.

    If a Cursor configuration already exists, the tool will prompt you before overwriting the existing base server configuration. If no configuration exists, it will create a new mcp.json file with the base server entry.

    // Example usage of the configuration logic
    await configureCursor({
      cdpKeyId: 'YOUR_CDP_KEY_ID',
      cdpSecret: 'YOUR_CDP_SECRET',
      mnemonicPhrase: 'YOUR_MNEMONIC_PHRASE',
      optionalKeys: {
        // Any additional environment variables
        CUSTOM_VAR: 'value'
      }
    });
  9. Use Onramp and Payment tools

    master

    Convert fiat to crypto or purchase credits using these tools:

    • Check Onramp Assets: Use get_onramp_assets to see which assets are available for purchase in a specific region.
      • country: The country code (e.g., US).
      • subdivision: The state/region code (e.g., NY).
    • Onramp Funds: Use onramp to generate a purchase link.
      • amountUsd: The amount in USD to spend.
      • assetId: The asset to purchase (e.g., eth).
    • Buy OpenRouter Credits: Use buy_openrouter_credits to purchase credits using USDC.
      • amountUsd: The amount in USD to spend.
    /* onramp example */
    onramp({
      "amountUsd": 100,
      "assetId": "eth"
    });
  10. Perform NFT operations

    master

    Manage NFTs on the blockchain using these tools:

    • List NFTs: Use list_nfts to find all NFTs owned by a specific address.
      • ownerAddress: The address to query.
    • Transfer an NFT: Use transfer_nft to move an NFT to a new owner.
      • contractAddress: The NFT contract address.
      • tokenId: The unique identifier of the token.
      • toAddress: The recipient's address.
      • amount: The quantity to transfer (usually 1).
    /* transfer_nft example */
    transfer_nft({
      "contractAddress": "0x3F06FcF75f45F1bb61D56D68fA7b3F32763AA15c",
      "tokenId": "56090175025510453004781233574040052668718235229192064098345825090519343038548",
      "toAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "amount": 1
    });
  11. Interact with smart contracts and ERC20 tokens

    master

    Manage contract interactions and specific token balances using these tools:

    Calling Contract Functions

    Use call_contract to execute read or write operations on any smart contract.

    • contractAddress: The address of the target contract.
    • functionName: The name of the function to call.
    • functionArgs: An array of arguments to pass to the function.
    • abi: A JSON object containing the contract's Application Binary Interface.

    Managing ERC20 Tokens

    • Check ERC20 Balance: Use erc20_balance with a contractAddress to see your balance of a specific token.
    • Transfer ERC20 Tokens: Use erc20_transfer to move specific tokens.
      • contractAddress: The address of the ERC20 token contract.
      • toAddress: The recipient's address.
      • amount: The amount to transfer.
    /* call_contract example */
    call_contract({
      "contractAddress": "0x1234567890abcdef1234567890abcdef12345678",
      "functionName": "balanceOf",
      "functionArgs": ["0x9876543210abcdef9876543210abcdef98765432"],
      "abi": { ... }
    });
    
    /* erc20_transfer example */
    erc20_transfer({
      "contractAddress": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
      "toAddress": "0x9876543210abcdef9876543210abcdef98765432",
      "amount": "10"
    });
  12. Resolve Farcaster usernames

    master

    Use the farcaster_username tool to look up the Ethereum address associated with a Farcaster username.

    • username: The Farcaster username (e.g., dwr).
    /* farcaster_username example */
    farcaster_username({
      "username": "dwr"
    });