AI代理编码服务

一个支持多种AI模型(Claude Code、Gemini和Codex)的MCP服务器,提供STDIO和HTTP两种传输模式,用于灵活的AI模型上下文管理。

  • by kadreio
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 kadreio/mcp-coding-agents

使用说明

@kadreio/mcp编码剂

一个与传输无关的MCP(模型上下文协议)服务器,集成了Claude Code、Gemini和Codex代理。支持STDIO和HTTP传输,以实现灵活的AI模型上下文管理。

特性

  • 🚀 与传输无关的架构 -业务逻辑和传输层之间的清晰分离
  • 🔄 多种运输方式 -STDIO用于直接进程通信,HTTP与SSE用于网络访问
  • 🤖 多个AI代理 -Claude Code、Gemini和Codex集成
  • 📦 内置工具 -BMI计算器、时间戳生成器、命令执行等
  • 🔧 可扩展设计 -易于添加新工具、提示和传输
  • 💬 实时流媒体 -支持HTTP模式下的通知和SSE

安装

npm install -g @kadreio/mcp-coding-agents

本地依赖关系

此软件包使用 better-sqlite3 用于会话持久性,这需要编译本机代码。在大多数系统上,预构建的二进制文件可用,安装是自动的。如果您遇到问题:

macOS/Linux:确保已安装构建工具:

# macOS
xcode-select --install

# Ubuntu/Debian
sudo apt-get install build-essential

# RHEL/CentOS
sudo yum groupinstall "Development Tools"

视窗:安装windows生成工具:

npm install --global windows-build-tools

快速开始

使用npx(无需安装)

# Default mode (HTTP on port 3050)
npx @kadreio/mcp-claude-code

# STDIO mode for direct process communication
npx @kadreio/mcp-claude-code stdio

# HTTP mode with custom port
npx @kadreio/mcp-claude-code http --port 3051

# With specific host binding
npx @kadreio/mcp-claude-code http --host 0.0.0.0

全球安装后

# Default HTTP mode
mcp-claude-code

# STDIO mode
mcp-claude-code stdio

# HTTP mode with options
mcp-claude-code http --port 3051 --no-cors

运输方式

STDIO模式

最适合编辑器集成和直接流程通信:

mcp-claude-code stdio
  • 使用JSON-RPC通过stdin/stdout进行通信
  • 无网络开销
  • 非常适合本地开发工具

HTTP模式

最适合网络访问和web集成:

mcp-claude-code http --port 3050
  • RESTful API,支持SSE流
  • 有状态交互的会话管理
  • CORS支持(可配置)
  • 健康检查终点位于 /health

可用工具

核心工具

  • calculate_bmi -计算体重指数
  • get_timestamp -获取当前时间戳
  • execute_command -执行带有超时支持的shell命令
  • stream_sse_timestamps -生成流式时间戳(HTTP模式)

AI代理工具

  • claude_code_query -使用流式响应查询Claude代码
  • gemini_query -执行Gemini CLI命令
  • codex_query -使用JSONL流执行Codex

环境变量

# Core Configuration
PORT=3050                        # HTTP server port (default: 3050)

# Claude Code Configuration
ANTHROPIC_API_KEY=sk-ant-...     # Required for Claude Code
CLAUDE_CODE_ENABLE=true          # Enable/disable Claude Code tool
CLAUDE_CODE_DEFAULT_CWD=/path    # Default working directory
CLAUDE_CODE_DEFAULT_MODEL=...    # Default Claude model
CLAUDE_CODE_MAX_MESSAGES=100     # Max messages to return
CLAUDE_CODE_EXECUTABLE_PATH=/path/to/claude  # Path to Claude executable (auto-detected if not set)

# Agent Configuration
GEMINI_API_KEY=...               # For Gemini agent
OPENAI_API_KEY=...               # For Codex agent

# Session Storage (HTTP mode)
MCP_DATABASE_PATH=/path/to/sessions.db  # Custom database location
# Default: ~/.local/share/mcp-coding-agents/sessions.db (Linux/macOS)
#          %LOCALAPPDATA%\mcp-coding-agents\sessions.db (Windows)

发展

# Clone the repository
git clone https://github.com/kadreio/mcp-claude-code.git
cd mcp-claude-code

# Install dependencies
npm install

# Build the project
npm run build

# Development mode with hot reload
npm run mcp:dev          # Default HTTP mode
npm run mcp:stdio:dev    # STDIO mode
npm run mcp:http:dev     # Explicit HTTP mode

# Run tests
npm test
npm run test:coverage

建筑

服务器使用干净的、与传输无关的架构:

CoreMCPServer (Business Logic)
       ↓
Transport Interface
    ↙     ↘
STDIO    HTTP
Transport Transport
  • CoreMCP服务器:包含所有业务逻辑、工具处理程序和代理集成
  • 传输层:适用于不同通信协议的薄型适配器
  • 统一CLI:具有运输选择的单一入口点

API端点(HTTP模式)

  • POST /mcp -JSON-RPC请求的主MCP端点
  • GET /mcp -流式通知的SSE端点
  • GET /health -健康检查端点
  • GET / -服务器信息和功能

HTTPS支持

服务器支持HTTPS进行安全通信:

快速入门(自动生成证书)

# Run with HTTPS - automatically generates a self-signed certificate
npx @kadreio/mcp-coding-agents http --https

这将自动动态生成自签名证书。非常适合发展!

使用您自己的证书

# Generate self-signed certificates
./generate-certs.sh

# Run with HTTPS using generated certificates
npx @kadreio/mcp-coding-agents http --https --cert ./certs/server.cert --key ./certs/server.key

使用自定义证书

# Run with your own certificates
npx @kadreio/mcp-coding-agents http --https \
  --cert /path/to/certificate.pem \
  --key /path/to/private-key.pem \
  --ca /path/to/ca-certificate.pem  # Optional CA certificate

HTTPS选项

  • --https -启用HTTPS模式
  • --cert <path> -SSL证书文件的路径
  • --key <path> -SSL私钥文件的路径
  • --ca <path> -SSL CA证书文件的路径(可选)

MCP客户端配置

用于STDIO模式

{
  "mcpServers": {
    "claude-code": {
      "command": "npx",
      "args": ["@kadreio/mcp-claude-code", "stdio"],
      "env": {
        "ANTHROPIC_API_KEY": "your-api-key"
      }
    }
  }
}

对于HTTP模式

{
  "mcpServers": {
    "claude-code": {
      "url": "http://localhost:3050/mcp",
      "transport": "http"
    }
  }
}

贡献

看 CLAUDE.md 了解开发指南和架构细节。

许可证

麻省理工学院

贡献

欢迎投稿!请随时提交拉取请求。

开发设置

git clone https://github.com/kadreio/mcp-coding-agents.git
cd mcp-coding-agents
npm install
npm test

释放

当您推送版本标签时,发布将通过GitHub Actions自动进行:

npm run release:patch  # 1.0.0 → 1.0.1
npm run release:minor  # 1.0.0 → 1.1.0
npm run release:major  # 1.0.0 → 2.0.0
npm run release:beta   # 1.0.0 → 1.0.1-beta.0

看 发布.md 了解详细的发布说明。