BLS MCP Server
Enables access to Bureau of Labor Statistics (BLS) economic data including Consumer Price Index, employment statistics, and other labor market indicators. Supports fetching data series, listing available datasets, and retrieving metadata through natural language queries.
README
BLS MCP Server
A standalone MCP (Model Context Protocol) server for Bureau of Labor Statistics (BLS) data, designed to work with multiple LLM clients through both local and remote connections.
Features
- Official MCP SDK: Built with the official
mcpPython SDK for full protocol control - Mock Data First: Uses realistic mock BLS data for rapid development and testing
- Multiple Transports: Supports both stdio (local) and SSE (remote via ngrok)
- Multi-LLM Compatible: Test with Claude, GPT-4, and other MCP-compatible clients
- Modular Design: Clean separation between tools, resources, and data providers
Quick Start
Installation
Option 1: Using UV (Recommended - 10x faster!)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Navigate to project
cd bls_mcp
# Sync dependencies (creates .venv automatically)
uv sync
# Run the server
./scripts/uv_start_server.sh
# Test the server
./scripts/uv_test_client.sh
See UV_USAGE.md for comprehensive UV documentation.
Option 2: Using pip (Traditional)
# Clone the repository
cd bls_mcp
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Or install with dev dependencies
pip install -e ".[dev]"
Running the Server (Local)
# With UV (recommended)
./scripts/uv_start_server.sh
# Or with traditional Python
python scripts/start_server.py
Testing with MCP Inspector
# Install MCP inspector (if not already installed)
npm install -g @modelcontextprotocol/inspector
# Run inspector
mcp-inspector python scripts/start_server.py
Project Status
Current Phase: Phase 1 - Foundation
- [x] Project structure created
- [x] Configuration files set up
- [ ] Mock data system implemented
- [ ] Core MCP server implemented
- [ ] Basic tools implemented
- [ ] Tests written
Available Tools (Phase 1)
get_series
Fetch BLS data series by ID with optional date range filtering.
Parameters:
series_id(string, required): BLS series ID (e.g., "CUUR0000SA0")start_year(integer, optional): Start year for data rangeend_year(integer, optional): End year for data range
Example:
{
"name": "get_series",
"arguments": {
"series_id": "CUUR0000SA0",
"start_year": 2020,
"end_year": 2024
}
}
list_series
List available BLS series with optional filtering.
Parameters:
category(string, optional): Filter by category (e.g., "CPI", "Employment")limit(integer, optional): Maximum number of results (default: 50)
get_series_info
Get detailed metadata about a specific BLS series.
Parameters:
series_id(string, required): BLS series ID
Architecture
Directory Structure
bls_mcp/
├── src/bls_mcp/
│ ├── server.py # Main MCP server
│ ├── transports/
│ │ ├── stdio.py # stdio transport (local)
│ │ └── sse.py # SSE transport (remote - Phase 2)
│ ├── tools/
│ │ ├── base.py # Base tool class
│ │ ├── get_series.py # Get series tool
│ │ ├── list_series.py # List series tool
│ │ └── get_series_info.py # Get series info tool
│ ├── data/
│ │ ├── mock_data.py # Mock data provider
│ │ └── fixtures/ # JSON data fixtures
│ └── utils/
│ ├── logger.py # Logging configuration
│ └── validators.py # Input validation
├── tests/ # Test suite
├── scripts/ # Utility scripts
└── docs/ # Documentation
Data Flow
- Client Request → MCP protocol (JSON-RPC)
- Transport Layer → stdio or SSE
- Server Router → Route to appropriate tool
- Tool Execution → Fetch data from provider
- Data Provider → Mock or real data source
- Response → JSON formatted response
Mock Data
The server uses realistic mock BLS data that follows the actual BLS API structure:
- CPI Series: Consumer Price Index data for various categories
- Time Range: 2020-2024 with monthly data points
- Coverage: Multiple categories (All Items, Food, Energy, Housing, etc.)
- Realistic Values: Based on actual BLS data patterns
Development
Running Tests
# Run all tests
pytest
# Run with coverage
pytest --cov=bls_mcp
# Run specific test file
pytest tests/test_tools.py
Code Quality
# Format code
black src/ tests/
# Lint code
ruff check src/ tests/
# Type checking
mypy src/
Adding New Tools
- Create tool file in
src/bls_mcp/tools/ - Implement tool class following the base pattern
- Register tool in
server.py - Add tests in
tests/test_tools.py - Update documentation
Roadmap
Phase 1: Foundation (Current)
- [x] Project setup and configuration
- [ ] Mock data system
- [ ] Core MCP server with stdio transport
- [ ] Basic tools (get_series, list_series, get_series_info)
- [ ] Unit tests
Phase 2: Remote Access
- [ ] SSE transport implementation
- [ ] ngrok integration
- [ ] Multi-LLM client testing
- [ ] Enhanced tools with visualization
Phase 3: Advanced Features
- [ ] MCP resources (catalogs, documentation)
- [ ] Pre-built prompts for analysis
- [ ] Advanced analysis tools
- [ ] Migration path to real BLS data
Configuration
Create a .env file (copy from .env.example):
MCP_SERVER_PORT=3000
MCP_SERVER_HOST=localhost
LOG_LEVEL=INFO
DATA_PROVIDER=mock
Contributing
This is a personal project, but suggestions and feedback are welcome!
License
MIT License - see LICENSE file for details
Related Projects
- bls_data - Comprehensive BLS data toolkit (parent project)
- Model Context Protocol - MCP specification and documentation
Support
For issues or questions, please refer to the documentation in the docs/ directory or check the PLAN.md file for development 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 模型以安全和受控的方式获取实时的网络信息。