A comprehensive workflow system for searching and displaying Title 21 (Food and Drugs) regulations from the Electronic Code of Federal Regulations (eCFR).
- 🔍 Intelligent Search: Search regulations by keywords, parts, chapters, or descriptions
- 🤖 Agent Workflow: Automated agent system for processing regulation queries
- 📊 Summary Table: Beautiful GUI with a comprehensive table summarizing all regulations
- 🔄 Auto-Refresh: Ability to refresh regulation data from the eCFR website
- 💾 Database Caching: SQLite database for fast local searches
- 📈 Statistics Dashboard: Real-time statistics about regulations and searches
The system supports LLM integration for enhanced regulation analysis:
- Get OpenAI API Key: Sign up at https://platform.openai.com/api-keys
- Create
.envfile: Copy.env.exampleto.envand add your API key:cp .env.example .env # Edit .env and add: OPENAI_API_KEY=your_key_here - Features enabled with LLM:
- More accurate status analysis (Allowed/Prohibited)
- Natural language question answering about regulations
- Enhanced regulation summaries
- Better extraction of key requirements
Note: The system works without LLM (using keyword matching), but LLM provides much better accuracy and insights.
Use the provided startup script:
./run.shThis will:
- Create a virtual environment (if needed)
- Install all dependencies
- Start the Flask server
- Open the application at http://localhost:5000
- Create a virtual environment (recommended):
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install Python dependencies:
pip install -r requirements.txt- Run the application:
python app.py- Open your browser and navigate to:
http://localhost:5000
- Enter a search term in the search box (e.g., "medical devices", "drugs", "food")
- Click "Search" or press Enter
- View results in the table below
Click the "Refresh Data" button to fetch the latest regulations from the eCFR website. This process runs in the background.
GET /api/regulations- Get all regulationsPOST /api/search- Search regulations{ "query": "medical devices" }POST /api/refresh- Refresh regulations from eCFRGET /api/stats- Get statistics
- RegulationScraper: Fetches and parses regulations from eCFR website
- RegulationAgent: Processes queries and generates summaries
- Flask API: RESTful API for frontend communication
- SQLite Database: Local caching of regulations
- Web GUI: Modern, responsive interface
regulations table:
- id, title, chapter, subchapter, part, section_range
- description, url, last_updated, content_summary, created_at
search_history table:
- id, query, results_count, created_at
The system includes a comprehensive agent workflow (agent_workflow.py) that provides:
- Intelligent Search: Multi-step search and analysis
- Categorization: Automatic categorization by chapter and subchapter
- Comprehensive Summaries: Detailed analysis of search results
- Batch Processing: Process multiple queries at once
- Recommendations: AI-powered recommendations for related searches
from agent_workflow import RegulationAgentWorkflow
# Initialize agent
agent = RegulationAgentWorkflow()
# Simple search
results = agent.search("medical devices")
# Comprehensive analysis
analysis = agent.analyze("drug approval", context="FDA submission")
# Batch processing
queries = ["medical devices", "food labeling", "drugs"]
batch_results = agent.batch_search(queries)
# Get recommendations
recommendations = agent.get_recommendations("medical devices")MCP (Model Context Protocol) is fully implemented! The system exposes:
- Resources: All regulations exposed as MCP resources (
regulation://{id}) - Tools: 5 MCP tools for search, Q&A, and monitoring
- Standardized Interface: Works with Cursor, Claude Desktop, and other MCP clients
- RAG-Powered: Tools use semantic search for better results
-
Install MCP SDK:
pip install 'mcp[cli]' -
Start Flask app (Terminal 1):
python app.py
-
Start MCP server (Terminal 2):
# Using FastMCP (recommended, simpler) python mcp_server_fast.py # Or using standard MCP Server python mcp_server.py
-
Configure MCP client (Cursor/Claude Desktop):
{ "mcpServers": { "regulations": { "command": "python", "args": ["/path/to/regulations/mcp_server_fast.py"], "env": { "API_BASE_URL": "http://localhost:5000" } } } }
search_regulations: Semantic search with RAGask_regulation_question: Natural language Q&Aget_regulation_by_id: Get specific regulationget_recent_changes: Monitor regulation updatesget_regulation_stats: Database statistics
See MCP_IMPLEMENTATION.md for detailed documentation.
- The eCFR website may require IP whitelisting for programmatic access
- Regulations are cached locally for faster searches
- The scraper respects the website's structure and extracts hierarchical data
- Search is case-insensitive and searches across multiple fields
MIT License