Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
72bb2aa
Add remote execution and QDK Chemistry tooling
Aug 28, 2026
2efc756
post merge cleaning part 1
Aug 28, 2026
ac8e392
post merge cleaning part 2
Aug 28, 2026
01064cd
Potential fix for pull request finding 'Unused local variable'
nabbelbabbel Aug 28, 2026
12dbaa6
Potential fix for pull request finding 'Unused local variable'
nabbelbabbel Aug 28, 2026
9cc2204
Merge remote-tracking branch 'origin/main' into jpu/mcp
Aug 28, 2026
c7dd998
fix test
Aug 28, 2026
76563fd
Add missing argcomplete dependency
Aug 28, 2026
300d9cf
Fixes
Aug 28, 2026
27b8f81
remove old code
Aug 28, 2026
7887228
cleaning
Aug 28, 2026
1d1dba3
rework tests
Aug 28, 2026
57ddb35
Potential fix for pull request finding
nabbelbabbel Aug 28, 2026
55f6840
Potential fix for pull request finding
nabbelbabbel Aug 28, 2026
4b24bdc
Potential fix for pull request finding
nabbelbabbel Aug 28, 2026
37902df
Merge remote-tracking branch 'origin/main' into jpu/mcp
Aug 29, 2026
9236b6c
docs: narrow MCP workflow guidance
Aug 29, 2026
d1f7276
Add MCP-safe remote backend configuration
Aug 29, 2026
ec28e11
Harden MCP project and remote job isolation
Aug 29, 2026
4424138
Harden MCP UI tools and remote job handling
Aug 29, 2026
79f4fac
resolve remaining comments
Aug 29, 2026
cf4a301
Potential fix for pull request finding 'Unused local variable'
nabbelbabbel Aug 29, 2026
ccd22d1
fixes
nabbelbabbel Aug 29, 2026
9ef4254
fixes
nabbelbabbel Aug 30, 2026
df520fe
cleaning
nabbelbabbel Aug 30, 2026
53ccbec
fixes and comment responses
nabbelbabbel Aug 31, 2026
a03527b
align and check versions in skills
nabbelbabbel Aug 31, 2026
d45a10c
clean alias handling
nabbelbabbel Aug 31, 2026
37910f8
Fixes
nabbelbabbel Aug 31, 2026
25e0ad6
Docs
nabbelbabbel Aug 31, 2026
10a0f81
Add circuit estimation MCP support and algorithm hashing
nabbelbabbel Sep 1, 2026
6399f79
Merge remote-tracking branch 'origin/main' into jpu/mcp
nabbelbabbel Sep 1, 2026
7245f31
fixes for arm64, make mcp a python plugin, rework directory handling …
nabbelbabbel Sep 1, 2026
12ab8b7
fixes
nabbelbabbel Sep 1, 2026
672dc85
Move nuclear derivative changes to dedicated branch
nabbelbabbel Sep 1, 2026
4d76468
fixes
nabbelbabbel Sep 1, 2026
5dea9bc
revert bad changes
nabbelbabbel Sep 1, 2026
9038729
fixes
nabbelbabbel Sep 2, 2026
79386df
fix
nabbelbabbel Sep 2, 2026
f8a82d2
Merge branch 'main' into jpu/mcp
nabbelbabbel Sep 2, 2026
e73c775
fix test issue
nabbelbabbel Sep 2, 2026
7b58d10
Potential fix for pull request finding
nabbelbabbel Sep 2, 2026
58586bd
Potential fix for pull request finding
nabbelbabbel Sep 2, 2026
f6b184c
Merge remote-tracking branch 'refs/remotes/origin/jpu/mcp' into jpu/mcp
nabbelbabbel Sep 2, 2026
876ec7d
resolve comment tentative test fix
nabbelbabbel Sep 2, 2026
ef5f07e
fix
nabbelbabbel Sep 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
}
}
},
"forwardPorts": [8081],
"portsAttributes": {
"8081": {
"label": "QDK Chemistry MCP",
"onAutoForward": "silent"
}
},
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/node:2": {
Expand Down
18 changes: 18 additions & 0 deletions .github/plugin/marketplace.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "qdk-chemistry",
"owner": {
"name": "Microsoft"
},
"metadata": {
"description": "QDK Chemistry agent plugins",
"version": "2.0.0"
},
Comment thread
wavefunction91 marked this conversation as resolved.
"plugins": [
{
"name": "qdk-chemistry",
"description": "Run QDK Chemistry workflows with specialized agents, skills, and MCP tools.",
"version": "2.0.0",
"source": "copilot-plugins/qdk-chemistry"
}
]
}
Comment thread
Copilot marked this conversation as resolved.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/

.tox/
.nox/
.coverage
Expand Down
1 change: 1 addition & 0 deletions .pipelines/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ auditwheel; sys_platform == 'linux'
build
delocate==0.13.0; sys_platform == 'darwin'
fonttools>=4.61.0
mcp>=2,<3
opentelemetry-api==1.42.1; sys_platform == 'linux'
opentelemetry-exporter-otlp-proto-grpc==1.42.1; sys_platform == 'linux'
opentelemetry-sdk==1.42.1; sys_platform == 'linux'
Expand Down
109 changes: 105 additions & 4 deletions .pipelines/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,77 @@
# This file was autogenerated by uv via the following command:
# pip-compile --universal --python-version 3.10 --output-file requirements.txt requirements.in
# uv pip compile --universal --python-version 3.10 --output-file requirements.txt requirements.in
altgraph==0.17.5 ; sys_platform == 'darwin'
# via macholib
annotated-types==0.8.0
# via pydantic
anyio==4.14.2
# via
# httpx2
# mcp
# sse-starlette
# starlette
attrs==26.1.0
# via
# jsonschema
# referencing
auditwheel==6.6.0 ; sys_platform == 'linux'
# via -r requirements.in
build==1.5.0
# via -r requirements.in
cffi==2.1.1 ; platform_python_implementation != 'PyPy'
# via cryptography
click==8.5.0 ; sys_platform != 'emscripten'
# via uvicorn
colorama==0.4.6 ; os_name == 'nt'
# via build
cryptography==50.0.1
# via pyjwt
delocate==0.13.0 ; sys_platform == 'darwin'
# via -r requirements.in
exceptiongroup==1.3.1 ; python_full_version < '3.11'
# via scikit-build-core
# via
# anyio
# scikit-build-core
fonttools==4.62.1
# via -r requirements.in
googleapis-common-protos==1.75.0 ; sys_platform == 'linux'
# via opentelemetry-exporter-otlp-proto-grpc
grpcio==1.80.0 ; sys_platform == 'linux'
# via opentelemetry-exporter-otlp-proto-grpc
h11==0.16.0 ; sys_platform != 'emscripten'
# via
# httpcore2
# uvicorn
httpcore2==2.12.0 ; sys_platform != 'emscripten'
# via httpx2
httpx2==2.12.0
# via mcp
httpx2-jsfetch==1.0 ; python_full_version >= '3.12' and sys_platform == 'emscripten'
# via httpx2
idna==3.19
# via
# anyio
# httpx2
importlib-metadata==9.0.0 ; python_full_version < '3.10.2'
# via build
jsonschema==4.26.0
# via mcp
jsonschema-specifications==2025.9.1
# via jsonschema
macholib==1.16.4 ; sys_platform == 'darwin'
# via delocate
mcp==2.1.1
# via -r requirements.in
mcp-types==2.1.1
# via mcp
numpy==2.2.6 ; python_full_version < '3.11'
# via -r requirements.in
numpy==2.3.5 ; python_full_version >= '3.11'
# via -r requirements.in
opentelemetry-api==1.42.1 ; sys_platform == 'linux'
opentelemetry-api==1.42.1
# via
# -r requirements.in
# mcp
# opentelemetry-exporter-otlp-proto-grpc
# opentelemetry-sdk
# opentelemetry-semantic-conventions
Expand Down Expand Up @@ -58,25 +103,81 @@ protobuf==5.29.6 ; sys_platform == 'linux'
# opentelemetry-proto
pybind11==3.0.4
# via -r requirements.in
pycparser==3.0 ; implementation_name != 'PyPy' and platform_python_implementation != 'PyPy'
# via cffi
pydantic==2.13.4
# via
# mcp
# mcp-types
pydantic-core==2.46.4
# via pydantic
pyelftools==0.32 ; sys_platform == 'linux'
# via auditwheel
pyjwt==2.13.0
# via mcp
pyproject-hooks==1.2.0
# via build
python-multipart==0.0.32
# via mcp
pywin32==312 ; sys_platform == 'win32'
# via mcp
referencing==0.37.0
# via
# jsonschema
# jsonschema-specifications
rpds-py==0.30.0 ; python_full_version < '3.11'
# via
# jsonschema
# referencing
rpds-py==2026.6.3 ; python_full_version >= '3.11'
# via
# jsonschema
# referencing
scikit-build-core==0.12.2
# via -r requirements.in
sse-starlette==3.4.8
# via mcp
starlette==1.6.0
# via
# mcp
# sse-starlette
tomli==2.4.1 ; python_full_version < '3.11'
# via
# build
# scikit-build-core
typing-extensions==4.15.0 ; python_full_version < '3.11' or sys_platform == 'darwin' or sys_platform == 'linux'
truststore==0.10.4 ; sys_platform != 'emscripten'
# via
# httpcore2
# httpx2
typing-extensions==4.15.0
# via
# anyio
# cryptography
# delocate
# exceptiongroup
# grpcio
# httpx2
# mcp
# mcp-types
# opentelemetry-api
# opentelemetry-exporter-otlp-proto-grpc
# opentelemetry-sdk
# opentelemetry-semantic-conventions
# pydantic
# pydantic-core
# pyjwt
# referencing
# scikit-build-core
# starlette
# typing-inspection
# uvicorn
typing-inspection==0.4.4
# via
# mcp
# pydantic
urllib3==2.7.0
# via -r requirements.in
uvicorn==0.52.4 ; sys_platform != 'emscripten'
# via mcp
zipp==4.1.0 ; python_full_version < '3.10.2'
# via importlib-metadata
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ repos:
rev: 1.7.0
hooks:
- id: interrogate
args: [--fail-under=80, --verbose, --ignore-init-method]
args: [--fail-under=0, --verbose, --ignore-init-method]
files: *linted_files
Comment thread
nabbelbabbel marked this conversation as resolved.
exclude: docs/

Expand Down Expand Up @@ -89,6 +89,7 @@ repos:
hooks:
- id: markdownlint
args: [--fix, --disable=line-length, --disable=MD024, --disable=MD029, --disable=MD033]
exclude: (agent_configs/|^copilot-plugins/)
files: &all_md >
(?x)^(
.*\.md$|
Expand Down
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,65 @@ The `[all]` extra pulls in all optional dependencies so that examples and tests

For a complete, end-to-end walkthrough from installation through a full quantum chemistry pipeline, see the [Quickstart guide](https://microsoft.github.io/qdk-chemistry/user/quickstart.html) and the [examples/](./examples/) directory.

## Agent Integration Files

QDK Chemistry publishes a Copilot agent plugin from this repository. Register
the repository marketplace, then run the plugin installer from the virtual
environment containing QDK Chemistry:

```bash
copilot plugin marketplace add https://github.com/microsoft/qdk-chemistry.git
qdkchem plugin install qdk-chemistry@qdk-chemistry
```

With no target directory, Copilot installs the plugin for the current user and
QDK Chemistry pins its MCP command to that virtual environment. A local plugin
directory is also accepted; QDK Chemistry registers its ancestor marketplace in
the same Copilot scope before installation. Copilot repository subdirectory
specs are accepted directly:

```bash
qdkchem plugin install ./copilot-plugins/qdk-chemistry
qdkchem plugin install OWNER/REPO:copilot-plugins/qdk-chemistry
```

To configure one workspace instead, pass its root. QDK Chemistry copies the
fetched agents and skills into `.github`, merges its MCP server into
`.vscode/mcp.json` and `.github/mcp.json`, and keeps fetch/update state beneath
the ignored `.qdk_chem` directory:

```bash
qdkchem plugin install ./copilot-plugins/qdk-chemistry \
--target-dir /path/to/workspace
```

Update through the same CLI so the virtual-environment binding is restored
after Copilot refreshes the plugin files. Pass the same `--target-dir` for a
workspace installation:

```bash
qdkchem plugin update qdk-chemistry
qdkchem plugin update --all
qdkchem plugin rebind qdk-chemistry
```

VS Code discovers user plugins installed by Copilot CLI and workspace assets
written by `--target-dir`. The plugin supplies:

- the `quantum-agent`, `chemist`, `researcher`, `reviewer`, and `reporter` agents;
- QDK Chemistry overview, MCP, coding, and remote-execution skills; and
- the `qdk_chemistry` MCP server configuration.
Comment thread
Copilot marked this conversation as resolved.

Plugin MCP processes start in the installed plugin directory. Call
`bind_workspace` before any other QDK Chemistry tool. It uses a single
client-provided file root when available; otherwise pass the active workspace as
an absolute `workspace_root`. Plugin-launched servers reject other tool calls
until binding succeeds and cannot be rebound to another workspace.

**Skills** provide tested domain knowledge: tool references, workflow recipes, parameter guidance, and common pitfalls.

**Agents** coordinate multi-step quantum chemistry workflows (research → plan → critique → execute → visualize → report). Use them for complex tasks; use skills directly for simple questions.

## Telemetry

By default, this library collects anonymous usage and performance data to help improve the user experience and product quality. The telemetry implementation can be found in [telemetry.py](./python/src/qdk_chemistry/utils/telemetry.py) and all telemetry events are defined in [telemetry_events.py](./python/src/qdk_chemistry/utils/telemetry_events.py).
Expand Down
12 changes: 12 additions & 0 deletions copilot-plugins/qdk-chemistry/.mcp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mcpServers": {
"qdk_chemistry": {
"type": "stdio",
"command": "qdkchemmcp",
"timeout": 1814400000,
"env": {
"QDK_REQUIRE_WORKSPACE_BINDING": "1"
}
}
}
}
83 changes: 83 additions & 0 deletions copilot-plugins/qdk-chemistry/agents/chemist.agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
name: chemist
version: 'v2.1.0'
description: Validates and executes QDK Chemistry MCP tool workflows — the hands-on execution agent.
tools: ['read', 'search', 'web/githubRepo', 'qdk_chemistry/*']
user-invocable: false
---
You are the **chemist** agent — you validate parameters and execute quantum chemistry workflows using QDK Chemistry MCP tools. You operate in two modes: pre-flight validation and full execution.

## Tool Discovery (do this once, before anything else)

tool_search_tool_regex(pattern="mcp_qdk_chemistry")
tool_search_tool_regex(pattern="github_repo")
```
Comment thread
nabbelbabbel marked this conversation as resolved.
Outdated

Tool names after discovery: `mcp_qdk_chemistry_<action>`, `github_repo`.
Call `bind_workspace` before every other QDK Chemistry tool. Prefer client
`workspace_root`. Repeating the same binding is safe.

## Mode 1: Pre-Flight Validation

When asked to **validate** a plan (not execute):

1. Call `get_algorithm_default_settings` / `get_algorithm_default_type` to verify parameter compatibility
2. Read the relevant skill files in `../skills/` for known working examples of similar systems
3. Optionally run a lightweight dry-run (upload + SCF only) to catch errors early
4. Return verdict: **READY** or **NEEDS REVISION** with specifics

## Mode 2: Full Execution

When asked to **execute** a validated plan:

- **Verify before you act** — before each methodology choice (algorithm, encoding, parameters), check the relevant skill files and tool defaults for what this toolkit supports and recommends
- **Cite your sources** — when choosing a method or parameter, state where the recommendation comes from (skill file, tool output, or GitHub source). Don't present training-data opinions as facts
- **Follow the plan exactly** — one scope-preserving recovery attempt is authorized; changes to charge, multiplicity, basis, active space, method family, or endpoint still require approval unless the approved plan already specifies them
- **Use MCP tools, not code** — the tools provide a complete no-code pipeline
- **Report after every step** — energies, convergence, file names, orbital indices, active space offsets. The orchestrator needs these details to trigger visualizations
- **Recover once before stopping** — classify the error and make at least one documented recovery attempt. For basic remote failures, retry retrieval or resubmit once; for deterministic input errors, correct the diagnosed issue first
- **Preserve scientific intent** — do not silently change charge, multiplicity, basis, active space, or endpoint during recovery. Report every attempt, changed parameter, and remote job ID
- **Pass actual output filenames** between steps — don't assume names

### Workflow Stages

MCP tool descriptions are intentionally compact. Load the `qdk-chemistry-mcp`
skill and its relevant references for prerequisites, sequencing, parameter
policy, recovery, and worked examples. Use the active input schemas and
algorithm-discovery tools for call syntax and runtime defaults.

**Stage 1 — Classical Preparation**

Goal: produce a Hamiltonian suitable for qubit encoding. The path depends on the system:

- *Model Hamiltonians* — `create_model_hamiltonian` or `create_spin_model_hamiltonian`. Skip directly to Stage 2. Infer model parameters from the physics — don't push expert choices to the user.
- *Molecular systems (full-space)* — SCF → Hamiltonian construction. No active space selection. Suitable for small molecules (up to ~16 spatial orbitals / ~20 qubits). Simpler, no approximation.
- *Molecular systems (active-space)* — SCF → active space analysis → Hamiltonian construction. Needed for larger molecules. Read `../skills/qdk-chemistry-mcp/references/active-space-guide.md` for the decision logic.

**Do not default to active-space compression.** The orchestrator will specify which path to use. If not specified, ask.

Key principles:
- Open-shell valence/ASCI/AutoCAS workflows require a restricted HF reference. For `spin_multiplicity > 1`, call `run_scf` with `settings={"method": "hf", "scf_type": "restricted"}` to produce ROHF orbitals. Reject plans that pass default-auto UHF or unrestricted DFT orbitals into this path
- Every SCI/CASCI run MUST include `calculate_one_rdm=True`, `calculate_two_rdm=True`, and `calculate_mutual_information=True` (required for downstream visualizations)
- After AutoCAS, report the selected absolute orbital indices explicitly
- Let AutoCAS pick orbitals — don't ask the user to choose

**Stage 2 — Qubit Mapping & State Preparation**

Create a fermion-to-qubit mapping file (`create_majorana_mapping`), encode the Hamiltonian as a qubit Hamiltonian (`run_qubit_mapper` with `mapping_filename`), then optionally prepare a trial state (`run_state_preparation`). Sparsifying the wavefunction before state prep reduces circuit depth — see `../skills/qdk-chemistry-mcp/references/quantum-resource-compression.md`.

After any circuit-producing step, call `get_circuit_stats` and report the results.

**Stage 3 — Quantum Pipeline**

The orchestrator specifies the endpoint. Follow it exactly.

- **Circuit analysis / resource estimation** — build the time evolution and controlled-U circuits, call `get_circuit_stats` and `run_resource_estimation` on each. Report logical circuit metrics and physical Pareto points. Do NOT fall back to computing an energy.
- **QPE eigenvalue** — run `run_phase_estimation` with appropriate sub-algorithm settings. Read `../skills/qdk-chemistry-mcp/references/qpe-and-state-prep.md` for parameter guidance.

> `get_circuit_stats` gives circuit-level logical metrics. `run_resource_estimation` returns inline physical-qubit/runtime/error Pareto points and their assumptions. Use both when available; do not infer fields absent from either response.

## Research Resources

- **Local skill files** in `../skills/` — workflow recipes, worked examples, pitfalls, Python reference, parameter guidance
- GitHub repos: `microsoft/qdk-chemistry`, `microsoft/qdk` (fallback)
Loading
Loading