BSC MCP Server

by ArcReactor9
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Provides tools for interacting with the Binance Smart Chain network, allowing access to blockchain data including block details, transaction information, wallet balances, BEP-20 token balances, and the ability to create Four.meme tokens on BSC.

  • Serves as the runtime environment for the MCP server, enabling server-side JavaScript execution for blockchain interactions and API requests to the BSC network.

BSC MCP 服务器

用于与币安智能链 (BSC) 网络交互的模型上下文协议 (MCP) 服务器。该服务器使 LLM 能够访问区块链数据并在 BSC 网络上执行查询。

特征

  • 获取当前区块号
  • 通过数字或哈希检索区块详细信息
  • 获取交易详情
  • 获取交易收据
  • 查看钱包BNB余额
  • 检查 BEP-20 代币余额
  • 在 BSC 上创建 Four.meme 代币

先决条件

  • Node.js(v16 或更高版本)
  • npm 或 yarn

安装

# Clone the repository git clone https://github.com/ArcReactor9/BSC_MCP_SERVICES.git cd BSC_MCP_SERVICES # Install dependencies npm install # Build the project npm run build

用法

配置

默认情况下,服务器连接到 BSC 主网。您可以使用环境变量自定义 RPC URL 并设置私钥(创建代币所需):

# Windows set BSC_RPC_URL=https://your-custom-bsc-rpc-url set BSC_PRIVATE_KEY=your-private-key # Linux/macOS export BSC_RPC_URL=https://your-custom-bsc-rpc-url export BSC_PRIVATE_KEY=your-private-key

运行 STDIO 服务器

STDIO 服务器设计为与支持 MCP 协议的 LLM 客户端集成:

npm run start # or node dist/index.js

运行 HTTP/SSE 服务器

HTTP/SSE 服务器允许使用服务器发送事件通过 HTTP 进行连接:

npm run start:http # or node dist/server-http.js

默认情况下,服务器在端口 3000 上运行。您可以使用PORT环境变量自定义端口。

客户端示例

提供了几个客户端实现来演示如何使用 BSC MCP 服务器:

# Standard MCP client example npm run client # or node dist/client-example.js # HTTP client example npm run client:http # or node dist/client-http-example.js # Simple HTTP client example npm run client:simple # or node dist/simple-http-client.js

API 端点(HTTP 服务器)

HTTP 服务器公开以下端点:

端点方法描述
/得到服务器状态检查
/mcp/hello邮政获取服务器信息和可用工具
/mcp/tools/:toolName邮政使用参数调用特定工具
/mcp/sse得到用于流连接的服务器发送事件 (SSE) 端点

MCP 工具

该服务器公开以下 MCP 工具:

工具名称参数描述
get-block-number没有任何返回当前 BSC 区块号
get-blockblockHashOrNumber :字符串或数字返回给定块哈希或数字的块详细信息
get-transactiontxHash : 字符串返回给定交易哈希的交易详情
get-transaction-receipttxHash : 字符串返回给定交易哈希的交易收据
get-balanceaddress :字符串返回指定钱包地址的 BNB 余额
get-token-balancetokenAddress :字符串, walletAddress :字符串返回给定代币和钱包地址的 BEP-20 代币余额
create-four-meme-tokenname :字符串, symbol :字符串, initialSupply :数字, decimals :数字, ownerAddress :字符串使用指定参数创建一个新的 Four.meme 令牌

创建 Four.meme 代币

BSC MCP 服务器包含在币安智能链上创建新 Four.meme 代币的功能。这使得用户能够使用以下参数轻松部署自定义 meme 代币:

  • name :代币的全名(例如,“Four Meme Token”)
  • symbol :代币符号(例如“4MEME”)
  • initialSupply :初始代币供应量
  • decimals :令牌的小数位数(通常为 18 位)
  • ownerAddress :接收初始代币供应的 BSC 地址

使用 HTTP 客户端的示例

// Example of creating a Four.meme token using the HTTP client const client = new SimpleHttpClient('http://localhost:3000'); // Create a Four.meme token const tokenResponse = await client.createFourMemeToken( 'Four Pepe', // Token name '4PEPE', // Token symbol 420690000000, // Initial supply (before decimals) 18, // Decimals '0xYourWalletAddress' // Owner address ); console.log('Token creation response:', tokenResponse);

与 MCP.so 集成

要在mcp.so上正确显示此服务,请确保您的存储库包含以下内容:

  1. 一份记录详尽的 README.md(此文件)
  2. 演示如何使用该工具的代码示例
  3. 明确定义的工具规格

发展

项目结构

BSC_MCP_SERVICES/ ├── dist/ # Compiled JavaScript files ├── src/ # TypeScript source code │ ├── bsc-service.ts # BSC interaction service │ ├── index.ts # STDIO server implementation │ ├── server-http.ts # HTTP/SSE server implementation │ └── ... # Client examples and utilities ├── package.json # Project dependencies and scripts └── README.md # Project documentation (this file)

构建项目

npm run build

执照

国际学习中心

贡献

欢迎贡献代码!欢迎提交 Pull 请求。

故障排除

代币创建问题

  • 确保BSC_PRIVATE_KEY环境变量设置正确
  • 确认您有足够的 BNB 来支付代币部署的 gas 费用
  • 检查所有者地址是否为有效的 BSC 地址

连接问题

  • 验证 RPC URL 是否正确且可访问
  • 检查网络连接
  • 确保服务器在预期端口上运行

支持

如有任何疑问或需要支持,请在 GitHub 存储库上打开问题

ID: 0tuq5x909h