QPanda3 Runtime MCP Server
QPanda3 Runtime MCP 服务器
一个模型上下文协议 (MCP) 服务器,使 AI 助手能够通过 QPanda3 Runtime 与本源量子计算服务进行交互。
功能特性
账户管理:配置和管理本源量子云账户认证
设备管理:列出并查询可用的 QPU 设备
量子计算任务:执行采样和估计任务
批量操作:高效运行多个电路
多目标决策:用于复杂优化的 CircuitObservableBinding
任务管理:查询任务状态、获取结果、取消任务
示例电路:提供常见的量子电路示例资源
文档
文档 | 描述 |
英文文档站点 | |
中文文档站点 | |
完整的初学者指南 - 从这里开始 | |
详细的安装说明 | |
经验丰富用户的快速设置 | |
环境和客户端配置 | |
详细的功能文档 | |
自动生成的 API 文档 |
安装
一键设置(推荐)
该项目提供了自动化整个过程的设置脚本:
Linux / macOS:
git clone https://github.com/OriginQ/qpanda3-runtime-mcp-server.git
cd qpanda3-runtime-mcp-server
chmod +x scripts/setup_configure.sh
./scripts/setup_configure.shWindows (PowerShell):
git clone https://github.com/OriginQ/qpanda3-runtime-mcp-server.git
cd qpanda3-runtime-mcp-server
.\scripts\setup_configure.ps1脚本处理所有事项:依赖项设置、API 密钥配置和 MCP 客户端设置。
请参阅 安装指南 获取手动安装选项。
快速开始
# 1. Configure your API key
cp .env.example .env
# Edit .env and set QPANDA3_API_KEY=your_api_key_here
# 2. Run the server
.venv/bin/python -m qpanda3_runtime_mcp_server # Linux/macOS
# .venv\Scripts\python.exe -m qpanda3_runtime_mcp_server # Windows请参阅 配置 获取 MCP 客户端设置和高级选项。
MCP 工具
账户管理
工具 | 描述 |
| 配置本源量子云账户认证 |
| 列出已保存的账户信息(基于会话) |
| 获取当前活跃的账户信息 |
设备管理
工具 | 描述 |
| 列出所有可用的 QPU(量子处理单元)设备 |
| 获取特定 QPU 设备的详细属性 |
量子计算任务
工具 | 描述 |
| 在 QPU 设备上执行量子电路采样任务 |
| 执行量子电路的期望值估计任务 |
| 批量执行多个量子电路采样任务 |
| 使用一个可观测量批量执行多个电路的估计任务 |
多目标决策 (CircuitObservableBinding)
工具 | 描述 |
| 为多个电路和可观测量创建绑定 |
| 添加笛卡尔积组合规则(所有组合) |
| 添加一对一组合规则(配对组合) |
| 使用创建的绑定执行估计 |
| 列出所有存储的 CircuitObservableBinding 对象 |
| 删除存储的 CircuitObservableBinding 对象 |
任务管理
工具 | 描述 |
| 获取任务的执行状态 ( |
| 获取已完成任务的计算结果 |
| 取消正在运行或挂起的任务 |
| 列出用户最近的量子计算任务 |
MCP 资源
资源 URI | 描述 |
| 服务状态 |
| 贝尔态电路示例 |
| GHZ 态电路示例 |
| 随机数生成器电路 |
| 叠加态电路示例 |
示例用法
配置账户
# Auto-configure via environment variables
# Or call explicitly
await setup_origin_quantum_account_tool(
api_key="your_api_key"
)列出设备
devices = await list_qpu_devices_tool()
print(f"Available devices: {devices['total_devices']}")执行采样任务
# Bell state circuit
circuit = """QINIT 2
CREG 2
H q[0]
CNOT q[0],q[1]
MEASURE q[0],c[0]
MEASURE q[1],c[1]"""
result = await sample_tool(
circuit=circuit,
device_id="20",
shots=1000
)
task_id = result["task_id"]
# Check status and get results
status = await get_task_status_tool(task_id)
if status["task_status"] == "DONE":
results = await get_task_results_tool(task_id)
print(f"Measurement results: {results['results']}")在 AI 编码平台中配置
自动配置: 使用
./scripts/setup_configure.sh --mcp claude-desktop(或--mcp cline,--mcp cursor等)
所有客户端使用相同的配置格式(将 /path/to/... 替换为您的实际路径):
{
"mcpServers": {
"qpanda3-runtime": {
"command": "/path/to/qpanda3-runtime-mcp-server/.venv/bin/python",
"args": ["-m", "qpanda3_runtime_mcp_server"],
"cwd": "/path/to/qpanda3-runtime-mcp-server",
"env": { "QPANDA3_API_KEY": "your_api_key_here" }
}
}
}客户端 | 配置文件位置 |
Claude Code |
|
Claude Desktop | macOS: |
Cline |
|
Cursor |
|
Windsurf |
|
对于更多客户端(如 Trae 等),请参阅 配置指南。
开发
安装开发依赖
uv sync --extra dev --extra test运行测试
uv run pytest代码检查
uv run ruff check .
uv run mypy src/构建文档
# Install documentation dependencies
uv sync --extra docs
# Build documentation (English + Chinese)
./scripts/build-docs.sh
# Local preview with live reload (language switching supported)
mkdocs serve项目结构
qpanda3-runtime-mcp-server/
├── src/
│ └── qpanda3_runtime_mcp_server/
│ ├── __init__.py # Package entry point
│ ├── server.py # MCP server definition
│ ├── runtime.py # QPanda3 Runtime core logic
│ └── utils.py # Utility functions
├── scripts/
│ ├── setup_configure.sh # One-click setup (Linux/macOS)
│ ├── setup_configure.ps1 # One-click setup (Windows PowerShell)
│ ├── setup_configure.bat # One-click setup (Windows CMD)
│ ├── build-docs.sh # Build all documentation
│ └── serve-docs.sh # Serve docs with live reload
├── tests/
│ ├── __init__.py
│ ├── conftest.py # pytest configuration
│ ├── test_server.py # Server tests
│ └── test_runtime.py # Runtime tests
├── docs/
│ ├── *.md # English documentation (default)
│ └── cn/ # Chinese documentation
├── mkdocs.yml # MkDocs configuration (i18n)
├── .github/
│ └── workflows/ # GitHub Actions workflows
├── pyproject.toml # Project configuration
├── README.md # Project documentation
├── LICENSE # Apache 2.0 License
├── .env.example # Environment variable example
└── .gitignore # Git ignore file注意事项
默认服务器:服务器默认连接到
https://qpanda3-runtime.qpanda.cn。设置QPANDA3_SERVER_URL可进行覆盖。通道:服务器默认使用 qcloud 通道
异步支持:所有工具函数均为
async函数错误处理:所有函数返回包含
status字段的字典类型提示:使用 Python 类型提示以提高代码可读性
许可证
本项目采用 Apache License 2.0 许可证 - 详情请参阅 LICENSE 文件。
相关链接
贡献
详情请参阅 贡献指南。
更新日志
版本历史请参阅 更新日志。
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/OriginQ/qpanda3-runtime-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server