Repository navigation
Add SuperQuantX MCP server for AI assistants - #3
Merged
Merged
Conversation
Adds superquantx.mcp, a stdio Model Context Protocol server built on the official mcp SDK (2.x, new [mcp] extra). Entry points: the superquantx-mcp script and python -m superquantx.mcp. Tools: list_backends, backend_versions, run_circuit (OpenQASM 2/3 or JSON gate list, counts plus timing), bell_state_demo, qsvm_classify (exact fidelity kernel plus RBF baseline and kernel diagnostics) and qaoa_maxcut (brute force check). Inputs are validated and capped (env configurable under hard ceilings), errors are returned as structured JSON per backend, and only local simulators are used unless SUPERQUANTX_MCP_ALLOW_HARDWARE=1. Includes unit tests, docs/mcp.md with Claude Desktop and Cursor configs and real end to end output, an example stdio client, and skills/superquantx.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Model Context Protocol (MCP) server so AI assistants (Claude Desktop, Cursor, any MCP client) can drive SuperQuantX across backends.
[mcp]extra using the officialmcpSDK (mcp>=2.3,<3, verified with 2.3.0)superquantx-mcpandpython -m superquantx.mcplist_backends: install status, init, and a Bell smoke test per backend (working,not_installed,init_failed,execution_failed,wrong_results)backend_versions: SDK and backend version inforun_circuit: OpenQASM 2, OpenQASM 3 (safe subset) or JSON gate list; counts, probabilities, gate counts, timingbell_state_demo: same Bell circuit on several backends, per-backend errors isolatedqsvm_classify: SuperQuantXQuantumSVMwith an exact fidelity kernel from each SDK's statevectors, kernel diagnostics, and an RBF SVM baselineqaoa_maxcut: QAOA on the unified circuit API with grid search plus COBYLA, checked against brute forcedeviceneedsSUPERQUANTX_MCP_ALLOW_HARDWARE=1. Logs go to stderr.docs/mcp.md(added to mkdocs nav): install, tools, limits, Claude Desktop and Cursormcp.jsonsnippets, comparison with the IBM Qiskit MCP servers (Qiskit stack only), and real captured outputexamples/mcp_client_demo.py: stdio client that calls every toolskills/superquantx/SKILL.md: agent skill for using the server honestlyWhy the server computes its own QSVM kernel and QAOA
On 0.2.0 the backend kernels are not usable for a demo:
simulator.compute_kernel_matrixis a classical Gaussian placeholder, the Qiskit kernel returns a zero diagonal, and the PennyLane kernel ignores the feature map.superquantx.algorithms.QAOAhas random placeholder fallbacks. The server therefore builds the feature map and QAOA circuits itself and executes them through each backend, so all three backends return identical kernels and correct MaxCut results.kernel="backend"is still available and reportslooks_valid: falsewhen the backend kernel is wrong. Also,QuantumSVMtrain accuracy is computed from the precomputed kernel to avoid a double scaling issue infit.Verification
uv venvon Python 3.11.16,uv pip install ".[mcp,qiskit,pennylane]"(mcp 2.3.0, qiskit 2.6.1, qiskit-aer 0.18.2, pennylane 0.45.1).examples/mcp_client_demo.pylaunched the server over stdio both assuperquantx-mcpandpython -m superquantx.mcpand called every tool on simulator, qiskit and pennylane. All calls succeeded except the intentional 64 qubit validation check.tests/unit/test_mcp_server.py: 44 passed with qiskit, pennylane and mcp installed; 41 passed and 3 skipped with only.[dev](no mcp, qiskit or pennylane)main(braket, ocean, circuits repr, client tests), none in new coderuff checkclean on the new filesmkdocs build --stricthas the same 104 pre-existing warnings asmain;docs/mcp.mdadds noneLimitations
uv.lockis not updated in this PR