openquantum-mcp 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- openquantum_mcp-0.1.0/LICENSE +190 -0
- openquantum_mcp-0.1.0/MANIFEST.in +11 -0
- openquantum_mcp-0.1.0/PKG-INFO +164 -0
- openquantum_mcp-0.1.0/README.md +131 -0
- openquantum_mcp-0.1.0/examples/claude_desktop.mcp.json +12 -0
- openquantum_mcp-0.1.0/examples/mcp.client.json +12 -0
- openquantum_mcp-0.1.0/openquantum_mcp/__init__.py +3 -0
- openquantum_mcp-0.1.0/openquantum_mcp/__main__.py +43 -0
- openquantum_mcp-0.1.0/openquantum_mcp/auth.py +91 -0
- openquantum_mcp-0.1.0/openquantum_mcp/config.py +77 -0
- openquantum_mcp-0.1.0/openquantum_mcp/logging_util.py +50 -0
- openquantum_mcp-0.1.0/openquantum_mcp/safety.py +153 -0
- openquantum_mcp-0.1.0/openquantum_mcp/server.py +372 -0
- openquantum_mcp-0.1.0/openquantum_mcp/service.py +758 -0
- openquantum_mcp-0.1.0/openquantum_mcp/summaries.py +141 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/PKG-INFO +164 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/SOURCES.txt +21 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/dependency_links.txt +1 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/entry_points.txt +2 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/requires.txt +8 -0
- openquantum_mcp-0.1.0/openquantum_mcp.egg-info/top_level.txt +1 -0
- openquantum_mcp-0.1.0/pyproject.toml +65 -0
- openquantum_mcp-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2025 Quantum Rings / Open Quantum
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openquantum-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model Context Protocol server for Open Quantum — run quantum jobs from AI coding agents
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: Homepage, https://www.openquantum.com
|
|
7
|
+
Project-URL: Documentation, https://docs.openquantum.com/mcp/overview/
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/Quantum-Rings/openquantum-platform/issues
|
|
9
|
+
Project-URL: Source, https://github.com/Quantum-Rings/openquantum-platform/tree/main/mcp
|
|
10
|
+
Keywords: quantum,mcp,model-context-protocol,openquantum,ai-agents
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering :: Physics
|
|
21
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: openquantum-sdk>=0.4.2
|
|
26
|
+
Requires-Dist: mcp<2,>=1.6.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-mock>=3.10; extra == "dev"
|
|
31
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# openquantum-mcp
|
|
35
|
+
|
|
36
|
+
[Model Context Protocol](https://modelcontextprotocol.io) (MCP) server for [Open Quantum](https://www.openquantum.com).
|
|
37
|
+
|
|
38
|
+
Any MCP-compatible client (Claude, Cursor, VS Code, Grok, and others) can discover backends, submit quantum jobs, wait for completion, and summarize results using your Open Quantum SDK credentials.
|
|
39
|
+
|
|
40
|
+
One stdio server, standard MCP tools — nothing client-specific in the package.
|
|
41
|
+
|
|
42
|
+
**Docs:** [docs.openquantum.com/mcp](https://docs.openquantum.com/mcp/overview/)
|
|
43
|
+
|
|
44
|
+
## Install
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pip install openquantum-sdk openquantum-mcp
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Requires **Python 3.10+**. `openquantum-mcp` depends on `openquantum-sdk` and installs it if needed:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
pip install openquantum-mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Verify without starting the stdio server:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
python -c "import openquantum_mcp; print(openquantum_mcp.__version__)"
|
|
60
|
+
python -m openquantum_mcp --version
|
|
61
|
+
python -m openquantum_mcp --help
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Authentication
|
|
65
|
+
|
|
66
|
+
Use the same SDK key credentials as the Core SDK ([portal SDK keys](https://www.openquantum.com/keys)):
|
|
67
|
+
|
|
68
|
+
| Variable | Meaning |
|
|
69
|
+
|----------|---------|
|
|
70
|
+
| `OPENQUANTUM_CLIENT_ID` | SDK key client id |
|
|
71
|
+
| `OPENQUANTUM_CLIENT_SECRET` | SDK key secret |
|
|
72
|
+
| `OPENQUANTUM_SDK_KEY` | Path to JSON key file (`client_id` + `client_secret`) |
|
|
73
|
+
|
|
74
|
+
If `OPENQUANTUM_SDK_KEY` is set but the file is missing, startup/auth fails with a clear path error (no silent fallback).
|
|
75
|
+
|
|
76
|
+
Optional configuration:
|
|
77
|
+
|
|
78
|
+
| Variable | Default | Meaning |
|
|
79
|
+
|----------|---------|---------|
|
|
80
|
+
| `OPENQUANTUM_MCP_MAX_CREDITS` | `10` | Hard cap on estimated credits per job |
|
|
81
|
+
| `OPENQUANTUM_MCP_WAIT_TIMEOUT_SECONDS` | `600` | Default `wait_for_job` timeout when the tool arg is omitted |
|
|
82
|
+
| `OPENQUANTUM_MCP_POLL_INTERVAL_SECONDS` | `5` | Default `wait_for_job` poll interval when omitted |
|
|
83
|
+
| `OPENQUANTUM_MCP_PREP_TIMEOUT_SECONDS` | `300` | Job preparation wait timeout |
|
|
84
|
+
| `OPENQUANTUM_MCP_DEFAULT_SHOTS` | `128` | Default shots when omitted |
|
|
85
|
+
| `OPENQUANTUM_MCP_DEFAULT_SUBCATEGORY` | `oth:oth` | Default job subcategory |
|
|
86
|
+
| `OPENQUANTUM_MCP_MAX_RESULT_RAW_CHARS` | `8000` | Cap on raw result text |
|
|
87
|
+
| `OPENQUANTUM_MCP_MAX_CALIBRATION_RAW_CHARS` | `8000` | Cap on raw calibration text |
|
|
88
|
+
| `OPENQUANTUM_MANAGEMENT_BASE` | production | Override management API base URL |
|
|
89
|
+
| `OPENQUANTUM_SCHEDULER_BASE` | production | Override scheduler API base URL |
|
|
90
|
+
| `OPENQUANTUM_KEYCLOAK_BASE` | production | Override Keycloak base URL |
|
|
91
|
+
| `OPENQUANTUM_KEYCLOAK_REALM` | `platform` | Keycloak realm |
|
|
92
|
+
|
|
93
|
+
## Run
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
export OPENQUANTUM_CLIENT_ID=...
|
|
97
|
+
export OPENQUANTUM_CLIENT_SECRET=...
|
|
98
|
+
python -m openquantum_mcp
|
|
99
|
+
# or
|
|
100
|
+
openquantum-mcp
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## MCP client configuration
|
|
104
|
+
|
|
105
|
+
Point your client at a Python environment where `openquantum-mcp` is installed, and pass credentials in the server `env`. Exact config file locations differ by host; the process definition is the same:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"mcpServers": {
|
|
110
|
+
"openquantum": {
|
|
111
|
+
"command": "python",
|
|
112
|
+
"args": ["-m", "openquantum_mcp"],
|
|
113
|
+
"env": {
|
|
114
|
+
"OPENQUANTUM_CLIENT_ID": "...",
|
|
115
|
+
"OPENQUANTUM_CLIENT_SECRET": "..."
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Prefer an absolute path to `python` if the client does not inherit your shell PATH (for example, `/path/to/venv/bin/python`).
|
|
123
|
+
|
|
124
|
+
## Tools
|
|
125
|
+
|
|
126
|
+
| Tool | Purpose |
|
|
127
|
+
|------|---------|
|
|
128
|
+
| `list_organizations` | Organizations for the account |
|
|
129
|
+
| `get_credits` | Spark and Full credit balances |
|
|
130
|
+
| `list_backends` / `get_backend` | Discover devices |
|
|
131
|
+
| `list_job_categories` | Categories and subcategories |
|
|
132
|
+
| `prepare_job` | Upload circuit and return a quote (no spend) |
|
|
133
|
+
| `submit_job` | Create a job (does not wait for completion) |
|
|
134
|
+
| `get_job` / `list_jobs` | Job status |
|
|
135
|
+
| `wait_for_job` | Poll until terminal status or timeout |
|
|
136
|
+
| `get_job_results` | Compact output summary |
|
|
137
|
+
| `get_job_calibration` | Calibration data on demand |
|
|
138
|
+
| `cancel_job` | Cancel when allowed by platform rules |
|
|
139
|
+
|
|
140
|
+
`prepare_job` / `submit_job` accept `execution_plan` (`auto` / `public` / `private` / UUID) and `queue_priority` (`auto` / `standard` / `priority` / `instant` / UUID). Auto plan selection prefers **Public** so Spark can apply. Quotes include `quote_summary` with per-priority pricing.
|
|
141
|
+
|
|
142
|
+
**Security:** `file_path` is read by the MCP process and uploaded; prefer `qasm` strings when possible and least-privilege process accounts.
|
|
143
|
+
|
|
144
|
+
## Spend policy
|
|
145
|
+
|
|
146
|
+
1. Estimated cost **greater than 10 credits** (configurable) → rejected.
|
|
147
|
+
2. Cost **0** → allowed.
|
|
148
|
+
3. **Public** plan and **Spark ≥ cost** → auto-approved.
|
|
149
|
+
4. Spend that would use **Full** credits → requires `confirm_spend=true`.
|
|
150
|
+
|
|
151
|
+
Default job subcategory: `oth:oth`. Jobs are tagged `submitted_with=mcp`.
|
|
152
|
+
|
|
153
|
+
## Example agent flow
|
|
154
|
+
|
|
155
|
+
1. `list_backends` / `get_credits`
|
|
156
|
+
2. `prepare_job` with OpenQASM → review quote
|
|
157
|
+
3. `submit_job` (with `confirm_spend=true` when required)
|
|
158
|
+
4. `wait_for_job` (re-call if still queued; QPU queues can be long)
|
|
159
|
+
5. `get_job_results`
|
|
160
|
+
6. `get_job_calibration` only if needed
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
Apache-2.0
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# openquantum-mcp
|
|
2
|
+
|
|
3
|
+
[Model Context Protocol](https://modelcontextprotocol.io) (MCP) server for [Open Quantum](https://www.openquantum.com).
|
|
4
|
+
|
|
5
|
+
Any MCP-compatible client (Claude, Cursor, VS Code, Grok, and others) can discover backends, submit quantum jobs, wait for completion, and summarize results using your Open Quantum SDK credentials.
|
|
6
|
+
|
|
7
|
+
One stdio server, standard MCP tools — nothing client-specific in the package.
|
|
8
|
+
|
|
9
|
+
**Docs:** [docs.openquantum.com/mcp](https://docs.openquantum.com/mcp/overview/)
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install openquantum-sdk openquantum-mcp
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires **Python 3.10+**. `openquantum-mcp` depends on `openquantum-sdk` and installs it if needed:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
pip install openquantum-mcp
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Verify without starting the stdio server:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python -c "import openquantum_mcp; print(openquantum_mcp.__version__)"
|
|
27
|
+
python -m openquantum_mcp --version
|
|
28
|
+
python -m openquantum_mcp --help
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Authentication
|
|
32
|
+
|
|
33
|
+
Use the same SDK key credentials as the Core SDK ([portal SDK keys](https://www.openquantum.com/keys)):
|
|
34
|
+
|
|
35
|
+
| Variable | Meaning |
|
|
36
|
+
|----------|---------|
|
|
37
|
+
| `OPENQUANTUM_CLIENT_ID` | SDK key client id |
|
|
38
|
+
| `OPENQUANTUM_CLIENT_SECRET` | SDK key secret |
|
|
39
|
+
| `OPENQUANTUM_SDK_KEY` | Path to JSON key file (`client_id` + `client_secret`) |
|
|
40
|
+
|
|
41
|
+
If `OPENQUANTUM_SDK_KEY` is set but the file is missing, startup/auth fails with a clear path error (no silent fallback).
|
|
42
|
+
|
|
43
|
+
Optional configuration:
|
|
44
|
+
|
|
45
|
+
| Variable | Default | Meaning |
|
|
46
|
+
|----------|---------|---------|
|
|
47
|
+
| `OPENQUANTUM_MCP_MAX_CREDITS` | `10` | Hard cap on estimated credits per job |
|
|
48
|
+
| `OPENQUANTUM_MCP_WAIT_TIMEOUT_SECONDS` | `600` | Default `wait_for_job` timeout when the tool arg is omitted |
|
|
49
|
+
| `OPENQUANTUM_MCP_POLL_INTERVAL_SECONDS` | `5` | Default `wait_for_job` poll interval when omitted |
|
|
50
|
+
| `OPENQUANTUM_MCP_PREP_TIMEOUT_SECONDS` | `300` | Job preparation wait timeout |
|
|
51
|
+
| `OPENQUANTUM_MCP_DEFAULT_SHOTS` | `128` | Default shots when omitted |
|
|
52
|
+
| `OPENQUANTUM_MCP_DEFAULT_SUBCATEGORY` | `oth:oth` | Default job subcategory |
|
|
53
|
+
| `OPENQUANTUM_MCP_MAX_RESULT_RAW_CHARS` | `8000` | Cap on raw result text |
|
|
54
|
+
| `OPENQUANTUM_MCP_MAX_CALIBRATION_RAW_CHARS` | `8000` | Cap on raw calibration text |
|
|
55
|
+
| `OPENQUANTUM_MANAGEMENT_BASE` | production | Override management API base URL |
|
|
56
|
+
| `OPENQUANTUM_SCHEDULER_BASE` | production | Override scheduler API base URL |
|
|
57
|
+
| `OPENQUANTUM_KEYCLOAK_BASE` | production | Override Keycloak base URL |
|
|
58
|
+
| `OPENQUANTUM_KEYCLOAK_REALM` | `platform` | Keycloak realm |
|
|
59
|
+
|
|
60
|
+
## Run
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
export OPENQUANTUM_CLIENT_ID=...
|
|
64
|
+
export OPENQUANTUM_CLIENT_SECRET=...
|
|
65
|
+
python -m openquantum_mcp
|
|
66
|
+
# or
|
|
67
|
+
openquantum-mcp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## MCP client configuration
|
|
71
|
+
|
|
72
|
+
Point your client at a Python environment where `openquantum-mcp` is installed, and pass credentials in the server `env`. Exact config file locations differ by host; the process definition is the same:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"openquantum": {
|
|
78
|
+
"command": "python",
|
|
79
|
+
"args": ["-m", "openquantum_mcp"],
|
|
80
|
+
"env": {
|
|
81
|
+
"OPENQUANTUM_CLIENT_ID": "...",
|
|
82
|
+
"OPENQUANTUM_CLIENT_SECRET": "..."
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Prefer an absolute path to `python` if the client does not inherit your shell PATH (for example, `/path/to/venv/bin/python`).
|
|
90
|
+
|
|
91
|
+
## Tools
|
|
92
|
+
|
|
93
|
+
| Tool | Purpose |
|
|
94
|
+
|------|---------|
|
|
95
|
+
| `list_organizations` | Organizations for the account |
|
|
96
|
+
| `get_credits` | Spark and Full credit balances |
|
|
97
|
+
| `list_backends` / `get_backend` | Discover devices |
|
|
98
|
+
| `list_job_categories` | Categories and subcategories |
|
|
99
|
+
| `prepare_job` | Upload circuit and return a quote (no spend) |
|
|
100
|
+
| `submit_job` | Create a job (does not wait for completion) |
|
|
101
|
+
| `get_job` / `list_jobs` | Job status |
|
|
102
|
+
| `wait_for_job` | Poll until terminal status or timeout |
|
|
103
|
+
| `get_job_results` | Compact output summary |
|
|
104
|
+
| `get_job_calibration` | Calibration data on demand |
|
|
105
|
+
| `cancel_job` | Cancel when allowed by platform rules |
|
|
106
|
+
|
|
107
|
+
`prepare_job` / `submit_job` accept `execution_plan` (`auto` / `public` / `private` / UUID) and `queue_priority` (`auto` / `standard` / `priority` / `instant` / UUID). Auto plan selection prefers **Public** so Spark can apply. Quotes include `quote_summary` with per-priority pricing.
|
|
108
|
+
|
|
109
|
+
**Security:** `file_path` is read by the MCP process and uploaded; prefer `qasm` strings when possible and least-privilege process accounts.
|
|
110
|
+
|
|
111
|
+
## Spend policy
|
|
112
|
+
|
|
113
|
+
1. Estimated cost **greater than 10 credits** (configurable) → rejected.
|
|
114
|
+
2. Cost **0** → allowed.
|
|
115
|
+
3. **Public** plan and **Spark ≥ cost** → auto-approved.
|
|
116
|
+
4. Spend that would use **Full** credits → requires `confirm_spend=true`.
|
|
117
|
+
|
|
118
|
+
Default job subcategory: `oth:oth`. Jobs are tagged `submitted_with=mcp`.
|
|
119
|
+
|
|
120
|
+
## Example agent flow
|
|
121
|
+
|
|
122
|
+
1. `list_backends` / `get_credits`
|
|
123
|
+
2. `prepare_job` with OpenQASM → review quote
|
|
124
|
+
3. `submit_job` (with `confirm_spend=true` when required)
|
|
125
|
+
4. `wait_for_job` (re-call if still queued; QPU queues can be long)
|
|
126
|
+
5. `get_job_results`
|
|
127
|
+
6. `get_job_calibration` only if needed
|
|
128
|
+
|
|
129
|
+
## License
|
|
130
|
+
|
|
131
|
+
Apache-2.0
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Entry point: python -m openquantum_mcp"""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def main(argv: list[str] | None = None) -> None:
|
|
9
|
+
args = list(sys.argv[1:] if argv is None else argv)
|
|
10
|
+
|
|
11
|
+
if any(a in ("-h", "--help") for a in args):
|
|
12
|
+
print(
|
|
13
|
+
"usage: python -m openquantum_mcp [--help] [--version]\n"
|
|
14
|
+
"\n"
|
|
15
|
+
"Open Quantum MCP server (stdio). Set SDK credentials via\n"
|
|
16
|
+
"OPENQUANTUM_CLIENT_ID / OPENQUANTUM_CLIENT_SECRET or\n"
|
|
17
|
+
"OPENQUANTUM_SDK_KEY, then start this process from an MCP client.\n"
|
|
18
|
+
"\n"
|
|
19
|
+
"Docs: https://docs.openquantum.com/mcp/overview/\n"
|
|
20
|
+
)
|
|
21
|
+
return
|
|
22
|
+
|
|
23
|
+
if any(a in ("-V", "--version") for a in args):
|
|
24
|
+
from . import __version__
|
|
25
|
+
|
|
26
|
+
print(__version__)
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
if args:
|
|
30
|
+
print(
|
|
31
|
+
f"error: unrecognized arguments: {' '.join(args)}\n"
|
|
32
|
+
"Try 'python -m openquantum_mcp --help'.",
|
|
33
|
+
file=sys.stderr,
|
|
34
|
+
)
|
|
35
|
+
raise SystemExit(2)
|
|
36
|
+
|
|
37
|
+
from .server import run
|
|
38
|
+
|
|
39
|
+
run()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
if __name__ == "__main__":
|
|
43
|
+
main()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""Credential resolution and SDK client construction."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
from dataclasses import dataclass
|
|
8
|
+
from typing import Optional, Tuple
|
|
9
|
+
|
|
10
|
+
from openquantum_sdk.auth import ClientCredentials, ClientCredentialsAuth
|
|
11
|
+
from openquantum_sdk.clients import ManagementClient, SchedulerClient
|
|
12
|
+
|
|
13
|
+
from .config import McpConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AuthError(RuntimeError):
|
|
17
|
+
"""Raised when credentials are missing or invalid."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def load_creds_from_file(path: str) -> ClientCredentials:
|
|
21
|
+
with open(path, "r", encoding="utf-8") as f:
|
|
22
|
+
data = json.load(f)
|
|
23
|
+
try:
|
|
24
|
+
return ClientCredentials(
|
|
25
|
+
client_id=data["client_id"], client_secret=data["client_secret"]
|
|
26
|
+
)
|
|
27
|
+
except KeyError as e:
|
|
28
|
+
raise AuthError(f"SDK key file missing field: {e}") from e
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def resolve_credentials() -> ClientCredentials:
|
|
32
|
+
"""Resolve SDK credentials from environment (same rules as openquantum-sdk CLI)."""
|
|
33
|
+
sdk_key_env = os.getenv("OPENQUANTUM_SDK_KEY")
|
|
34
|
+
if sdk_key_env:
|
|
35
|
+
# Set-but-missing path is a config error, not a silent fallback.
|
|
36
|
+
if not os.path.exists(sdk_key_env):
|
|
37
|
+
raise AuthError(
|
|
38
|
+
f"OPENQUANTUM_SDK_KEY is set to {sdk_key_env!r}, but that path "
|
|
39
|
+
"does not exist. Fix the path or unset OPENQUANTUM_SDK_KEY and "
|
|
40
|
+
"use OPENQUANTUM_CLIENT_ID / OPENQUANTUM_CLIENT_SECRET instead."
|
|
41
|
+
)
|
|
42
|
+
return load_creds_from_file(sdk_key_env)
|
|
43
|
+
|
|
44
|
+
env_id = os.getenv("OPENQUANTUM_CLIENT_ID")
|
|
45
|
+
env_secret = os.getenv("OPENQUANTUM_CLIENT_SECRET")
|
|
46
|
+
if env_id and env_secret:
|
|
47
|
+
return ClientCredentials(client_id=env_id, client_secret=env_secret)
|
|
48
|
+
|
|
49
|
+
raise AuthError(
|
|
50
|
+
"Missing credentials. Set OPENQUANTUM_CLIENT_ID and "
|
|
51
|
+
"OPENQUANTUM_CLIENT_SECRET, or OPENQUANTUM_SDK_KEY to a JSON key file "
|
|
52
|
+
"from the Open Quantum portal (SDK keys)."
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@dataclass
|
|
57
|
+
class SdkClients:
|
|
58
|
+
"""Paired management + scheduler clients sharing auth."""
|
|
59
|
+
|
|
60
|
+
management: ManagementClient
|
|
61
|
+
scheduler: SchedulerClient
|
|
62
|
+
config: McpConfig
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def build_clients(config: Optional[McpConfig] = None) -> SdkClients:
|
|
66
|
+
cfg = config or McpConfig.from_env()
|
|
67
|
+
creds = resolve_credentials()
|
|
68
|
+
auth = ClientCredentialsAuth(
|
|
69
|
+
creds=creds,
|
|
70
|
+
keycloak_base=cfg.keycloak_base,
|
|
71
|
+
realm=cfg.keycloak_realm,
|
|
72
|
+
)
|
|
73
|
+
management = ManagementClient(base_url=cfg.management_base, auth=auth)
|
|
74
|
+
scheduler = SchedulerClient(
|
|
75
|
+
base_url=cfg.scheduler_base,
|
|
76
|
+
auth=auth,
|
|
77
|
+
management_client=management,
|
|
78
|
+
)
|
|
79
|
+
return SdkClients(management=management, scheduler=scheduler, config=cfg)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def redact_secrets(text: str) -> str:
|
|
83
|
+
"""Best-effort redaction of credential material from error strings."""
|
|
84
|
+
secret = os.getenv("OPENQUANTUM_CLIENT_SECRET") or ""
|
|
85
|
+
client_id = os.getenv("OPENQUANTUM_CLIENT_ID") or ""
|
|
86
|
+
out = text
|
|
87
|
+
if secret:
|
|
88
|
+
out = out.replace(secret, "[REDACTED_SECRET]")
|
|
89
|
+
if client_id and len(client_id) > 8:
|
|
90
|
+
out = out.replace(client_id, "[REDACTED_CLIENT_ID]")
|
|
91
|
+
return out
|