Base Network MCP Server

MIT License
4
1
  • Apple

Integrations

  • Allows interaction with the Base blockchain network (operated by Coinbase) for performing wallet management, balance checking, and transaction execution operations.

  • Provides specific configuration paths for Claude Desktop integration on macOS systems.

基础网络 mcp 服务器

这是Base网络的MCP服务器。它允许LLM通过自然语言命令在Base网络上执行区块链操作,包括钱包管理、余额查询和交易执行。

该服务器可与 Base Mainnet 和 Base Sepolia 测试网配合使用。

工具

可以使用以下工具:

进程命令

处理基础网络操作的自然语言命令。它接受以下参数:

  • command :要处理的自然语言命令(例如,“将 0.5 ETH 发送至 0x1234...”)

它返回一个包含操作结果的结构化响应,包括发送操作的交易详细信息、余额检查的余额信息以及钱包创建的钱包详细信息。

创建钱包

在 Base 网络上创建一个新钱包。它接受以下参数:

  • name :(可选)钱包的名称

它返回一个包含钱包地址、名称和其他详细信息的对象。

检查余额

检查 Base 网络上钱包的余额。它接受以下参数:

  • wallet :(可选)要检查的钱包名称或地址(默认为主钱包)

它以 ETH 形式返回钱包余额。

列表钱包

列出所有可用的钱包。

它返回一个钱包对象数组,每个对象包含钱包地址、名称和其他详细信息。

用法

使用 Claude Desktop

Claude Desktop 是一款流行的 LLM 客户端,支持模型上下文协议 (MCP)。您可以将 Base MCP 服务器连接到 Claude Desktop,通过自然语言命令执行区块链操作。

您可以通过以下配置文件将 MCP 服务器添加到 Claude Desktop:

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

要将您的 Base MCP 服务器添加到 Claude Desktop,请将以下配置添加到配置文件中的mcpServers对象:

{ "mcpServers": { "base": { "command": "npx", "args": [ "-y", "base-network-mcp-server" ], "env": { "BASE_PROVIDER_URL": "https://api.developer.coinbase.com/rpc/v1/base/YOUR_API_KEY", "WALLET_PRIVATE_KEY": "your_private_key_here" }, "disabled": false, "autoApprove": [] } } }

配置

  • BASE_PROVIDER_URL :Base 网络提供商(Mainnet 或 Sepolia)的 URL
  • WALLET_PRIVATE_KEY :用于身份验证和交易签名的钱包私钥
  • DEFAULT_GAS_PRICE :(可选)默认 gas 价格(单位:Gwei)

以编程方式(自定义 MCP 客户端)

如果您正在构建自己的 MCP 客户端,可以使用您首选的传输方式以编程方式连接到基础 MCP 服务器。MCP SDK 提供内置的 stdio 和 SSE 传输方式。

安装

npm i base-network-mcp-server # or yarn add base-network-mcp-server # or pnpm add base-network-mcp-server

例子

以下示例使用 StreamTransport 直接连接 MCP 客户端和服务器:

import { Client } from '@modelcontextprotocol/sdk/client/index.js'; import { StreamTransport } from '@modelcontextprotocol/sdk/client/stream.js'; import { BaseMcpServer } from 'base-network-mcp-server'; // Create a stream transport for both client and server const clientTransport = new StreamTransport(); const serverTransport = new StreamTransport(); // Connect the streams together clientTransport.readable.pipeTo(serverTransport.writable); serverTransport.readable.pipeTo(clientTransport.writable); const client = new Client( { name: 'MyClient', version: '0.1.0', }, { capabilities: {}, } ); // Create and configure the Base MCP server const server = new BaseMcpServer({ providerUrl: 'https://api.developer.coinbase.com/rpc/v1/base/YOUR_API_KEY', privateKey: 'your_private_key_here', }); // Connect the client and server to their respective transports await server.connect(serverTransport); await client.connect(clientTransport); // Call tools const output = await client.callTool({ name: 'process_command', arguments: { command: 'Check my wallet balance', }, }); console.log(output); // Example output: // { // "success": true, // "message": "Balance of wallet \"default\": 1.5 ETH", // "balance": "1.5", // "wallet": "default" // }

示例命令

一旦集成,您就可以使用自然语言命令,例如:

  • “创建一个新的储蓄钱包”
  • “检查我的钱包余额”
  • “我的储蓄钱包余额是多少?”
  • “发送 0.1 ETH 到 0x1234567890123456789012345678901234567890”
  • “从我的储蓄钱包转移 0.5 ETH 到 0xABCD...”

安全注意事项

由于此实现与真实的区块链网络交互并处理私钥:

  1. 私钥安全:安全存储私钥,切勿将其提交到版本控制
  2. 优先使用测试网:先从 Base Sepolia 测试网开始,然后再迁移到主网
  3. 交易验证:发送前务必验证交易参数
  4. 错误处理:针对网络问题实施强大的错误处理
  5. 速率限制:发出频繁请求时请注意 API 速率限制

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

MCP 服务器使 LLM 能够通过自然语言命令在 Base 网络上执行区块链操作,包括钱包管理、余额检查和交易执行。

  1. Tools
    1. process_command
    2. create_wallet
    3. check_balance
    4. list_wallets
  2. Usage
    1. With Claude Desktop
    2. Configuration
    3. Programmatically (custom MCP client)
  3. Installation
    1. Example
      1. Example Commands
        1. Security Considerations
          ID: xx2sxvy29l