Skip to main content

MCP server exposing Google's Stim quantum stabilizer circuit library as LLM tools

Project description

stim-mcp-server

MCP server wrapping Google's Stim stabilizer circuit simulator. Wire it up to an LLM and you can build, sample, and debug circuits through conversation.

Tools

Tool Description
hello_quantum Health check — returns Stim version and active session count
create_circuit Validate a Stim circuit string and open a persistent session
append_operation Append one or more Stim instructions to an existing circuit
sample_circuit Simulate a circuit and return measurement statistics
analyze_errors Build the Detector Error Model and find shortest logical error paths
get_circuit_diagram Return an ASCII, SVG, or timeline diagram
inject_noise Add depolarizing or X error noise to a circuit

Connecting to the remote server

A hosted instance runs on Google Cloud Run:

URL: https://stim-mcp-5s3woqufqa-uc.a.run.app/mcp Transport: Streamable HTTP (MCP 1.x)

Claude.ai

Go to Settings → Integrations → Add custom integration and enter the URL above.

Claude Code (CLI)

Add to your ~/.claude/claude.json (or project-level .claude/claude.json):

{
  "mcpServers": {
    "stim-mcp": {
      "url": "https://stim-mcp-5s3woqufqa-uc.a.run.app/mcp"
    }
  }
}

Other MCP clients

Use POST https://stim-mcp-5s3woqufqa-uc.a.run.app/mcp with Content-Type: application/json and Accept: application/json, text/event-stream.

Cold start: The server scales to zero when idle. The first request after a period of inactivity may take 5–10 seconds. In-memory circuit sessions are lost on scale-down — circuits are cheap to recreate.

Installation

Needs uv.

Via PyPI (recommended)

No cloning needed. Configure your MCP client (see below) and uvx handles the rest on first run.

From source

git clone https://github.com/DeDuckProject/stim-mcp
cd stim-mcp
uv sync

Running locally

Claude Desktop

macOS~/Library/Application Support/Claude/claude_desktop_config.json Windows%APPDATA%\Claude\claude_desktop_config.json Linux~/.config/Claude/claude_desktop_config.json

{
  "mcpServers": {
    "stim": {
      "command": "/path/to/uvx",
      "args": ["--from", "stim-mcp-server", "stim-mcp-server"]
    }
  }
}

Replace /path/to/uvx with the output of which uvx.

Claude Code

claude mcp add stim -- /path/to/uvx --from stim-mcp-server stim-mcp-server

Stdio (direct)

uv run stim-mcp-server

Or after installing:

pip install .
stim-mcp-server

HTTP / SSE (local testing)

MCP_TRANSPORT=sse stim-mcp-server
# Server listens on http://localhost:8080/mcp

Inspect with the MCP inspector:

npx @modelcontextprotocol/inspector http://localhost:8080/mcp

Docker

docker build -t stim-mcp .
docker run -p 8080:8080 stim-mcp
# Server listens on http://localhost:8080/mcp

MCP dev tools

uv run mcp dev src/stim_mcp_server/server.py

Deploying to Cloud Run

Prerequisites

brew install --cask google-cloud-sdk
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud services enable run.googleapis.com artifactregistry.googleapis.com cloudbuild.googleapis.com

Deploy

gcloud run deploy stim-mcp \
  --source . \
  --region us-central1 \
  --allow-unauthenticated \
  --port 8080 \
  --memory 512Mi \
  --cpu 1 \
  --min-instances 0 \
  --max-instances 1

--source . triggers Cloud Build to build the Docker image — no local Docker required. --max-instances 1 keeps circuit sessions consistent (in-memory store). --min-instances 0 enables scale-to-zero.

Environment variables

Variable Default Description
MCP_TRANSPORT stdio Set to anything else (e.g. sse) to start the HTTP server
MCP_HOST 0.0.0.0 Bind address for HTTP mode
MCP_PORT 8080 Port for HTTP mode

Examples

"Create a Bell state and sample it 1000 times"

"What's the shortest error path in this surface code?"

"Add 0.1% depolarizing noise and show me what changes"

Development

uv sync
uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stim_mcp_server-0.1.0.tar.gz (129.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stim_mcp_server-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file stim_mcp_server-0.1.0.tar.gz.

File metadata

  • Download URL: stim_mcp_server-0.1.0.tar.gz
  • Upload date:
  • Size: 129.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stim_mcp_server-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae3bbc37fbcf564c9983e150c046ac0746b30dae6c3f76120c62c43cd06cf45d
MD5 3680815b79b74058a584abb511982588
BLAKE2b-256 f0ab370cf659b07dfbfc8aa5ebc2d264b66adb5dd40bce9ad44567e56fedf6b7

See more details on using hashes here.

File details

Details for the file stim_mcp_server-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: stim_mcp_server-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for stim_mcp_server-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6ebaa9eecb887d45f5d139ab34b5d34c12bbbcb1c27d41a86602438959bce2a0
MD5 4326e72a4be564b7ad5445c2d1b0c517
BLAKE2b-256 1aaac6e9020f82f60d81d4f73ada9d754c985b6670ed5aa8602c2750ffe52aee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page