Quantum Code Validator
An MCP server that provides static validation and documentation lookup for quantum computing libraries, currently supporting PennyLane. It allows users to verify quantum code syntax and method usage against official library documentation to ensure correct implementation.
README
Quantum Code Validator
A Model Context Protocol (MCP) server for validating quantum computing library code. Currently supports PennyLane, with plans to expand support for other quantum computing libraries in the future.
Overview
The Quantum Code Validator is a tool that helps developers ensure their quantum computing code is valid and follows the correct usage patterns for various quantum libraries. It provides static validation of quantum code against official documentation and offers reference documentation lookup capabilities.
Features
- Static Code Validation: Validates quantum code by:
- Checking code syntax using Python's
astmodule - Verifying code compilation using
py_compile - Comparing quantum library method usage against official documentation
- Checking code syntax using Python's
- Reference Documentation Lookup: Retrieves method documentation for specific versions of quantum libraries
- Version-Specific Validation: Supports validation against specific versions of quantum libraries
- Extensible Architecture: Designed to support multiple quantum computing libraries
Current Support
- PennyLane: Full support for static validation and reference documentation lookup
- Supported versions: v0.35.0 - v0.41.1
Planned Support
The following quantum computing libraries are planned for future support:
- Qulacs
- Qiskit
- Cirq
- cuQuantum
- And more...
Usage
The server provides two main tools:
-
validate_quantum_method_by_static:# Example usage result = validate_quantum_method_by_static( code="your_quantum_code_here", version="v0.41.1" # Optional ) -
request_quantum_method_reference:# Example usage docs = request_quantum_method_reference( method_name="qml.CNOT", # Method name without arguments version="v0.41.1" # Optional )
Installation
1. Install with uv
git clone https://github.com/yourusername/quantum-code-validator.git
cd quantum-code-validator
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate -
Install uv (if not already installed):
curl -LsSf https://astral.sh/uv/install.sh | sh -
Install dependencies using uv:
uv sync -
Run the server:
uv run src/server.py
<!--
2. Install with Docker
-
Set the required environment variables (for downloading reference documents from Google Cloud Storage):
GOOGLE_CREDENTIALS_JSON: Service account JSON stringGCS_BUCKET_NAME: GCS bucket nameGCS_PREFIX: (Optional) Prefix within the bucket
-
Build and run the container:
docker build -t quantum-code-validator . docker run -p 8000:8000 \ -e GOOGLE_CREDENTIALS_JSON='...' \ -e GCS_BUCKET_NAME='your-bucket' \ -e GCS_PREFIX='your/prefix' \ quantum-code-validatorYou can pass
GOOGLE_CREDENTIALS_JSONdirectly as a string or use a.envfile with the--env-fileoption. -
The server will start on port 8000 by default. -->
Setting MCP Server
1. Local MCP Server by uv
1.1 Load and Parse PennyLane Source Code
Load basic information from PennyLane's source code and save it as JSON files by version. The PennyLane version will be the one installed in the execution environment, so please switch it using the uv command as needed.
uv run scripts/parse_pennylane_api.py ./refdocs/pennylane/raw/v0.41.1.json
1.2 Format Source Code to Document
Next, we will use an LLM to format the basic information extracted in Step 1 into document information that can be accessed on MCP. Please specify the PennyLane versions to be converted into documents as a comma-separated list. Note that this process uses an LLM, so the "OPENAI_API_KEY" environment variable must be set, and there is a cost of approximately $2.50 per version. The formatting results will be saved in "./refdocs/pennylane/formatted".
uv run scripts/format_docs_by_llm.py v0.41.0,v0.41.1
1.3 Setup MCP Server on Local
Finally, by configuring the mcp.json file according to the platform and starting the MCP server, the tool becomes available for use with the target tool. As a reference, a link to the documentation on how to configure it for Claude Desktop is provided.
{
"mcpServers": {
"quantum-code-validator": {
"command": "uv",
"args": [
"--directory",
"/your/mcp/server/directory/quantum-code-validator",
"run",
"server.py",
"--transport",
"stdio"
]
}
}
}
<!--
2. Use Remote Server
Although Claude Desktop does not support MCP servers launched remotely, tools such as Cline or Cursor can connect to MCP via a remote server using the following configuration.
{
"mcpServers": {
"quantum-code-validator": {
"url": "https://quantum-code-validator.onrender.com/sse"
}
}
}
-->
License
This project is licensed under the MIT License - see the LICENSE file for details.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。