ChrisTansey007/permit-data-mcp-server-nhc
If you are the rightful owner of permit-data-mcp-server-nhc and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The PermitData FastMCP Server for New Hanover County is a comprehensive solution for managing building permit data through ArcGIS Feature Services integration.
check_permit_data
Verify data freshness and synchronization status.
download_permits
Fetch all permits with intelligent caching and pagination.
get_recent_permits
Retrieve permits based on date criteria.
filter_permits
Apply Python expressions to filter permit datasets.
permit_stats_summary
Generate statistical summaries grouped by specified fields.
PermitData FastMCP Server - New Hanover County (NHC)
A comprehensive FastMCP server providing 8 specialized tools for managing New Hanover County building permit data through ArcGIS Feature Services integration.
๐ Quick Start
# Clone the repository
git clone https://github.com/yourusername/permit-data-mcp-server-nhc.git
cd permit-data-mcp-server-nhc
# Install dependencies
pip install -r requirements.txt
# Copy environment template
cp .env.example .env
# Run the server
python permit_mcp_server_nhc.py
The server will start at http://localhost:8000/mcp
๐ Features
Data Management
- check_permit_data: Verify data freshness and compare local vs server records
- download_permits: Fetch all permits with intelligent caching and pagination
- get_recent_permits: Retrieve permits based on date criteria
Analytics & Filtering
- filter_permits: Apply Python expressions to filter permit datasets
- permit_stats_summary: Generate statistical summaries grouped by specified fields
State Management
- get_current_subcontractors: Retrieve cached subcontractor list
- update_current_subcontractors: Add/remove subcontractors from persistent state
Reporting
- generate_reports: Create markdown and CSV reports with timestamped outputs
๐ Configuration
Environment Variables
Create a .env
file from .env.example
and configure:
# Data storage
DATA_DIR=./data
# New Hanover County ArcGIS endpoints
PERMIT_FEATURESERVER_URL_PRIMARY=https://gis.nhcgov.com/server/rest/services/Thematic/BuildingPermits/FeatureServer/0/query
# State management
SUBSCRIBER_STATE_PATH=./data/current_subs.json
REPORTS_OUTPUT_DIR=./data
# Optional API authentication
# MCP_API_KEY=your_secure_api_key_here
# Server configuration
PORT=8000
Required Dependencies
- fastmcp >=0.1.0: FastMCP framework
- pandas >=2.0.0: Data manipulation and analysis
- requests >=2.31.0: HTTP client for API calls
- python-dateutil >=2.8.2: Date parsing utilities
- python-dotenv >=1.0.0: Environment variable management
๐ณ Docker Deployment
Using Docker Compose (Recommended)
# Build and start the service
docker-compose up -d
# View logs
docker-compose logs -f
# Stop the service
docker-compose down
Using Docker Directly
# Build the image
docker build -t permit-mcp-server-nhc .
# Run the container
docker run -d \
--name permit-mcp-nhc \
-p 8000:8000 \
-v $(pwd)/data:/app/data \
-v $(pwd)/logs:/app/logs \
permit-mcp-server-nhc
๐ API Reference
Tool: check_permit_data
Verify data freshness and synchronization status.
Parameters:
base_url
(str): ArcGIS Feature Service URLlocal_csv
(str): Path to local CSV file for comparisondelta_days
(int, default=1): Days threshold for staleness checkstrict
(bool, default=False): Raise exceptions on errors
Returns:
{
"is_stale": true,
"server_record_count": 1250,
"server_last_edit": "2025-01-15T10:30:00",
"local_record_count": 1245,
"local_last_modified": "2025-01-14T15:20:00",
"reason": "stale counts / age"
}
Tool: download_permits
Fetch all permits with intelligent caching and pagination.
Parameters:
base_url
(str): ArcGIS Feature Service URLforce
(bool, default=False): Force download even if cache is freshwhere
(str, default="1=1"): SQL WHERE clause for filteringpage_size
(int, default=10000): Records per API requestout_csv
(str, optional): Output CSV path for caching
Returns:
{
"records": 1250,
"csv_path": "./data/permits.csv",
"dataframe": [...],
"skipped": false
}
Tool: get_recent_permits
Retrieve permits based on date criteria.
Parameters:
base_url
(str): ArcGIS Feature Service URLsince
(str): ISO date string (required)date_field
(str, default="ISSUE_DATE"): Date field to filter onpage_size
(int, default=10000): Records per API request
Tool: filter_permits
Apply Python expressions to filter permit datasets.
Parameters:
permits_json
(List[Dict]): Permit records to filterfilter_expr
(str): Python expression (e.g., "row['PERMIT_VALUE'] > 50000")
Tool: permit_stats_summary
Generate statistical summaries grouped by specified fields.
Parameters:
permits_json
(List[Dict]): Permit records to analyzegroup_by
(str, default="GENERAL_CONTRACTOR"): Field to group by
๐งช Testing
Run the test suite with pytest:
# Install test dependencies
pip install pytest
# Run all tests
pytest test_permit_server.py -v
# Run with coverage
pip install pytest-cov
pytest test_permit_server.py --cov=permit_mcp_server_nhc
๐ Project Structure
permit-data-mcp-server-nhc/
โโโ permit_mcp_server_nhc.py # Main FastMCP server
โโโ requirements.txt # Python dependencies
โโโ .env.example # Environment template
โโโ Dockerfile # Container configuration
โโโ docker-compose.yml # Docker orchestration
โโโ test_permit_server.py # Test suite
โโโ README.md # This file
โโโ LICENSE # MIT License
โโโ .gitignore # Git ignore rules
โโโ data/ # Runtime data storage
โโโ logs/ # Application logs
๐ง Development
Local Development Setup
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -r requirements.txt
pip install pytest pytest-cov black flake8
# Format code
black .
# Lint code
flake8 permit_mcp_server_nhc.py
# Run server in development mode
python permit_mcp_server_nhc.py
Data Source Information
This server connects to New Hanover County's public ArcGIS Feature Service:
- Service URL: https://gis.nhcgov.com/server/rest/services/Thematic/BuildingPermits/FeatureServer/0
- Data Type: Building permits issued by New Hanover County
- Update Frequency: Real-time (as permits are processed)
- Geographic Coverage: New Hanover County, North Carolina
Note: Unlike Brunswick County, New Hanover County does not expose public EnerGov/COAST endpoints for contractor contact information.
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
๐ License
This project is licensed under the MIT License - see the file for details.
๐ Support
- Issues: Report bugs or request features via GitHub Issues
- Documentation: FastMCP documentation at https://github.com/jlowin/fastmcp
- Data Source: New Hanover County GIS portal
๐ Related Projects
- Brunswick County Permit MCP Server - Original template
- FastMCP Framework - Underlying MCP framework
Built with โค๏ธ using FastMCP for New Hanover County permit data management.