
qasmguard
io.github.raydeoliveira/qasmguard
Free OpenQASM lint, profile, sim & Pauli grouping. Metered equiv, routing & FTQC.
Documentation
Qasmguard
Qasmguard lints and profiles OpenQASM 2.0/3.0 circuits, runs exact dense statevector (<= 12 qubits) and bit-packed Clifford stabilizer (<= 256 qubits) simulations, groups VQE/QAOA Pauli Hamiltonians, verifies circuit equivalence and qubit-endianness reversals, routes SWAPs onto hardware coupling maps, and estimates fault-tolerant surface-code resources. Version 0.1.0; changes are listed in CHANGELOG.md.
Quick Start
Try Qasmguard on Apify. Run the prefilled 2-qubit OpenQASM 2.0 Bell circuit lint sample, then open the default dataset. The single row reports data.valid as true, data.qubits as 2, data.gateCount as 2, and data.summary.errors as 0. This example uses zero paid Actor events.
Simulate a 2-qubit Bell circuit and evaluate ZZ and XX Pauli expectations (seed: 42, shots: 1024). This free hosted call needs only curl.
curl -sS https://qasmguard-mcp.raymond-deoliveira.workers.dev/mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"q_simulate","arguments":{"qasm":"OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0],q[1];\nmeasure q -> c;\n","shots":1024,"seed":42,"observables":["ZZ","XX"]}}}'
Under result.structuredContent, q_simulate returns backend: "statevector", counts: {"11": 530, "00": 494}, measurementOrder: "q0_lsb", and expectation values ZZ: 1 (1.0000000000000002) and XX: 1 (1.0000000000000002). To keep the example handy, star Qasmguard on GitHub.
Group an H2 STO-3G Hamiltonian with Pauli coloring
Send the 5-term 2-qubit H2 STO-3G Hamiltonian (IZ, ZI, ZZ, XX, YY) to q_pauli_group with General Commuting (gc) grouping:
curl -fsS --max-time 15 https://qasmguard-mcp.raymond-deoliveira.workers.dev/mcp \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"q_pauli_group","arguments":{"terms":[{"pauli":"IZ","coeff":0.39793742484318045},{"pauli":"ZI","coeff":-0.39793742484318045},{"pauli":"ZZ","coeff":-0.01128010425623538},{"pauli":"XX","coeff":0.09046559989211578},{"pauli":"YY","coeff":0.09046559989211578}],"strategy":"gc","totalShots":1000}}}'
IZ, ZI, ZZ commute qubitwise and XX, YY commute together, reducing 5 separate measurement circuits to 2 commuting groups with Neyman variance-optimal shot allocation.
What a two-cent FTQC estimate returns
For a 100-logical-qubit circuit with 1,000,000 T-gates (tDepth: 10000, measurementCount: 100) targeting 1% total algorithm failure (targetTotalError: 0.01) on willow-superconducting (Lambda = 2.14, p = 0.0014, 15-to-1-distillation), q_ftqc_estimate (fixtures/ftqc_willow_100q.json) computes:
| Calculated result | Value |
|---|---|
Surface-code distance (codeDistance) | 53 |
Total physical qubits (totalPhysicalQubits) | 104,466,710 |
Magic-state factories (factoryCount) | 595 |
Estimated runtime (estimatedRuntimeSeconds) | 0.58883 s |
Achieved total error (achievedTotalError) | 0.002920 |
To reproduce the calculation locally via CLI (qasmguard ftqc --input fixtures/ftqc_willow_100q.json --json) or via metered MCP q_ftqc_estimate ($0.02/call via x402 or Polar key once provisioned), pass these exact JSON arguments:
{"logicalQubits":100,"tCount":1000000,"tDepth":10000,"measurementCount":100,"hardwareProfile":"willow-superconducting","factoryType":"15-to-1-distillation"}
What It Does / What It Does Not Do
| Surface / Tool | Tier / Price | What It Does |
|---|---|---|
q_lint_qasm / qasmguard lint | Free ($0) | OpenQASM 2.0/3.0 lexer, AST parser, and 15 static preflight checks (register bounds, duplicate qubits, gate arity, expression div-by-zero, recursive gates, q0_lsb endianness hint) |
q_profile_circuit / qasmguard profile | Free ($0) | DAG critical-path depth, gate histogram, Clifford+T counts and T-depth, and NISQ survival fidelity for willow-105, sycamore-54, ibm-heron-133, ionq-forte |
q_simulate / qasmguard simulate | Free ($0) | Exact Float64Array dense statevector (<= 12 qubits) and bit-packed CHP Clifford stabilizer (<= 256 qubits) simulation, Mulberry32 seeded shots (<= 100,000), and Pauli expectation values (<= 64) |
q_pauli_group / qasmguard pauli-group | Free ($0) | Symplectic Pauli parser (<= 2,048 terms), QWC and General Commuting graph coloring, and Neyman variance-optimal shot allocation |
q_equivalence_check / qasmguard equiv | Metered ($0.005) | Exact unitary (<= 6Q) and multi-probe statevector/stabilizer (<= 12Q non-Clifford, <= 256Q Clifford) equivalence check with global-phase and endianness_reversed diagnostics |
q_transpile_route / qasmguard route | Metered ($0.01) | Deterministic bidirectional heuristic SWAP router for willow-105, sycamore-54, ibm-heron-133, ionq-forte, line, ring, and customEdges |
q_ftqc_estimate / qasmguard ftqc | Metered ($0.02) | Willow/Qualtran (Lambda=2.14, 1.1 us), optimistic-superconducting, trapped-ion, and neutral-atom surface-code distance, 15-to-1-distillation / cultivation factory sizing, runtime, and Pareto trade-off sweep |
HTTP 402 MCP & stdio MCP | MCP 2025-03-26 | Cloudflare Worker at https://qasmguard-mcp.raymond-deoliveira.workers.dev/mcp (GET/HEAD /health, /llms.txt, /.well-known/mcp/server-card.json, POST /mcp with 1..64 JSON-RPC batches, Free, Bearer, Polar /validate, deferred x402 v2 /verify+/settle) plus serve-mcp --stdio |
| Apify Actor & Standby MCP | PPE / Standby | Single ({ tool, arguments }) and batch ({ calls }) Dataset/OUTPUT runs plus Standby HTTP /mcp with readiness probe and Pay-Per-Event charging |
What It Does Not Do:
- No physical QPU hardware drivers, pulse-level scheduling, or paid IBM/Braket/Google cloud quantum credentials (
$0Day 1 stateless compute only). - No remote QASM URL fetching (inline bounded payloads only;
<= 262,144bytes per payload). - Statevector simulation is strictly bounded to
<= 12qubits (4,096amplitudes); Clifford stabilizer simulation is bounded to<= 256qubits.
Install & Uninstall
Use the hosted endpoint with curl or any MCP client. The public GitHub repository contains documentation, skill metadata, and packaging manifests. The local CLI and tests require a source checkout.
The source checkout requires Node.js >= 22.18.0 for native TypeScript type stripping (0 runtime and 0 dev npm dependencies, 361,765 bytes / 353.3 KiB source across 42 TypeScript files and 7,692 lines in src/, 432 KB src/ on disk, 1,080 KB project total via du -sk):
node --test tests/*.test.ts
node --test e2e/*.test.ts
Measured runs on node v25.9.0 (macOS):
- Unit & integration (
node --test tests/*.test.ts):160tests across45suites in23test files (160pass,0fail,0skipped). - End-to-end (
node --test e2e/*.test.ts):141tests across17test files (141pass,0fail,0skipped). - Total:
301tests (301pass,0fail). - Representative CLI latency (median of
5runs after1warm-up onnode v25.9.0):166.3 ms(simulate --qasm-file fixtures/bell_qasm2.qasm --shots 1024 --seed 42 --observables ZZ,XX --json, range156.6–168.0 ms),162.9 ms(ftqc --input fixtures/ftqc_willow_100q.json --json, range153.7–164.3 ms).
Install the agent skill reference from GitHub:
npx skills add raydeoliveira/qasmguard
Connect Claude Code to the hosted MCP endpoint (free tools work without credentials; pass -H "X-Polar-License-Key: ..." for metered tools):
claude mcp add --transport http qasmguard https://qasmguard-mcp.raymond-deoliveira.workers.dev/mcp
For clients using mcpServers JSON:
{
"mcpServers": {
"qasmguard": {
"url": "https://qasmguard-mcp.raymond-deoliveira.workers.dev/mcp"
}
}
}
Hosted & discovery status:
- Live Cloudflare Worker:
https://qasmguard-mcp.raymond-deoliveira.workers.dev(MCP endpointPOST /mcp, healthGET/HEAD /health, agent summaryGET/HEAD /llms.txt, discovery cardGET/HEAD /.well-known/mcp/server-card.json; free tools work live today, and metered tools fail closed with HTTP402). - Live Official MCP Registry: io.github.raydeoliveira/qasmguard (v0.1.0).
- Pending dashboard provisioning: Apify Store Actor (
https://apify.com/raydeoliveira/qasmguard-mcp), Glama Connector (https://glama.ai/mcp/connectors/io.github.raydeoliveira/qasmguard), Polar Pro checkout (https://buy.polar.sh/qasmguard), and x402 payout address (X402_PAY_TO_ADDRESS, so live402challenges currently emitaccepts: []until dashboard secrets are provisioned). - Apify Actor / Standby container:
FROM node:22-alpine(0npm install, non-rootUSER node, port4321).
To uninstall locally, remove the directory (rm -rf qasmguard).
CLI and MCP Examples
1. Local CLI (source checkout)
Inspect capabilities and run Bell-state simulation or reference fixtures under fixtures/ with --json output:
node src/adapters/cli.ts --describe --json
printf '%s\n' '{"qasm":"OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0],q[1];\nmeasure q -> c;\n","shots":1024,"seed":42,"observables":["ZZ","XX"]}' | node src/adapters/cli.ts simulate --json --input -
node src/adapters/cli.ts simulate --qasm-file fixtures/bell_qasm2.qasm --shots 1024 --seed 42 --observables ZZ,XX --json
node src/adapters/cli.ts route --qasm-file fixtures/bell_qasm2.qasm --preset willow-105 --json
node src/adapters/cli.ts pauli-group --input fixtures/h2_sto3g_pauli.json --json
node src/adapters/cli.ts ftqc --input fixtures/ftqc_willow_100q.json --json
Reference fixtures included in fixtures/:
fixtures/bell_qasm2.qasm— 2-qubit OpenQASM 2.0 Bell state (h q[0]; cx q[0],q[1]; measure q -> c;).fixtures/h2_sto3g_pauli.json— 5-term H2 STO-3G Pauli Hamiltonian (strategy: "gc",totalShots: 1000, reduces 5 terms to 2 commuting groups).fixtures/ftqc_willow_100q.json— 100-logical-qubit,1,000,000-T-gate Willow (15-to-1-distillation) FTQC benchmark (codeDistance: 53,totalPhysicalQubits: 104466710,factoryCount: 595,estimatedRuntimeSeconds: 0.58883).
2. HTTP 402 & stdio MCP Server
Dry-run or start the local HTTP 402 server or stdio MCP server:
node src/adapters/cli.ts serve-mcp --dry-run --json
API_KEYS_CSV="demo-key" node src/adapters/cli.ts serve-mcp --host 127.0.0.1 --port 0
node src/adapters/cli.ts serve-mcp --stdio
3. Apify Actor & Standby MCP (source checkout)
Run offline Actor mode against APIFY_LOCAL_STORAGE_DIR (create INPUT.json first; without it the run exits 2 and writes ERR_INVALID_INPUT to OUTPUT.json):
mkdir -p storage/key_value_stores/default
printf '%s\n' '{"tool":"q_lint_qasm","arguments":{"qasm":"OPENQASM 2.0;\ninclude \"qelib1.inc\";\nqreg q[2];\ncreg c[2];\nh q[0];\ncx q[0],q[1];\nmeasure q -> c;\n"}}' > storage/key_value_stores/default/INPUT.json
APIFY_LOCAL_STORAGE_DIR=./storage node src/adapters/apify_main.ts
cat storage/key_value_stores/default/OUTPUT.json
Run Standby MCP mode (PORT=0 for ephemeral bind):
APIFY_META_ORIGIN=STANDBY ACTOR_WEB_SERVER_PORT=0 node src/adapters/apify_main.ts
Safety & Compute Bounds
- Stateless
$0compute: Zero OS hardware mutation, zero physical QPU driver installation, and zero remote file fetching. - Unified
q0_lsbconvention: Bitstrings (bitstr[n - 1 - k]) and Pauli observables (obs[n - 1 - k]) consistently address qubitq[k]. - Fail-closed bounds: QASM payloads
<= 262,144bytes, statevector<= 12qubits, stabilizer<= 256qubits, shots<= 100,000, observables<= 64, Pauli terms<= 2,048, HTTP MCP body<= 262,144bytes, JSON-RPC batch1..64messages, and strict prototype-chain key rejection (__proto__,constructor,prototype). - Fail-closed
402& deferred x402 settlement: Authorization runs before tool validation on metered calls; x402/settleexecutes only after the tool succeeds (QasmValidationErrornever settles or charges). - Apify Pay-Per-Event: Results are pushed to the Dataset before charging; on
APIFY_IS_AT_HOME=1,chargeEvents: falseis ignored and runs stop before exceedingACTOR_MAX_TOTAL_CHARGE_USD.
Exit Codes
| Code | Meaning |
|---|---|
0 | Success (including --help, --version, --describe, --dry-run, and serve-mcp --stdio EOF) |
1 | Runtime error or --strict failure (lint --strict warnings/errors, equiv --strict inequivalent) |
2 | CLI usage error or validation error (QasmValidationError, malformed JSON, unknown flag) |
3 | I/O error or missing/unreadable --input / --qasm-file path |
4 | Domain limit exceeded (> 12Q statevector, non-Clifford gate in stabilizer, > 256Q, > preset.qubits, disconnected topology) |
5 | Internal error (or Apify PPE charge rejection / spending limit reached before any call succeeded) |
130 | SIGINT interrupted |
License & Support
Proprietary commercial software. Copyright (c) 2026 Raymond de Oliveira. All rights reserved. See LICENSE and SECURITY.md.
No installation packages available.
Remote
Related Servers
io.github.raydeoliveira/depthpipe
Live 2D-to-3D stereo depth pipeline, Metal DIBR weaver, and MV-HEVC Spatial Video tool.
io.github.raydeoliveira/dutybench-firmware-power
Compare firmware battery drain by operating phase using Joulescope current measurements.
io.github.raydeoliveira/edidsmith
EDID 1.4/CTA-861/DisplayID 2.1 parser, CVT-RB2 link-budget solver, and safe EDID patcher.