Constitute MCP Server
A Model Context Protocol (MCP) server that provides tools for analyzing and scraping constitutional documents from the Constitute Project.
Features
This MCP server provides comprehensive tools for constitutional analysis:
Core Functionality
- Constitution Listing: Get lists of all available constitutions with filtering options
- Country Search: Find constitutions by country name with fuzzy matching
- Full Text Scraping: Extract complete constitutional documents with structured parsing
- Article Retrieval: Access specific articles by number or ranges
- Keyword Search: Find articles containing specific terms
- Topic Analysis: Search constitutions by legal topics (e.g., economic planning, environment, judiciary)
- Data Export: Save constitutions as JSON or plain text files
- Batch Operations: Scrape multiple constitutions efficiently
Available Tools
- get_constitutions_list - List all available constitutions
- find_constitution_by_country - Search constitutions by country name
- scrape_constitution - Download and parse a complete constitution
- get_article_by_number - Retrieve a specific article
- get_articles_range - Get multiple articles in a range
- search_articles_by_keyword - Find articles containing keywords
- topic_constitutions - Find constitutions by topic
- topic_sections - Get topic-related sections from constitutions
- export_constitution_json - Export constitution as JSON
- export_constitution_text - Export constitution as plain text
- scrape_all_constitutions - Batch scrape operation
Installation
Using uvx (Recommended)
# Install directly from PyPI (once published)
uvx constitute-mcp
# Or install from local development
uvx --from . constitute-mcp
Using pip
pip install constitute-mcp
Development Installation
Linux/macOS
# Clone the repository
git clone https://github.com/yourusername/constitute-mcp.git
cd constitute-mcp
# Initialize development environment
make init
Windows
# Clone the repository
git clone https://github.com/yourusername/constitute-mcp.git
cd constitute-mcp
# Initialize development environment
scripts\setup.bat
For detailed Windows instructions, see README_Windows.md.
Usage
As an MCP Server
Add to your MCP client configuration:
{
"mcpServers": {
"constitute": {
"command": "constitute-mcp"
}
}
}
Example Usage
# Example tool calls through MCP client
# List all constitutions
get_constitutions_list()
# Find constitutions for a specific country
find_constitution_by_country(country_name="Taiwan")
# Scrape a specific constitution
scrape_constitution(constitution_id="taiwan")
# Get a specific article
get_article_by_number(constitution_id="taiwan", article_number="1")
# Search for articles about "freedom"
search_articles_by_keyword(constitution_id="taiwan", keyword="freedom")
# Find constitutions dealing with economic planning
topic_constitutions(topic_key="econplan")
Configuration
The server automatically handles:
- Rate limiting (1 second delay between requests)
- Request logging with unique IDs
- Error handling and retry logic
- File naming sanitization for Windows compatibility
Data Sources
This server uses the Constitute Project API (https://constituteproject.org), which provides:
- 200+ constitutions from around the world
- Current and historical constitutional texts
- Structured data about constitutional topics
- Professional legal annotations
Development
Project Structure
constitute-mcp/
├── constitute_mcp/
│ ├── __init__.py
│ ├── server.py # Main MCP server implementation
│ └── scraper.py # Constitution scraping logic
├── pyproject.toml # Project configuration
├── README.md
└── scripts/
├── publish_to_pypi.py # Automated PyPI publishing
└── version_manager.py # Automatic version management
Running Tests
pytest
Code Quality
# Format code
black constitute_mcp/
# Check imports
isort constitute_mcp/
# Type checking
mypy constitute_mcp/
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and quality checks
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Constitute Project for providing the constitutional database
- Model Context Protocol for the integration framework
Metadata
Release files for constitute-mcp 0.1.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| constitute_mcp-0.1.27.tar.gz | 21.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| constitute_mcp-0.1.27-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.4 kB
Release files / constitute_mcp-0.1.27.tar.gz
| Download URL | constitute_mcp-0.1.27.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e3431a4b928f89a4abedf552b0ec0373667f4a9cdf397070c863fc6cc6975ffc
|
|
BLAKE2b-256 checksum How to use checksums |
205dfa9fb1f0ed8cb3028bfed009556367d185067cab1e160c16e93322f4f811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / constitute_mcp-0.1.27-py3-none-any.whl
| Download URL | constitute_mcp-0.1.27-py3-none-any.whl |
|---|---|
| Size | 20.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
937a5ed08c10213a6170b9cbcf3e5607f70d15a4ea64bb90dfef9497b355ef60
|
|
BLAKE2b-256 checksum How to use checksums |
bec5863491d65f79f08cbf6439bed169d829c4f10880eec1ab246eada6f57e29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.15 {"installer":{"name":"uv","version":"0.11.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|