Lawmesh MCP Server
Enables AI agents to query U.S. legislative data, including jurisdictions, legislators, and bills, via the OpenStates API.
README
Lawmesh MCP Server
A comprehensive Model Context Protocol (MCP) server providing AI agents with powerful tools to access U.S. legislative data through the OpenStates API v3.
Live Deployment
Public MCP Server: https://pk-dev-Lawmesh.hf.space/mcp
The server is deployed on Hugging Face Spaces and ready for immediate use with any MCP-compatible client.
Available Tools
Lawmesh provides four comprehensive tools for querying U.S. legislative information:
1. list_jurisdictions
Retrieve all available U.S. jurisdictions (states, territories, federal districts) with optional filtering.
Parameters:
classification(optional): Filter by type ("state", "municipality", "country")include(optional): Additional data ("organizations", "legislative_sessions", "latest_runs")page,per_page: Pagination support
2. get_jurisdiction
Get detailed metadata for a specific jurisdiction.
Parameters:
jurisdiction(required): State abbreviation, full name, or OpenStates IDinclude(optional): Additional data to include
3. get_people
Search for legislators, governors, and government officials.
Parameters:
jurisdiction,name,id: Filter criteria (at least one required)org_classification: Role filter ("upper", "lower", "executive")district: District filterinclude: Additional biographical data- Pagination support
4. get_bills
Search legislative bills, resolutions, and documents.
Parameters:
jurisdiction,session,chamber: Basic filtersidentifier: Specific bill numbersclassification: Bill type ("bill", "resolution")subject,sponsor: Content and sponsor filtersq: Full-text searchupdated_since,created_since,action_since: Date filtersinclude: Additional data (votes, actions, documents, etc.)sort: Sort options- Pagination support
Architecture
Lawmesh is built using:
- FastMCP: Modern MCP server framework
- Streamable HTTP Transport: Optimized for web deployment
- OpenStates API v3: Authoritative source for U.S. legislative data
- Async Architecture: High-performance concurrent request handling
┌─────────────────┐ HTTP/MCP ┌─────────────────┐ HTTPS/API ┌─────────────────┐
│ MCP Client │ <-------------> │ Lawmesh Server │ <-------------> │ OpenStates API │
│ (Claude, etc.) │ │ (FastMCP) │ │ (v3) │
└─────────────────┘ └─────────────────┘ └─────────────────┘
Quick Start with MCP Client
Example: Python MCP Client
import asyncio
from mcp import create_client_session
from mcp.client.transports.http import create_http_transport
async def main():
# Connect to the deployed Lawmesh server
transport = create_http_transport("https://pk-dev-Lawmesh.hf.space/mcp")
async with create_client_session(transport) as session:
# List available tools
tools = await session.list_tools()
print("Available tools:", [tool.name for tool in tools.tools])
# Example: Get California jurisdictions
result = await session.call_tool("list_jurisdictions", {
"classification": "state",
"per_page": 10
})
print("Jurisdictions:", result.content)
# Example: Search for bills about education in California
bills = await session.call_tool("get_bills", {
"jurisdiction": "ca",
"subject": "education",
"per_page": 5
})
print("Education bills:", bills.content)
if __name__ == "__main__":
asyncio.run(main())
Example: Using with Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"lawmesh": {
"url": "https://pk-dev-Lawmesh.hf.space/mcp"
}
}
}
Local Development Setup
Prerequisites
- Python 3.13+
- OpenStates API Key: Get one at OpenStates.org
- Environment Setup
Installation
- Clone the repository:
git clone <repository-url>
cd Lawmesh
- Install dependencies:
# Using pip
pip install -r requirements.txt
# Or using uv (recommended)
uv sync
- Environment Configuration:
Create a
.envfile:
# .env
OPENSTATES_API_KEY=your_openstates_api_key_here
- Run the server:
# Development mode
python app.py
# Or with uvicorn
uvicorn app:app --host 0.0.0.0 --port 7860 --reload
The server will be available at: http://localhost:7860/mcp
Local Testing
Test your local server with MCP Inspector:
npx @modelcontextprotocol/inspector http://localhost:7860/mcp
Docker Deployment
Using the included Dockerfile:
# Build the image
docker build -t lawmesh-mcp .
# Run with environment variable
docker run -p 7860:7860 -e OPENSTATES_API_KEY=your_key_here lawmesh-mcp
Docker Compose:
# docker-compose.yml
version: '3.8'
services:
lawmesh:
build: .
ports:
- "7860:7860"
environment:
- OPENSTATES_API_KEY=${OPENSTATES_API_KEY}
env_file:
- .env
Dependencies
Core dependencies from pyproject.toml:
- fastmcp>=2.12.3: MCP server framework
- httpx>=0.28.1: Async HTTP client for API calls
- uvicorn>=0.36.0: ASGI server
- python-dotenv>=1.1.1: Environment variable management
- mcp[cli]>=1.14.1: MCP protocol support
Security & Configuration
Environment Variables
| Variable | Required | Description |
|---|---|---|
OPENSTATES_API_KEY |
Yes | Your OpenStates API key |
PORT |
No | Server port (default: 7860) |
HOST |
No | Server host (default: 0.0.0.0) |
API Key Security
- Never commit API keys to version control
- Use environment variables or secure secret management
- For Hugging Face Spaces: Configure as Repository Secrets
Use Cases
- Political Research: Track legislation and voting patterns
- Government Transparency: Access public legislative records
- Civic Engagement: Build tools for citizen participation
- Academic Research: Study U.S. political processes
- News & Media: Automated legislative monitoring
- Legal Research: Access bill text and legislative history
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
This project is open source. Please check the LICENSE file for details.
Support
- Issues: Report bugs and feature requests via GitHub Issues
- Documentation: OpenStates API v3 docs at docs.openstates.org
- MCP Protocol: Learn more at modelcontextprotocol.io
Built with ❤️ using FastMCP and OpenStates API
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。