Qiskit MCP Server

io.github.Qiskit由 GitHub 帳號 Qiskit 發布v0.3.2更新於 Oct 24, 2026

MCP server for Qiskit quantum computing with circuit serialization utilities

已驗證STDIO僅桌面開發者工具AI 與機器學習

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理對 Qiskit 量子電路進行轉譯、分析,並轉換成面向硬體的格式。

可以做什麼
  • 依可設定的最佳化等級、基礎閘預設集與耦合圖拓撲轉譯量子電路
  • 在不轉譯的情況下分析電路結構、閘數量與深度
  • 比較 0 至 3 各最佳化等級的結果
  • 從 OpenQASM 2.0/3.0 載入電路,並在 QASM 與 base64 編碼的 QPY 之間匯出或轉換
  • 讀取關於轉譯器能力、基礎閘與拓撲的參考資源
適用情境
適合處理量子電路與 Qiskit 的情境:為特定硬體目標最佳化電路、檢視電路深度與閘組成,或在執行前挑選合適的最佳化等級。
執行需求
以 Python 套件(qiskit-mcp-server,透過 uvx 或 uv run 啟動)在本機以 stdio 執行;需要 Python 3.10 以上版本,以及 uv 套件管理員或 pip。未宣告帳號、API 金鑰或標頭。選用環境變數 QISKIT_MCP_MAX_QUBITS 與 QISKIT_MCP_MAX_GATES 可提高預設的 100 量子位元與 10,000 閘上限。
安裝前請注意
不涉及憑證或付費。轉譯僅為本機運算,不會向量子硬體提交工作,但等級 3 最佳化在較大電路上可能非常慢;超過量子位元或閘數上限的電路會被拒絕,除非調高對應的上限變數。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Qiskit MCP Server,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

Qiskit MCP Server

[MCP Registry]

A Model Context Protocol (MCP) server that provides quantum circuit transpilation capabilities using Qiskit's pass managers. This server enables AI assistants to optimize quantum circuits for various hardware targets.

Features

  • Circuit Transpilation: Transpile quantum circuits with configurable optimization levels (0-3)
  • Preset Basis Gates: Support for IBM Eagle, IBM Heron, ion trap, and other basis gate sets
  • Topology Support: Built-in support for linear, ring, grid, and custom coupling maps
  • Circuit Analysis: Analyze circuit complexity without transpilation
  • Optimization Comparison: Compare results across all optimization levels
  • Dual API: Supports both async (MCP) and sync (Jupyter, scripts) usage

Prerequisites

  • Python 3.10 or higher
  • uv package manager (recommended) or pip

Installation

From PyPI (when published)

bash
pip install qiskit-mcp-server

From Source

bash
# Clone the repositorygit clone https://github.com/Qiskit/mcp-servers.gitcd mcp-servers/qiskit-mcp-server
# Install with uvuv sync
# Or with pippip install -e .

Quick Start

Running the MCP Server

bash
# With uvuv run qiskit-mcp-server
# Or directlyqiskit-mcp-server

Claude Desktop Configuration

Add to your Claude Desktop configuration (claude_desktop_config.json):

json
{  "mcpServers": {    "qiskit": {      "command": "uv",      "args": [        "--directory",        "/path/to/qiskit-mcp-servers/qiskit-mcp-server",        "run",        "qiskit-mcp-server"      ]    }  }}

Usage Examples

Async Usage (MCP Server / FastAPI)

python
from qiskit_mcp_server.transpiler import transpile_circuit
# Simple Bell state circuit (QASM2 - automatically detected)qasm = """OPENQASM 2.0;include "qelib1.inc";qreg q[2];creg c[2];h q[0];cx q[0], q[1];measure q -> c;"""
# Transpile with default settings (optimization level 2, QASM3 format)result = await transpile_circuit(qasm)
# Transpile for IBM Heron processorresult = await transpile_circuit(    qasm,    optimization_level=3,    basis_gates="ibm_heron",    coupling_map="linear")

Using QPY Format

python
from qiskit import QuantumCircuitfrom qiskit_mcp_server import dump_qpy_circuitfrom qiskit_mcp_server.transpiler import transpile_circuit
# Create a circuit programmaticallyqc = QuantumCircuit(2, 2)qc.h(0)qc.cx(0, 1)qc.measure([0, 1], [0, 1])
# Convert to QPY (preserves exact parameters and metadata)qpy_circuit = dump_qpy_circuit(qc)
# Transpile using QPY formatresult = await transpile_circuit(qpy_circuit, circuit_format="qpy")# Result includes transpiled circuit in QPY format (for chaining)transpiled_qpy = result["transpiled_circuit"]["circuit_qpy"]
# Chain to another operation using QPYresult2 = await transpile_circuit(transpiled_qpy, circuit_format="qpy", optimization_level=3)

Sync Usage (Scripts, Jupyter)

python
from qiskit_mcp_server.transpiler import transpile_circuit, analyze_circuit
# All async functions have a .sync attributeresult = transpile_circuit.sync(qasm, optimization_level=2)
# Analyze circuit without transpilinganalysis = analyze_circuit.sync(qasm)print(f"Circuit depth: {analysis['circuit_info']['depth']}")print(f"Two-qubit gates: {analysis['gate_categories']['two_qubit_gates']}")

Compare Optimization Levels

python
from qiskit_mcp_server.transpiler import compare_optimization_levels
# Compare all optimization levels (0-3) for your circuitcomparison = compare_optimization_levels.sync(qasm)
for level in range(4):    result = comparison['optimization_results'][f'level_{level}']    print(f"Level {level}: depth={result['depth']}, size={result['size']}")

LangChain Integration Example:

Note: To run LangChain examples you will need to install the dependencies:

bash
pip install langchain langchain-mcp-adapters langchain-openai python-dotenv
python
import asyncioimport osfrom langchain.agents import create_agentfrom langchain_mcp_adapters.client import MultiServerMCPClientfrom langchain_mcp_adapters.tools import load_mcp_toolsfrom langchain_openai import ChatOpenAIfrom dotenv import load_dotenv
# Load environment variables (OPENAI_API_KEY, etc.)load_dotenv()
# Sample Bell state circuitSAMPLE_BELL = """OPENQASM 3.0;include "stdgates.inc";qubit[2] q;h q[0];cx q[0], q[1];"""
async def main():    # Configure MCP client    mcp_client = MultiServerMCPClient({        "qiskit": {            "transport": "stdio",            "command": "qiskit-mcp-server",            "args": [],            "env": {},        }    })
    # Use persistent session for efficient tool calls    async with mcp_client.session("qiskit") as session:        tools = await load_mcp_tools(session)
        # Create agent with LLM        llm = ChatOpenAI(model="gpt-5.2", temperature=0)        agent = create_agent(llm, tools)
        # Run a query        response = await agent.ainvoke(f"Transpile this circuit for IBM Heron: {SAMPLE_BELL}")        print(response)
asyncio.run(main())

For more LLM providers (Anthropic, Google, Ollama, Watsonx) and detailed examples including Jupyter notebooks, see the examples/ directory.

API Reference

Tools

ToolDescription
transpile_circuit_toolTranspile a circuit with configurable optimization
analyze_circuit_toolAnalyze circuit structure without transpiling
compare_optimization_levels_toolCompare all optimization levels (0-3)
load_circuit_from_qasm_toolLoad a circuit from OpenQASM 2.0 or 3.0 string, returning QPY and metadata
export_circuit_to_qasm_toolExport a QPY circuit to OpenQASM 2.0 or 3.0 format
convert_qpy_to_qasm3_toolConvert a base64-encoded QPY circuit to QASM3
convert_qasm3_to_qpy_toolConvert a QASM3 (or QASM2) circuit to base64-encoded QPY

Resources

Resource URIDescription
qiskit://transpiler/infoTranspiler capabilities and documentation
qiskit://transpiler/basis-gatesAvailable basis gate presets
qiskit://transpiler/topologiesAvailable coupling map topologies

Core Functions

transpile_circuit(circuit, optimization_level=2, basis_gates=None, coupling_map=None, initial_layout=None, seed_transpiler=None, circuit_format="qasm3")

Transpile a quantum circuit using Qiskit's preset pass managers.

Parameters:

  • circuit: Quantum circuit as QASM3 string, base64-encoded QPY, or QASM2 string (max 100 qubits, 10,000 gates)
  • optimization_level: 0-3 (default: 2)
    • 0: No optimization, only basis gate decomposition (fastest)
    • 1: Light optimization with default layout
    • 2: Medium optimization with noise-aware layout (recommended)
    • 3: Heavy optimization for best results (can be slow for large circuits)
  • basis_gates: List of gate names or preset ("ibm_default", "ibm_heron", etc.)
  • coupling_map: List of edges or topology name ("linear", "ring", "grid", "full")
  • initial_layout: List of physical qubit indices (length must match circuit qubits)
  • seed_transpiler: Random seed for reproducibility
  • circuit_format: Format of the input circuit ("qasm3" or "qpy"). Defaults to "qasm3". When "qasm3" is specified, QASM2 is also accepted as a fallback.

Returns: Dictionary with original/transpiled circuit info and optimization metrics

Note: Level 3 optimization can be very slow for circuits with >20 qubits or >500 gates. Use level 2 for faster results with good quality.

analyze_circuit(circuit, circuit_format="qasm3")

Analyze circuit structure and complexity.

Returns: Dictionary with gate counts, depth, and categorization (single/two/multi-qubit gates)

compare_optimization_levels(circuit, circuit_format="qasm3")

Compare transpilation results across all optimization levels.

Returns: Dictionary comparing depth, size, and gates for levels 0-3

Circuit Format Support

The server supports two circuit formats for input:

FormatDescription
qasm3OpenQASM 3.0 string (with QASM2 fallback). Human-readable text format.
qpyBase64-encoded QPY binary format. Preserves exact parameters and metadata.

QPY output: All tools return circuits in QPY format (base64-encoded) for precision when chaining tools/servers.

When to use each format:

  • QASM3 (input): Best for human-readable circuits and initial input
  • QPY (input/output): Best for preserving exact numerical parameters when chaining tools/servers

Converting QPY to Human-Readable QASM3

To view a QPY circuit output in human-readable format, use the qpy_to_qasm3 utility:

python
from qiskit_mcp_server import qpy_to_qasm3from qiskit_mcp_server.transpiler import transpile_circuit
# Transpile a circuit (returns QPY format)result = transpile_circuit.sync(qasm_circuit, optimization_level=2)qpy_output = result["transpiled_circuit"]["circuit_qpy"]
# Convert to human-readable QASM3conversion = qpy_to_qasm3(qpy_output)if conversion["status"] == "success":    print(conversion["qasm3"])

Converting QASM3 to QPY

To convert a QASM circuit to QPY format (for full fidelity when chaining tools), use qasm3_to_qpy:

python
from qiskit_mcp_server import qasm3_to_qpy
qasm_circuit = '''OPENQASM 3.0;include "stdgates.inc";qubit[2] q;h q[0];cx q[0], q[1];'''
# Convert to QPY formatresult = qasm3_to_qpy(qasm_circuit)if result["status"] == "success":    qpy_string = result["circuit_qpy"]    # Use qpy_string with tools that accept QPY input

Available Basis Gate Sets

PresetGatesDescription
ibm_eagleid, rz, sx, x, ecr, resetIBM Eagle r3 (127 qubits, uses ECR)
ibm_heronid, rz, sx, x, cz, resetIBM Heron (133-156 qubits, uses CZ)
ibm_legacyid, rz, sx, x, cx, resetOlder IBM systems (uses CX)

You can also provide a custom list of gate names for other hardware targets.

Available Topologies

TopologyDescription
linearChain connectivity (qubit i ↔ i+1)
ringLinear with wraparound
grid2D grid connectivity
heavy_hexIBM heavy-hex topology (Eagle/Heron architecture)
fullAll-to-all connectivity

Limits and Performance

Circuit Size Limits

To ensure reliable performance, the server enforces the following limits:

LimitDefaultEnvironment Variable
Maximum qubits100QISKIT_MCP_MAX_QUBITS
Maximum gates10,000QISKIT_MCP_MAX_GATES

Circuits exceeding these limits will return an error with a descriptive message.

You can override these limits via environment variables:

bash
# Allow up to 200 qubits and 50,000 gatesexport QISKIT_MCP_MAX_QUBITS=200export QISKIT_MCP_MAX_GATES=50000

Performance Recommendations

Optimization LevelUse CasePerformance
0Quick iterations, debuggingFastest
1Development, prototypingFast
2Production use (recommended)Balanced
3Critical applications, small circuitsSlowest

Tips:

  • Use level 2 for most use cases (best balance of quality and speed)
  • Use level 3 only when circuit quality is critical AND circuit is small (<20 qubits, <500 gates)
  • Use level 0 or 1 for rapid prototyping and development
  • The compare_optimization_levels tool helps identify the best level for your specific circuit

Transpilation Stages

The Qiskit transpiler processes circuits through six stages:

  1. init: Decompose multi-qubit gates to 1 and 2-qubit operations
  2. layout: Map virtual qubits to physical qubits
  3. routing: Insert SWAP gates for hardware connectivity
  4. translation: Convert to target basis gates
  5. optimization: Reduce gate count and circuit depth
  6. scheduling: Add timing and delay instructions

Testing

bash
# Run all testsuv run pytest tests/ -v
# Run with coverageuv run pytest tests/ --cov=src --cov-report=term-missing
# Run specific test classuv run pytest tests/test_transpiler.py::TestTranspileCircuit -v

Development

bash
# Install dev dependenciesuv sync --group dev --group test
# Run lintinguv run ruff check src testsuv run ruff format --check src tests
# Run type checkinguv run mypy src
# Run all checks./run_tests.sh

Contributing

Contributions are welcome! Please see the CONTRIBUTING.md guide in the root of the repository.

License

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

來源:qiskit-mcp-server/README.md,提交 373be19

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

2
  1. v0.3.2最新Oct 8, 2026
  2. v0.3.1Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分