DP

dbillionaer/polygon-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

4 stars 5 forks 质量 53 趋势 12

Polygon blockchain MCP server for interacting with Polygon network

概览

A Model Context Protocol (MCP) server that provides seamless integration with the Polygon blockchain network. This server enables AI assistants to interact with Polygon through a standardized interface, offering comprehensive tools for wallet operations, smart contract deployment, L2 bridging, DeFi interactions, and transaction simulations. Polygon is a Layer 2 scaling solution for Ethereum that provides faster and cheaper transactions while maintaining Ethereum's security. This MCP server allows AI assistants to interact with the Polygon network, enabling a wide range of blockchain operations through a simple, standardized interface. The server acts as a bridge between AI systems and the Polygon blockchain, handling the complexities of blockchain interactions and providing a clean, easy-to-use API for common operations. - Node.js (v18 or higher) - npm or yarn - A Polygon wallet private key (for signing transactions) - RPC endpoints for Polygon Mainnet and Amoy Testnet 1.

README

以下为原文 README 节选,完整内容请查看原文。

Polygon MCP Server

A Model Context Protocol (MCP) server that provides seamless integration with the Polygon blockchain network. This server enables AI assistants to interact with Polygon through a standardized interface, offering comprehensive tools for wallet operations, smart contract deployment, L2 bridging, DeFi interactions, and transaction simulations.

Table of Contents

Introduction

Polygon is a Layer 2 scaling solution for Ethereum that provides faster and cheaper transactions while maintaining Ethereum’s security. This MCP server allows AI assistants to interact with the Polygon network, enabling a wide range of blockchain operations through a simple, standardized interface.

The server acts as a bridge between AI systems and the Polygon blockchain, handling the complexities of blockchain interactions and providing a clean, easy-to-use API for common operations.

┌─────────────┐     ┌───────────────┐     ┌─────────────────┐
│             │     │               │     │                 │
│  AI System  ├─────┤  Polygon MCP  ├─────┤  Polygon Chain  │
│             │     │    Server     │     │                 │
└─────────────┘     └───────────────┘     └─────────────────┘

Quick Start

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • A Polygon wallet private key (for signing transactions)
  • RPC endpoints for Polygon Mainnet and Amoy Testnet

Installation

  1. Clone the repository or download the source code
  2. Install dependencies:
cd polygonmcp
npm install
  1. Create a .env file with the following variables:
# Network RPC endpoints
POLYGON_MAINNET_RPC=https://polygon-rpc.com
POLYGON_AMOY_RPC=https://rpc-amoy.polygon.technology
ETHEREUM_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY  # Sepolia for Amoy's L1

# API Keys
POLYGONSCAN_API_KEY=YOUR_EXPLORER_API_KEY  # Use OKLink API key for Amoy

# Wallet (IMPORTANT: Use secure key management in production)
PRIVATE_KEY=your_private_key_here
DEFAULT_NETWORK=amoy  # Use 'amoy' for testnet

# DeFi Configuration (Optional)
DEFAULT_SLIPPAGE=0.5
DEFAULT_DEADLINE_MINUTES=20

Running the Server

Start the server:

npm start

For development with auto-restart:

npm run dev

First Steps

  1. Check your wallet balance:
    import { PolygonMCPServer } from './polygon-mcp.js';
    const server = new PolygonMCPServer();
    
    async function checkBalance() {
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "polygon": { "command": "node", "args": ["path/to/polygon-mcp.js"], "env": { "POLYGON_MAINNET_RPC": "https://polygon-rpc.com", "POLYGON_AMOY_RPC": "https://rpc-amoy.polygon.technology", "ETHEREUM_RPC_URL": "https://eth-sepolia.g.alchemy.com/v2/YOUR_ALCHEMY_KEY", "POLYGONSCAN_API_KEY": "YOUR_EXPLORER_API_KEY", "PRIVATE_KEY": "your_private_key_here", "DEFAULT_NETWORK": "amoy", "DEFAULT_SLIPPAGE": "0.5", "DEFAULT_DEADLINE_MINUTES": "20" }, "disabled": false, "autoApprove": [] } } }