Skip to main content
Glama

qiskit-sim-mcp

Claude DesktopでQiskitおよびQiskit Aerを使用して量子回路を作成、可視化、シミュレーションできるModel Context Protocol (MCP) サーバーです。

機能

Claude Desktopに接続すると、以下のような自然な会話が可能になります。

  • 「ベル状態を作成し、1024ショットでシミュレーションして」

  • 「GHZ回路の図を見せて」

  • 「ベル状態を高いノイズ設定で実行し、何が変わったか説明して」

  • 「このQASM文字列からカスタム回路を作成して」

Claudeは自動的に基盤となるツールを呼び出すため、手動でツールを起動する必要はありません。

Related MCP server: Qiskit MCP Server

特徴

  • 3つのツール: create_circuit, visualize_circuit, run_simulation

  • 5つのプリセット回路: Bell状態, GHZ-3, 重ね合わせ, ドイッチュ・ジョサ, ランダム-4

  • カスタムQASM: 有効なOpenQASM 2.0文字列をすべて受け入れ可能

  • ノイズモデリング: 理想的、低ノイズ (p=0.001)、高ノイズ (p=0.01) を脱分極誤差でサポート

  • 1つのリソース: resource://noise-presets — 利用可能なノイズ設定をリスト化

  • 1つのプロンプト: simulate_walkthrough — ガイド付き会話テンプレート

要件

セットアップ

1. リポジトリのクローン

git clone <repo-url>
cd qiskit-sim-mcp

2. 依存関係のインストール

pip install -e .

これにより、mcp[cli]、qiskit、qiskit-aerがPython環境にインストールされます。

3. インストールの確認

python -c "
import asyncio
from quantum_mcp_demo.server import mcp

tools    = asyncio.run(mcp.list_tools())
resources = asyncio.run(mcp.list_resources())
prompts  = asyncio.run(mcp.list_prompts())

print('Tools:',     [t.name for t in tools])
print('Resources:', [r.uri  for r in resources])
print('Prompts:',   [p.name for p in prompts])
"

期待される出力:

Tools: ['create_circuit', 'visualize_circuit', 'run_simulation']
Resources: [AnyUrl('resource://noise-presets')]
Prompts: ['simulate_walkthrough']

4. MCP Inspectorでテストする (オプション)

uv run mcp dev src/quantum_mcp_demo/server.py

ブラウザで http://localhost:6274 を開きます。Claude Desktopに接続する前に、Toolsタブを使用して各ツールを手動で呼び出してみてください。

5. Claude Desktopへの接続

Claude Desktopの設定ファイルを見つけます:

OS

パス

macOS

~/Library/Application Support/Claude/claude_desktop_config.json

Windows

%APPDATA%\Claude\claude_desktop_config.json

mcpServersオブジェクト内に以下のエントリを追加します:

{
  "mcpServers": {
    "qiskit-sim-mcp": {
      "command": "/opt/anaconda3/bin/python",
      "args": [
        "-m",
        "quantum_mcp_demo.server"
      ]
    }
  }
}

注意: /opt/anaconda3/bin/python は実際のPythonパスに置き換えてください。which pythonを実行して確認できます。

6. Claude Desktopの再起動

Claude Desktopを完全に終了し(macOSではCmd+Q)、再度開きます。新しい会話で、チャット入力欄のハンマーアイコン(🔨)が表示されていれば、MCPツールが読み込まれています。

使用例

ベル状態のシミュレーション

「ベル状態の回路を作成し、図を表示して、理想的なノイズと高いノイズで1024回シミュレーションして。」

Claudeは以下を呼び出します:

  1. create_circuit(preset="bell") → circuit_idを取得

  2. visualize_circuit(circuit_id=...) → H + CNOTゲートの図を表示

  3. run_simulation(circuit_id=..., shots=1024, noise_preset="ideal") → 約50% |00⟩, 約50% |11⟩

  4. run_simulation(circuit_id=..., shots=1024, noise_preset="high_noise") → カウントが劣化し、|01⟩や|10⟩が出現

カスタムQASM回路

「この回路を実行して: OPENQASM 2.0; include "qelib1.inc"; qreg q[2]; creg c[2]; h q[0]; cx q[0],q[1]; measure q -> c;」

ClaudeはQASM文字列を解析し、同じシミュレーションパイプラインを通じて実行します。

ノイズの比較

「理想的な状態と高いノイズ環境下でのGHZ状態を比較して。ノイズは量子もつれにどのような影響を与えますか?」

プロジェクト構造

src/quantum_mcp_demo/
├── server.py              # MCP server entry point
├── circuits/
│   ├── presets.py         # 5 named preset circuits
│   └── store.py           # In-memory circuit storage (UUID-keyed)
├── tools/
│   ├── create_circuit.py  # Tool: create from preset or QASM
│   ├── visualize.py       # Tool: HTML diagram + gate JSON
│   └── simulate.py        # Tool: AerSimulator + noise modeling
├── resources/
│   └── noise_presets.py   # Resource: noise configuration list
├── prompts/
│   └── walkthrough.py     # Prompt: guided simulation conversation
└── utils/
    ├── serialization.py   # numpy → Python int conversion
    └── errors.py          # MCP error response builder

プリセット回路

プリセット

量子ビット

デモンストレーション

bell

2

量子もつれ — `

00⟩と

11⟩`で50/50に分割

ghz_3

3

多量子ビットの量子もつれ

superposition

1

アダマールゲートによる等しい重ね合わせ

deutsch_jozsa

3

量子アルゴリズム — 干渉

random_4

4

ノイズストレステスト — 固定シードのランダムゲート

ノイズプリセット

プリセット

脱分極 p

説明

ideal

なし

完璧なシミュレーション

low_noise

0.001

現実的な近未来デバイス

high_noise

0.01

強力なノイズ — 目に見える劣化

トラブルシューティング

Claude Desktopにハンマーアイコンが表示されない

  • 設定ファイルを編集した後、Claude Desktopを完全に終了して再起動してください

  • 設定JSONが有効であることを確認してください(末尾のカンマなどがないか)

  • Pythonパスを確認してください: which python

python -m quantum_mcp_demo.server が失敗する

  • プロジェクトルートから pip install -e . を実行したか確認してください

  • Pythonのバージョンを確認してください: python --version (3.13以上が必要です)

MCP Inspector実行時にポート競合が発生する

kill -9 $(lsof -t -i :6274) 2>/dev/null; kill -9 $(lsof -t -i :6277) 2>/dev/null

シミュレーションが予期しないカウントを返す

  • ショット数の不一致は自動的に検出され、isError: trueとして返されます

  • エラーが発生する場合は、shotsを減らしてみてください(例: 512)

Available Tools

3 tools
create_circuitA

Create a quantum circuit from a named preset or an OpenQASM 2.0 string. Provide exactly one of: preset (bell|ghz_3|superposition|deutsch_jozsa|random_4) or qasm.

ParametersJSON Schema
NameRequiredDescriptionDefault
presetNo
qasmNo

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry full burden. It only states 'create', which implies mutation, but does not disclose side effects, permissions, rate limits, or whether the operation is reversible. Minimal behavioral context beyond the action.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loaded with purpose, and contains no unnecessary words. Every sentence adds value, making it highly concise.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given that an output schema exists (implied), the description need not explain return values. It covers the essential parameter modes and preset list. However, it lacks error handling guidance (e.g., what happens if both or neither are provided) and interaction with sibling tools, but the description remains adequate for a simple creation tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% description coverage, so the description compensates by specifying that exactly one parameter must be provided and listing the preset options. It clarifies that qasm is an OpenQASM 2.0 string, adding semantic value. However, it does not detail the format or constraints further.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates a quantum circuit from a named preset or an OpenQASM 2.0 string, listing specific preset options. This distinguishes it from siblings (run_simulation, visualize_circuit) which perform different actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for circuit creation but does not explicitly state when to use this tool over alternatives or provide exclusions. It lacks guidance on prerequisites or context for using presets versus QASM.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

run_simulationA

Run a stored circuit on AerSimulator with optional depolarizing noise. noise_preset: ideal | low_noise | high_noise. Returns counts, probabilities, metadata.

ParametersJSON Schema
NameRequiredDescriptionDefault
circuit_idYes
shotsYes
noise_presetYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions returns (counts, probabilities, metadata) but does not state whether the operation is read-only, has side effects, or requires specific permissions. The behavior is partially transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, front-loads the core purpose, and presents noise options succinctly. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with 3 required parameters, no annotations, and an output schema, the description covers the platform and noise but omits parameter constraints and fails to distinguish output structure beyond mentioning three fields. It is adequate but not rich.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description must compensate. It explains noise_preset with enumerated values, but leaves circuit_id and shots undocumented (no hint on circuit_id source or shots default/range). Only 1 of 3 parameters gains meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool runs a stored circuit on AerSimulator with optional noise, and the verb 'Run' paired with 'stored circuit' distinguishes it from sibling tools 'create_circuit' and 'visualize_circuit'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context (run a stored circuit) and provides specific noise preset options (ideal, low_noise, high_noise), but does not explicitly exclude alternatives or state prerequisites like needing a pre-existing circuit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

visualize_circuitB

Visualize a stored circuit as HTML and a structured gate list for narration.

ParametersJSON Schema
NameRequiredDescriptionDefault
circuit_idYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

B3.4/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose behavioral traits such as whether the operation is read-only, any side effects, or prerequisites (e.g., circuit must exist). This leaves uncertainty about its safety and failure modes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no unnecessary words. It front-loads the key action and outputs.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the presence of an output schema and no annotations, the description is adequate but incomplete. It fails to specify error conditions, the format of the gate list, or prerequisite existence checks for the circuit.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter 'circuit_id' has 0% schema description coverage, and the description does not add any meaning beyond the schema's title. No guidance on what constitutes a valid circuit_id or how to obtain it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'visualize' and resource 'stored circuit', and specifies the output as HTML and a gate list for narration. This distinguishes it from siblings 'create_circuit' and 'run_simulation'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No explicit when-to-use or when-not-to-use guidance is provided. Usage is implied by the context of having a stored circuit to visualize, but alternatives like run_simulation are not differentiated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 3 tool updatesv0.1.0
    • First observedcreate_circuit
    • First observedrun_simulation
    • First observedvisualize_circuit

TDQS

A3.9/5.0

Scored across 3 tools

Disambiguation5/5

Each tool addresses a distinct phase of quantum circuit workflow: creation, simulation, and visualization. No overlap in functionality.

Naming Consistency5/5

All tools follow a consistent verb_noun convention (create_circuit, run_simulation, visualize_circuit), making their purpose immediately clear.

Tool Count4/5

Three tools cover the core lifecycle adequately. While more tools (e.g., list, delete) could be added, the current count is reasonable for a focused server.

Completeness4/5

The tools enable creating, running with noise, and visualizing circuits. Missing operations like listing or deleting circuits are minor gaps but do not severely hinder basic usage.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server exposing Qiskit quantum computing functionality through the Model Context Protocol. Enables LLMs to create, manipulate, and execute quantum circuits via standardized MCP tools and resources.
    26 PyPI
    MIT