xiaozhi-mcp

xiaozhi-mcp

A versatile MCP server framework that enables AI capabilities like remote control, calculations, and email operations via multiple transport types. It supports stdio, SSE, and HTTP protocols for seamless integration between language models and external systems.

Category
访问服务器

README

xiaozhi-mcp

A powerful interface for extending AI capabilities through remote control, calculations, email operations, knowledge search, and more.

About

MCP (Model Context Protocol) is a protocol that allows servers to expose tools that can be invoked by language models. This project provides a flexible framework for creating and managing MCP tools, supporting multiple transport types (stdio, SSE, HTTP) and enabling seamless integration between AI models and external systems.

Key Features:

  • 🔌 Bidirectional communication between AI and external tools
  • 🔄 Automatic reconnection with exponential backoff
  • 📊 Real-time data streaming
  • 🛠️ Easy-to-use tool creation interface
  • 🔒 Secure WebSocket communication
  • ⚙️ Multiple transport types support (stdio/sse/http)

How to Install

Using uv (Recommended)

  1. Install uv:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Install dependencies:
uv sync

Using pip

  1. Install dependencies:
pip install -r requirements.txt

Requirements:

  • Python 3.10+
  • websockets>=16.0
  • python-dotenv>=1.2.1
  • mcp>=1.25.0
  • pydantic>=2.12.5
  • mcp-proxy>=0.11.0
  • fastmcp>=2.14.3
  • httpx>=0.28.1
  • yfinance>=1.0
  • pyyaml>=6.0.3

How to Run

Run All Configured Servers

Start all enabled servers from the configuration file:

# Using uv
uv run python src/app.py

# Using pip
python src/app.py

Run a Single Server Script

Run a specific server script directly:

# Using uv
uv run python src/app.py src/mcp/tools/calculator.py

# Using pip
python src/app.py src/mcp/tools/calculator.py

Run with Docker

Using Docker Compose (Recommended)

# Copy example docker-compose file
cp docker/docker-compose.example.yml docker-compose.yml

# Start the service (from project root)
docker-compose -f docker-compose.yml up -d

# View logs
docker-compose -f docker-compose.yml logs -f

# Stop the service
docker-compose -f docker-compose.yml down

# Rebuild after code changes
docker-compose -f docker-compose.yml build && docker-compose -f docker-compose.yml up -d

Using Docker directly

# Build the image (from project root)
docker build -f docker/Dockerfile -t xiaozhi-mcp .

# Run the container
docker run -d --name xiaozhi-mcp \
  -v $(pwd)/mcp_config.yaml:/app/mcp_config.yaml:ro \
  xiaozhi-mcp

Building and Pushing Docker Images

Build and push to registry:

# Build image with version tag (from project root)
docker build -f docker/Dockerfile -t xiaozhi-mcp:1.0.0 -t xiaozhi-mcp:latest .

# Tag for registry (replace with your registry address)
docker tag xiaozhi-mcp:latest <registry>/<namespace>/xiaozhi-mcp:latest
docker tag xiaozhi-mcp:1.0.0 <registry>/<namespace>/xiaozhi-mcp:1.0.0

# Push to registry
docker push <registry>/<namespace>/xiaozhi-mcp:latest
docker push <registry>/<namespace>/xiaozhi-mcp:1.0.0

Example - Aliyun Container Registry:

# Example registry address format
REGISTRY="<your-registry>.cn-shanghai.personal.cr.aliyuncs.com"
NAMESPACE="<your-namespace>"

# Build and tag (from project root)
docker build -f docker/Dockerfile -t xiaozhi-mcp:1.0.0 -t xiaozhi-mcp:latest .
docker tag xiaozhi-mcp:latest ${REGISTRY}/${NAMESPACE}/xiaozhi-mcp:latest
docker tag xiaozhi-mcp:1.0.0 ${REGISTRY}/${NAMESPACE}/xiaozhi-mcp:1.0.0

# Push
docker push ${REGISTRY}/${NAMESPACE}/xiaozhi-mcp:latest
docker push ${REGISTRY}/${NAMESPACE}/xiaozhi-mcp:1.0.0

Using the provided script:

# Use the build-and-push.sh script (from project root)
# Script will automatically use docker/Dockerfile and docker/.env
./docker/build-and-push.sh 1.0.0

Using GitHub Actions (Recommended): The project includes a GitHub Actions workflow that automatically builds and pushes Docker images on push to main/dev branches or when tags are created. Configure secrets in your GitHub repository settings. See .github/workflows/README.md for details.

For more Docker build and push options, see docs/DOCKER_BUILD_PUSH.md.

For more Docker deployment options, see docs/DEPLOYMENT.md.

Configs

Configuration files use YAML format:

  • mcp_config.yaml - Main configuration file

Configuration Structure

Edit mcp_config.yaml to configure your MCP endpoint and servers:

mcp:
  endpoint: ws://your-endpoint-url/mcp
  token: your-token-here  # Optional
  
  servers:
    local-stdio-calculator:
      enabled: true
      type: stdio
      command: python
      args:
        - src/mcp/tools/calculator.py

For detailed configuration examples, see docs/CONFIG.md.

Config Loading Priority

  1. MCP_CONFIG environment variable (if set, used directly - backward compatibility)
  2. mcp_config.yaml (default configuration file)
  3. mcp_config.json (fallback, backward compatibility)

Thanks To

  • Thanks to all contributors who have helped shape this project
  • Inspired by the need for extensible AI capabilities
  • Built on top of the MCP (Model Context Protocol) specification

License

This project is licensed under the MIT License - see the LICENSE file for details.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选