MCP Setup via an AI Agent¶
Connect DQC to Codex, Claude Code, Cursor, or another MCP client by pasting one prompt into your agent.
LOCAL MCP SERVER
Let your agent handle setup
It checks your Python environment, installs missing dependencies, connects DQC, and verifies the tools are ready.
Copy, paste into your agent, and send.
Your agent checks for an existing DQC installation automatically.
View the full setup prompt
## Task: install and connect the memq-dqc MCP server
You are setting up the memq-dqc MCP server for the user. memq-dqc is a
Python library for distributed quantum compilation (PyPI package
`memq-dqc`). Its MCP server ships as the optional `mcp` extra and runs
locally over stdio via the `memq-dqc-mcp` command.
Work through the steps in order. Run the commands yourself; do not ask the
user to run them. Keep narration brief: one short progress sentence, then a
short final summary of the environment, server command, and verification.
Do not print full config files, dependency logs, or documentation. Show the
relevant command and error if something fails. Tool output may still be
visible in the client's interface; do not repeat it in your prose.
### Rules
- Web browsing is not required. For Codex, Claude Code, and Cursor, use the
client-specific instructions below and local CLI `--help` if needed.
Do not browse the web or fetch external documentation for this setup.
Package managers may download the required packages and dependencies.
- Never use `sudo`, and never install into the system Python.
- Ask the user before installing `uv` or any other tool.
- When editing a client config file, back it up first and merge the new
entry into it. Never remove or overwrite other entries.
- If a step fails in a way this file does not cover, stop and tell the user
what failed, including the command and its output.
- Use the paths and shell for the user's OS. On Windows, executables live in
`Scripts\` with an `.exe` suffix rather than in `bin/`.
### Step 1: MCP client
The user selected Codex. Set up this client only.
### Step 2: Detect an existing installation
Check for an existing installation yourself; do not first ask the user
whether memq-dqc is installed.
1. If memq-dqc tools are already available, call `list_algorithms`. If it
succeeds, report that DQC is connected and stop without changing config.
2. Inspect only the selected client's memq-dqc configuration entry. If
present, test its configured command and arguments with `--help`. Reuse
a working server, including a development installation or uvx command.
3. If the user supplied an environment or executable path, check that first.
Otherwise check the current project's `.venv`, the active Python
environment, `python`/`python3` on PATH, and an existing `~/.memq-dqc`
virtualenv. Do not scan unrelated directories or print environment
variables or credentials. For each available interpreter, run:
```bash
<python> -c "import sys, importlib.metadata as m; print(sys.executable); print(m.version('memq-dqc'))"
```
If a single suitable installation is found, follow Path A. Prefer the
configured server or user-specified environment over other candidates.
Ask which environment to use only if multiple candidates remain ambiguous.
If none is found, follow Path B.
memq-dqc needs Python 3.11 or newer. Check `<python> --version` before
installing into an environment.
### Path A: memq-dqc is already installed
Find the absolute path of the server executable:
```bash
<python> -c "import sysconfig; print(sysconfig.get_path('scripts'))"
```
The server is `<that directory>/memq-dqc-mcp`. Test it:
```bash
<absolute path>/memq-dqc-mcp --help
```
If this works, reuse it without installing or upgrading anything. Clients
launch the absolute command without activating the environment.
If the server or MCP dependency is missing, add the extra to that same
virtualenv. For a PyPI installation:
```bash
<python> -m pip install --upgrade "memq-dqc[mcp]"
```
For a uv-managed project, use `uv add "memq-dqc[mcp]"`. For an editable
local checkout, preserve the development installation and add the MCP
extra from that checkout rather than replacing it with a PyPI release.
Never install into system Python; use Path B's isolated environment instead.
Re-test the server's `--help` after any install.
The client command is the absolute server path, with no arguments.
Go to Step 3.
### Path B: memq-dqc is not installed
Check for uv with `uv --version`.
**If uv is available**, use `uvx`, which needs no install into the user's
Python. Run this once to download and cache everything; it can take a
minute or two, and doing it now keeps the client from timing out on first
launch:
```bash
uvx --from "memq-dqc[mcp]" memq-dqc-mcp --help
```
The client command is `uvx` with the arguments
`--from memq-dqc[mcp] memq-dqc-mcp`. Go to Step 3.
**If uv is not available**, ask the user which they prefer:
1. Install uv (see https://docs.astral.sh/uv/getting-started/installation/),
then follow the uv instructions above.
2. Use a dedicated virtualenv instead. With a Python 3.11+ interpreter:
```bash
python3 -m venv ~/.memq-dqc
~/.memq-dqc/bin/python -m pip install "memq-dqc[mcp]"
~/.memq-dqc/bin/memq-dqc-mcp --help
```
The client command is the absolute path of
`~/.memq-dqc/bin/memq-dqc-mcp` with `~` expanded, and no arguments.
### Step 3: Register the server in Codex
Use the server name `memq-dqc` and the command and arguments from Path A or
Path B. Back up the existing Codex config (normally `~/.codex/config.toml`,
or `config.toml` in the configured CODEX_HOME directory) before registration.
Check `codex mcp list` first. If an entry named memq-dqc already exists,
inspect it and reuse it if correct; ask before replacing a different entry.
Preserve every other configured server.
```bash
codex mcp add memq-dqc -- <command> <args...>
```
### Step 4: Verify in Codex
Run `codex mcp list` and `codex mcp get memq-dqc` to confirm the registered
stdio command. Restart the Codex session to load the server, then check
`/mcp` and call the memq-dqc `list_algorithms` tool to verify it responds.
If a new session is required, explain that handoff rather than claiming
that the current session already has the tools.
### Present setup and results
Once installation and registration have succeeded, print this banner once
in the user-facing terminal. Color only the three small memQ lines purple
with ANSI `\033[35m`, then reset with `\033[0m` before DQC.
Use the already available Python interpreter to print it; do not install
figlet or another dependency. Keep ANSI codes out of MCP server stdout.
If terminal output is unavailable or does not support color, show the
plain banner once in your final response as a fenced text block instead.
```text
▄ ▄ ▄ ▄▄▄ ▄ ▄ ▄ ▄▄▄
█▀█▀█ █▄ █▀█▀█ █ █
█ █ █ █▄▄ █ █ █ ▀▀█▄
██████╗ ██████╗ ██████╗
██╔══██╗ ██╔═══██╗ ██╔════╝
██║ ██║ ██║ ██║ ██║
██║ ██║ ██║▄▄ ██║ ██║
██████╔╝ ╚██████╔╝ ╚██████╗
╚═════╝ ╚══▀▀═╝ ╚═════╝
```
Follow it with a compact Markdown table showing the Python environment,
server executable, and verified status. Distinguish "Registered; restart
required" from "Connected; tool call verified". Do not claim connectivity
until an actual MCP tool call succeeds. If setup fails, show the error
instead of the success banner. End with the next step and one prompt:
"Use memq-dqc to compile qft_n10 on 10_qubits/n2_pair_nn and report the
e-bit cost."
For subsequent DQC requests, keep results easy to scan:
- Use a short summary table for compilation, verification, and scheduling.
Include only returned values: partitioner, e-bit cost, verification
method/result, makespan with documented units, and saved files as relevant.
- Use one row per partitioner in comparisons, showing e-bit cost,
makespan, and status. Retain failed rows with their error rather than
inventing results. Note that randomized methods can vary.
- Save circuit and schedule outputs to files instead of dumping long QASM
or JSON into the conversation, unless the user asks to see them.
- Keep explanations to one or two sentences. Describe statevector
verification as an ideal measured-output distribution check and
schedules as timing estimates.
### Troubleshooting
| Symptom | Fix |
|---|---|
| `memq-dqc ... does not provide the extra 'mcp'` | The installed release predates the MCP server. Re-run the install with `--upgrade`. |
| `Requires-Python >=3.11` or a resolver error naming Python | The environment's Python is too old. Use a 3.11+ interpreter. |
| The client times out the first time it starts the server | Run the `--help` command from Path A or B once, then restart the client. |
| The `hypergraph` partitioner fails on Windows | Expected. KaHyPar has no Windows build; every other partitioner works. |
## Task: install and connect the memq-dqc MCP server
You are setting up the memq-dqc MCP server for the user. memq-dqc is a
Python library for distributed quantum compilation (PyPI package
`memq-dqc`). Its MCP server ships as the optional `mcp` extra and runs
locally over stdio via the `memq-dqc-mcp` command.
Work through the steps in order. Run the commands yourself; do not ask the
user to run them. Keep narration brief: one short progress sentence, then a
short final summary of the environment, server command, and verification.
Do not print full config files, dependency logs, or documentation. Show the
relevant command and error if something fails. Tool output may still be
visible in the client's interface; do not repeat it in your prose.
### Rules
- Web browsing is not required. For Codex, Claude Code, and Cursor, use the
client-specific instructions below and local CLI `--help` if needed.
Do not browse the web or fetch external documentation for this setup.
Package managers may download the required packages and dependencies.
- Never use `sudo`, and never install into the system Python.
- Ask the user before installing `uv` or any other tool.
- When editing a client config file, back it up first and merge the new
entry into it. Never remove or overwrite other entries.
- If a step fails in a way this file does not cover, stop and tell the user
what failed, including the command and its output.
- Use the paths and shell for the user's OS. On Windows, executables live in
`Scripts\` with an `.exe` suffix rather than in `bin/`.
### Step 1: MCP client
The user selected {{CLIENT}}. Set up this client only.
### Step 2: Detect an existing installation
Check for an existing installation yourself; do not first ask the user
whether memq-dqc is installed.
1. If memq-dqc tools are already available, call `list_algorithms`. If it
succeeds, report that DQC is connected and stop without changing config.
2. Inspect only the selected client's memq-dqc configuration entry. If
present, test its configured command and arguments with `--help`. Reuse
a working server, including a development installation or uvx command.
3. If the user supplied an environment or executable path, check that first.
Otherwise check the current project's `.venv`, the active Python
environment, `python`/`python3` on PATH, and an existing `~/.memq-dqc`
virtualenv. Do not scan unrelated directories or print environment
variables or credentials. For each available interpreter, run:
```bash
<python> -c "import sys, importlib.metadata as m; print(sys.executable); print(m.version('memq-dqc'))"
```
If a single suitable installation is found, follow Path A. Prefer the
configured server or user-specified environment over other candidates.
Ask which environment to use only if multiple candidates remain ambiguous.
If none is found, follow Path B.
memq-dqc needs Python 3.11 or newer. Check `<python> --version` before
installing into an environment.
### Path A: memq-dqc is already installed
Find the absolute path of the server executable:
```bash
<python> -c "import sysconfig; print(sysconfig.get_path('scripts'))"
```
The server is `<that directory>/memq-dqc-mcp`. Test it:
```bash
<absolute path>/memq-dqc-mcp --help
```
If this works, reuse it without installing or upgrading anything. Clients
launch the absolute command without activating the environment.
If the server or MCP dependency is missing, add the extra to that same
virtualenv. For a PyPI installation:
```bash
<python> -m pip install --upgrade "memq-dqc[mcp]"
```
For a uv-managed project, use `uv add "memq-dqc[mcp]"`. For an editable
local checkout, preserve the development installation and add the MCP
extra from that checkout rather than replacing it with a PyPI release.
Never install into system Python; use Path B's isolated environment instead.
Re-test the server's `--help` after any install.
The client command is the absolute server path, with no arguments.
Go to Step 3.
### Path B: memq-dqc is not installed
Check for uv with `uv --version`.
**If uv is available**, use `uvx`, which needs no install into the user's
Python. Run this once to download and cache everything; it can take a
minute or two, and doing it now keeps the client from timing out on first
launch:
```bash
uvx --from "memq-dqc[mcp]" memq-dqc-mcp --help
```
The client command is `uvx` with the arguments
`--from memq-dqc[mcp] memq-dqc-mcp`. Go to Step 3.
**If uv is not available**, ask the user which they prefer:
1. Install uv (see https://docs.astral.sh/uv/getting-started/installation/),
then follow the uv instructions above.
2. Use a dedicated virtualenv instead. With a Python 3.11+ interpreter:
```bash
python3 -m venv ~/.memq-dqc
~/.memq-dqc/bin/python -m pip install "memq-dqc[mcp]"
~/.memq-dqc/bin/memq-dqc-mcp --help
```
The client command is the absolute path of
`~/.memq-dqc/bin/memq-dqc-mcp` with `~` expanded, and no arguments.
{{CLIENT_STEPS}}
### Present setup and results
Once installation and registration have succeeded, print this banner once
in the user-facing terminal. Color only the three small memQ lines purple
with ANSI `\033[35m`, then reset with `\033[0m` before DQC.
Use the already available Python interpreter to print it; do not install
figlet or another dependency. Keep ANSI codes out of MCP server stdout.
If terminal output is unavailable or does not support color, show the
plain banner once in your final response as a fenced text block instead.
```text
▄ ▄ ▄ ▄▄▄ ▄ ▄ ▄ ▄▄▄
█▀█▀█ █▄ █▀█▀█ █ █
█ █ █ █▄▄ █ █ █ ▀▀█▄
██████╗ ██████╗ ██████╗
██╔══██╗ ██╔═══██╗ ██╔════╝
██║ ██║ ██║ ██║ ██║
██║ ██║ ██║▄▄ ██║ ██║
██████╔╝ ╚██████╔╝ ╚██████╗
╚═════╝ ╚══▀▀═╝ ╚═════╝
```
Follow it with a compact Markdown table showing the Python environment,
server executable, and verified status. Distinguish "Registered; restart
required" from "Connected; tool call verified". Do not claim connectivity
until an actual MCP tool call succeeds. If setup fails, show the error
instead of the success banner. End with the next step and one prompt:
"Use memq-dqc to compile qft_n10 on 10_qubits/n2_pair_nn and report the
e-bit cost."
For subsequent DQC requests, keep results easy to scan:
- Use a short summary table for compilation, verification, and scheduling.
Include only returned values: partitioner, e-bit cost, verification
method/result, makespan with documented units, and saved files as relevant.
- Use one row per partitioner in comparisons, showing e-bit cost,
makespan, and status. Retain failed rows with their error rather than
inventing results. Note that randomized methods can vary.
- Save circuit and schedule outputs to files instead of dumping long QASM
or JSON into the conversation, unless the user asks to see them.
- Keep explanations to one or two sentences. Describe statevector
verification as an ideal measured-output distribution check and
schedules as timing estimates.
### Troubleshooting
| Symptom | Fix |
|---|---|
| `memq-dqc ... does not provide the extra 'mcp'` | The installed release predates the MCP server. Re-run the install with `--upgrade`. |
| `Requires-Python >=3.11` or a resolver error naming Python | The environment's Python is too old. Use a 3.11+ interpreter. |
| The client times out the first time it starts the server | Run the `--help` command from Path A or B once, then restart the client. |
| The `hypergraph` partitioner fails on Windows | Expected. KaHyPar has no Windows build; every other partitioner works. |
### Step 3: Register the server in Codex
Use the server name `memq-dqc` and the command and arguments from Path A or
Path B. Back up the existing Codex config (normally `~/.codex/config.toml`,
or `config.toml` in the configured CODEX_HOME directory) before registration.
Check `codex mcp list` first. If an entry named memq-dqc already exists,
inspect it and reuse it if correct; ask before replacing a different entry.
Preserve every other configured server.
```bash
codex mcp add memq-dqc -- <command> <args...>
```
### Step 4: Verify in Codex
Run `codex mcp list` and `codex mcp get memq-dqc` to confirm the registered
stdio command. Restart the Codex session to load the server, then check
`/mcp` and call the memq-dqc `list_algorithms` tool to verify it responds.
If a new session is required, explain that handoff rather than claiming
that the current session already has the tools.
### Step 3: Register the server in Claude Code
Use the server name `memq-dqc` and the command and arguments from Path A or
Path B. Back up `~/.claude.json` (or `.claude.json` in the configured
CLAUDE_CONFIG_DIR directory) before registration. Check `claude mcp list`
first. Reuse an existing correct entry; ask before replacing a different
entry named memq-dqc. Preserve every other configured server.
Register at user scope so it works in every project:
```bash
claude mcp add --scope user memq-dqc -- <command> <args...>
```
### Step 4: Verify in Claude Code
Run `claude mcp list` and confirm memq-dqc is connected. If necessary,
restart the session and check `/mcp`. Call the memq-dqc `list_algorithms`
tool to verify it responds.
### Step 3: Register the server in Cursor
Use the server name `memq-dqc` and the command and arguments from Path A or
Path B. Back up `~/.cursor/mcp.json` if it exists, then merge this entry
under its top-level `mcpServers` object. Create the file if absent.
Reuse an existing correct entry; ask before replacing a different entry
named memq-dqc. Preserve every other configured server.
Omit `args` when there are none:
```json
{
"mcpServers": {
"memq-dqc": {
"command": "<command>",
"args": ["<arg>", "..."]
}
}
}
```
Use an absolute command path. If using uvx, resolve it with `which uvx`
(`where uvx` on Windows) so Cursor can find it without an activated shell.
### Step 4: Verify in Cursor
Check Cursor's MCP settings to confirm memq-dqc is enabled and its tools
are available. Reload Cursor if necessary, then call the memq-dqc
`list_algorithms` tool in Agent mode to verify it responds.
### Step 3: Register the server in your MCP client
Ask which MCP client the user wants to configure. Use its local CLI help,
built-in setup instructions, or documentation supplied by the user.
If the registration method is still unknown, ask for those instructions;
do not require browsing or guess. Register a local stdio server named
memq-dqc with the command and arguments from Path A or Path B. Back up its config
before editing, preserve other entries, and reuse an existing correct
entry. Ask before replacing a different entry named memq-dqc.
Do not guess the config path or use another client's config format.
### Step 4: Verify in your MCP client
Follow the client's documented reload and connection checks. Confirm
memq-dqc's tools appear and call `list_algorithms` to verify it responds.
Report any remaining connection problem without claiming success.