MCP server for the Qiskit Code Assistant
Project description
qiskit-code-assistant-mcp-server
MCP server for Qiskit Code Assistant
Components
Tools
The server implements one tool:
qca_completion: Get completion for a given prompt- Takes a "prompt" as a required string argument
- Connects to a Qiskit Code Assistant service and returns a code completion based on the prompt
Prerequisites
- Python 3.10 or higher
- uv package manager (recommended)
- IBM Quantum account and API token
- Access to Qiskit Code Assistant service
Installation
This project uses uv for virtual environments and dependencies management. If you don't have uv installed, check out the instructions in https://docs.astral.sh/uv/getting-started/installation/
Setting up the Project with uv
-
Initialize or sync the project:
# This will create a virtual environment and install dependencies uv sync
-
Configure environment variables:
# Copy the example environment file cp .env.example .env # Edit .env and add your IBM Quantum API token # Get your token from: https://cloud.quantum.ibm.com/
Quick Start
Running the Server
uv run qiskit-code-assistant-mcp-server
The server will start and listen for MCP connections.
Using Sync Wrappers
For frameworks that don't support async operations (DSPy, traditional scripts, etc.), use the synchronous wrappers:
from qiskit_code_assistant_mcp_server.sync import (
qca_get_completion_sync,
qca_get_rag_completion_sync,
qca_list_models_sync
)
# Use synchronously without async/await
result = qca_get_completion_sync("Write a quantum circuit for a Bell state")
print(result)
# Works in Jupyter notebooks
rag_result = qca_get_rag_completion_sync("What is quantum entanglement?")
print(rag_result)
Available sync functions:
qca_list_models_sync()- List available modelsqca_get_model_sync(model_id)- Get model infoqca_get_completion_sync(prompt)- Get code completionqca_get_rag_completion_sync(prompt)- Get RAG-based completionqca_accept_completion_sync(completion_id)- Accept a completionqca_get_service_status_sync()- Get service status
Testing and debugging the server
Note: to launch the MCP inspector you will need to have
nodeandnpm
-
From a terminal, go into the cloned repo directory
-
Switch to the virtual environment
source .venv/bin/activate
-
Run the MCP Inspector:
npx @modelcontextprotocol/inspector uv run qiskit-code-assistant-mcp-server
-
Open your browser to the URL shown in the console message e.g.,
MCP Inspector is up and running at http://localhost:5173
Testing
This project includes comprehensive unit and integration tests.
Running Tests
Quick test run:
./run_tests.sh
Manual test commands:
# Install test dependencies
uv sync --group dev --group test
# Run all tests
uv run pytest
# Run only unit tests
uv run pytest -m "not integration"
# Run only integration tests
uv run pytest -m "integration"
# Run tests with coverage
uv run pytest --cov=src --cov-report=html
# Run specific test file
uv run pytest tests/test_qca.py -v
Test Structure
tests/test_qca.py- Unit tests for QCA functionstests/test_utils.py- Unit tests for utility functionstests/test_constants.py- Unit tests for configurationtests/test_integration.py- Integration teststests/conftest.py- Test fixtures and configuration
Test Coverage
The test suite covers:
- ✅ All QCA API interactions
- ✅ Error handling and validation
- ✅ HTTP client management
- ✅ Configuration validation
- ✅ Integration scenarios
- ✅ Resource and tool handlers
Resources
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qiskit_code_assistant_mcp_server-0.1.0.tar.gz.
File metadata
- Download URL: qiskit_code_assistant_mcp_server-0.1.0.tar.gz
- Upload date:
- Size: 98.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
011d99cbd3c373b2581f0c6b5dc87a60f37ec1f657019931494a4606c26ed7ff
|
|
| MD5 |
a4400c46d4e9fb9bdf1bbebc8d45e6e5
|
|
| BLAKE2b-256 |
0372f9556b94f6b33c04c2ef1d657699b0d94771b0519889fffea6d7bfd92e86
|
File details
Details for the file qiskit_code_assistant_mcp_server-0.1.0-py3-none-any.whl.
File metadata
- Download URL: qiskit_code_assistant_mcp_server-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3872e579614c8c582547168c252354b2a25a9d736bbbc5ce9215f2ea6bd73ea2
|
|
| MD5 |
a8f7c8dcfdd397f38514bb25d7f85f84
|
|
| BLAKE2b-256 |
3cc966c4813ec75e937e3efeb957720ed8103cd7b4e123615e7f9928a19255dc
|