Solana Model Context Protocol (MCP) Server

by omaidf
Verified
MIT License
5
  • Linux
  • Apple

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

  • Offers containerized deployment options through Docker and Docker Compose, allowing for simple setup and consistent running environments across different systems.

  • Enables repository access for installation, with the codebase hosted on GitHub for distribution and contribution.

  • Built with Python and requires Python 3.9+ for development and local execution, with Python client examples provided for integration.

Solana 模型上下文协议 (MCP)

一个全面的 Solana 区块链交互服务器,实现了模型上下文协议 (MCP),并针对与 AI 工具和接口的无缝集成进行了优化。

什么是模型上下文协议?

模型上下文协议 (MCP) 为 AI 工具和语言模型与区块链数据交互提供了一种标准化的方式。此实现允许 AI 代理:

  • 使用自然语言查询 Solana 区块链数据
  • 访问结构化令牌和帐户信息
  • 在多个交互中保持上下文
  • 跨区块链交易执行语义搜索
  • 生成复杂区块链数据的人类可读解释

为什么 MCP 适合 AI 集成?

MCP 在 AI 代理和区块链数据之间建立了一座桥梁,从而实现:

  • 语境理解:人工智能模型可以保存对话历史并构建有关代币和账户的语境
  • 语义查询:支持自然语言处理,将用户查询转化为区块链操作
  • 结构化响应:数据以针对 AI 消费优化的标准化格式返回
  • 增强解释:用通俗易懂的语言解释复杂的区块链概念

特征

  • 自然语言处理:使用日常语言查询区块链数据
  • 代币分析:全面的代币信息和指标
  • 语义搜索:根据含义查找交易和活动,而不仅仅是精确匹配
  • 上下文感知:服务器维护会话状态并了解实体关系
  • Solana RPC 集成:完全访问 Solana 区块链功能
  • RESTful API :轻松与现有系统集成
  • Docker 支持:通过容器化实现简单部署

Docker 快速入门

选项 1:使用 Docker Compose

# Clone the repository git clone https://github.com/omaidf/solana-mcp.git cd solana-mcp # Build and start the container docker-compose up -d

选项 2:直接使用 Docker

# Build the Docker image docker build -t solana-mcp . # Run the container docker run -p 8000:8000 solana-mcp

环境变量

通过设置以下环境变量来定制服务器:

SOLANA_RPC_URL=https://api.mainnet-beta.solana.com SOLANA_COMMITMENT=confirmed SOLANA_TIMEOUT=30 HOST=0.0.0.0 PORT=8000 LOG_LEVEL=INFO LOG_FORMAT=json ENVIRONMENT=production METADATA_CACHE_SIZE=100 METADATA_CACHE_TTL=300 PRICE_CACHE_SIZE=500 PRICE_CACHE_TTL=60

API 端点

核心 MCP 端点

  • GET /health - 健康检查端点
  • GET /version - 获取 API 版本信息

Solana代币分析

  • GET /token-analysis/analyze/{mint} - 获取全面的 token 分析
  • GET /token-analysis/metadata/{mint} - 获取令牌元数据
  • GET /token-analysis/supply/{mint} - 获取代币供应信息
  • GET /token-analysis/price/{mint} - 获取代币价格信息
  • GET /token-analysis/holders/{mint} - 获取代币持有者信息

自然语言查询

  • POST /nlp/query - 提交有关 Solana 区块链的自然语言查询

请参阅API_DOCUMENTATION.md以获取完整的 API 文档。

发展

先决条件

  • Python 3.9+
  • 点子

设置

# Create and activate virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install dependencies pip install -e .

本地运行

python -m solana_mcp.main

该服务器将在http://localhost:8000上可用。

MCP 集成示例

Python

import httpx import asyncio async def get_token_analysis(mint_address): async with httpx.AsyncClient() as client: response = await client.get(f"http://localhost:8000/token-analysis/analyze/{mint_address}") if response.status_code == 200: return response.json() else: raise Exception(f"Error: {response.status_code} - {response.json().get('detail')}") # Example usage async def main(): try: token_data = await get_token_analysis("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v") print(f"Token name: {token_data['token_name']}") print(f"Current price: ${token_data['current_price_usd']}") except Exception as e: print(f"Failed to get token data: {e}") if __name__ == "__main__": asyncio.run(main())

执照

有关详细信息,请参阅 LICENSE 文件。

贡献

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

作者

创建者: omaidf

-
security - not tested
A
license - permissive license
-
quality - not tested

Solana 区块链交互服务器允许 AI 工具使用自然语言查询区块链数据、访问结构化令牌信息并生成复杂区块链概念的人类可读解释。

  1. What is Model Context Protocol?
    1. Why MCP for AI Integration?
      1. Features
        1. Quick Start with Docker
          1. Option 1: Using Docker Compose
          2. Option 2: Using Docker directly
        2. Environment Variables
          1. API Endpoints
            1. Core MCP Endpoints
            2. Solana Token Analysis
            3. Natural Language Queries
          2. Development
            1. Prerequisites
            2. Setup
            3. Running locally
          3. MCP Integration Examples
            1. Python
          4. License
            1. Contributing
              1. Author
                ID: 2xuxi3ody7