Quantum Code Validator

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.

Category
Visit Server

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 ast module
    • Verifying code compilation using py_compile
    • Comparing quantum library method usage against official documentation
  • 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:

  1. validate_quantum_method_by_static:

    # Example usage
    result = validate_quantum_method_by_static(
        code="your_quantum_code_here",
        version="v0.41.1"  # Optional
    )
    
  2. 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
  1. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
  2. Install uv (if not already installed):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  3. Install dependencies using uv:

    uv sync
    
  4. Run the server:

    uv run src/server.py
    

<!--

2. Install with Docker

  1. Set the required environment variables (for downloading reference documents from Google Cloud Storage):

    • GOOGLE_CREDENTIALS_JSON: Service account JSON string
    • GCS_BUCKET_NAME: GCS bucket name
    • GCS_PREFIX: (Optional) Prefix within the bucket
  2. 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-validator
    

    You can pass GOOGLE_CREDENTIALS_JSON directly as a string or use a .env file with the --env-file option.

  3. 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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured