Skip to main content

Rocq MCP Server

Tests Python 3.10+ License

Overview

This MCP server exposes the functionality of the Rocq/Coq proof assistant through a set of tools that can be used by MCP-compatible clients (like Claude Desktop). It uses the Pytanque to communicate with a coq-lsp via a Petanque server.

Features

Available Tools

  • rocq_start_proof: Start a proof session for a specific theorem in a Coq/Rocq file
  • rocq_run_tactic: Execute tactics or commands on the current proof state
  • rocq_get_goals: Get the current proof goals for a session
  • rocq_get_premises: Get available premises (lemmas, definitions) for the current proof state
  • rocq_get_file_toc: Get table of contents (available definitions and theorems) for a Coq/Rocq file
  • rocq_search: Search for theorems, definitions, and other objects in the current context
  • rocq_parse_ast: Parse a command and return its Abstract Syntax Tree (only with the dev version of coq-lsp)
  • rocq_get_state_at_position: Get the proof state at a specific position in a file (only with the dev version of coq-lsp)

Key Capabilities

  • Two communication modes:

    • Stdio mode (default): direct communication with pet process via stdin/stdout.
    • TCP mode: socket-based communication with pet-server via TCP.
  • Interactive theorem proving: Execute tactics and commands step by step

  • Comprehensive feedback: Access all Rocq messages (errors, warnings, search results)

  • State management: Navigate proof states and compare them

  • Session management: Support multiple concurrent proof sessions

  • AST parsing: Get abstract syntax trees for commands and file positions (only with the dev version of coq-lsp)

  • Position-based queries: Get states at specific file positions (only with the dev version of coq-lsp)

Prerequisites

Install coq-lsp with Petanque support:

# Install dependencies
opam install lwt logs coq-lsp

# Or install one of the dev versions of coq-lsp, e.g., for Coq.8.20
opam install lwt logs coq.8.20.0
opam pin add coq-lsp https://github.com/ejgallego/coq-lsp.git#v8.20

Installation

Install from GitHub (Recommended)

pip install git+https://github.com/llm4rocq/rocq-mcp.git

Development Installation

We recommand using uv.

  1. Clone this repository
  2. Use the project workflow:
    cd rocq-mcp
    uv sync
    

Usage

Running the MCP Server

# Default: stdio mode (uses 'pet' command directly)
rocq-mcp

# Use TCP mode for multi-client usage
rocq-mcp --tcp

# TCP mode with custom server configuration  
rocq-mcp --tcp --host 127.0.0.1 --port 8833

Development mode (if using uv sync):

uv run rocq-mcp
uv run rocq-mcp --tcp

Communication Modes:

  • Stdio mode (default): Spawns and communicates directly with the pet process via stdin/stdout. This is more efficient and simpler as it doesn't require a separate server process.
  • TCP mode: Starts a pet-server process and communicates via TCP socket. Use this for multi-client usage scenarios where multiple applications need to connect to the same Petanque instance.

MCP Client Configuration

Run the following command to install rocq-mcp for claude code.

claude mcp add rocq-mcp -- rocq-mcp

Note: If you are using virtual envs, rocq-mcp may not be in the path by default. First, activate the venv, and copy the path returned by which rocq-mcp. Then install rocq-mcp using this absolute path:

claude mcp add rocq-mcp -- /path/to/rocq-mcp

When you start a claude session, you can check the server with:

> /mcp

Then, simply ask claude a question.

> help me prove addnC in test.v

Testing

# Install with dev dependencies
uv sync --dev

# Run tests
uv run pytest tests/

Troubleshooting

Common Issues

Server Connection Errors

  • Verify port availability
  • Check that coq-lsp is properly installed

Installation Issues

  • Ensure coq-lsp is properly installed
  • Install lwt and logs before coq-lsp (required for pet and pet-server)
  • Verify pytanque dependency is correctly resolved

Note: This project was build with the help of Claude from the code of pytanque.

Related Projects

  • pytanque: Python client for the Petanque protocol
  • coq-lsp: Language server for Coq/Rocq
  • MCP: Model Context Protocol specification

Metadata

Release files for iflow-mcp-rocq 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iflow-mcp-rocq 0.1.2
File Size Uploaded
iflow_mcp_rocq-0.1.2.tar.gz 13.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iflow-mcp-rocq 0.1.2
File Interpreter ABI Platform
iflow_mcp_rocq-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 26.2 kB

Release files / iflow_mcp_rocq-0.1.2.tar.gz

Download URL iflow_mcp_rocq-0.1.2.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6a490f9df3e173b8b0e49cb3c2419618c55e68e0d4802b09b630634044b99d14
BLAKE2b-256 checksum
How to use checksums
f6c750313fac7e421cd7643595e51a3e495a7f6b82de67b41457d6988c037af7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / iflow_mcp_rocq-0.1.2-py3-none-any.whl

Download URL iflow_mcp_rocq-0.1.2-py3-none-any.whl
Size 12.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3cba686da87923fbf8f9ebf670c54880748130993c26901910f8ff8589e5c5ca
BLAKE2b-256 checksum
How to use checksums
8e1fabf9f7db52ed01a2a0c5f053a889ec84dcc5fe2e482f6fa64a779019b572
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page