
Grants Search
STDIOMCP server for searching government grants by keywords
MCP server for searching government grants by keywords
A Model Context Protocol (MCP) server for comprehensive government grants discovery and analysis, powered by the Simpler Grants API.
The Grants MCP Server is a Python-based MCP implementation using FastMCP that provides intelligent tools for discovering, analyzing, and tracking government grant opportunities. It offers multiple specialized tools for different aspects of grant research, from opportunity discovery to funding trend analysis and agency landscape mapping.
git clone https://github.com/Tar-ive/grants-mcp.git cd grants-mcp
Important: You must provide your own API key. Never commit API keys to version control.
Option A - Using .env file (Recommended):
# Copy the example file cp .env.example .env # Edit .env and add your actual API key # SIMPLER_GRANTS_API_KEY=your_actual_api_key_here
Option B - Edit docker-compose.yml directly:
environment: - SIMPLER_GRANTS_API_KEY=your_actual_api_key_here
# Build the Docker image docker-compose build # Start the container docker-compose up -d # Check if it's running docker ps | grep grants-mcp # View logs docker logs grants-mcp-server
# Test with curl curl -X POST http://localhost:8081/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}' # Or use the provided test script python scripts/test_http_local.py
Copy the Docker configuration to Claude Desktop:
# For macOS cp claude_desktop_configs/config_local_docker.json \ ~/Library/Application\ Support/Claude/claude_desktop_config.json # For Windows cp claude_desktop_configs/config_local_docker.json \ %APPDATA%\Claude\claude_desktop_config.json
Then restart Claude Desktop to connect to your containerized MCP server.
grants-mcp/
├── src/
│ └── mcp_server/
│ ├── server.py # Main server implementation
│ ├── config/ # Configuration management
│ │ └── settings.py
│ ├── models/ # Data models and schemas
│ │ └── grants_schemas.py
│ ├── tools/
│ │ ├── discovery/ # Grant discovery tools
│ │ │ ├── opportunity_discovery_tool.py
│ │ │ ├── agency_landscape_tool.py
│ │ │ └── funding_trend_scanner_tool.py
│ │ └── utils/ # Utility modules
│ │ ├── api_client.py
│ │ ├── cache_manager.py
│ │ └── cache_utils.py
│ └── prompts/ # System prompts
├── scripts/ # Testing and deployment scripts
│ ├── test_http_local.py # Test HTTP endpoint
│ ├── test_http_no_docker.py # Run HTTP server locally
│ └── debug_connection.sh # Debug connectivity
├── claude_desktop_configs/ # Claude Desktop configurations
│ ├── config_local_stdio.json # Direct Python execution
│ ├── config_local_docker.json # Docker via mcp-remote
│ └── config_both.json # Both options
├── docker-compose.yml # Docker Compose configuration
├── Dockerfile # Container definition
└── tests/ # Comprehensive test suite
The Docker deployment provides:
# Quick start docker-compose up -d # Stop the server docker-compose down # View logs docker logs grants-mcp-server --follow # Rebuild after code changes docker-compose build && docker-compose up -d
For development and testing:
# Install dependencies pip install -r requirements.txt # Run with stdio transport (for direct integration) SIMPLER_GRANTS_API_KEY=your_key python main.py # Run with HTTP transport (for testing containerization locally) MCP_TRANSPORT=http PORT=8080 SIMPLER_GRANTS_API_KEY=your_key python main.py
The Simpler Grants API key is required for this MCP server to function. To get your API key:
Variable | Description | Default |
---|---|---|
SIMPLER_GRANTS_API_KEY | API key for Grants.gov (required) | - |
MCP_TRANSPORT | Transport mode: stdio or http | stdio |
PORT | HTTP server port (container mode) | 8080 |
LOG_LEVEL | Logging level | INFO |
CACHE_TTL | Cache time-to-live (seconds) | 300 |
MAX_CACHE_SIZE | Maximum cache entries | 1000 |
The docker-compose.yml
file includes:
Search for grant opportunities with detailed analysis.
Parameters:
query
: Search keywords (e.g., "renewable energy", "climate change")filters
: Advanced filter parametersmax_results
: Maximum number of results (default: 100)page
: Page number for paginationgrants_per_page
: Grants per page (default: 3)Map agencies and their funding focus areas.
Parameters:
include_opportunities
: Include opportunity analysis (default: true)focus_agencies
: Specific agency codes (e.g., ["NSF", "NIH"])funding_category
: Filter by categorymax_agencies
: Maximum agencies to analyze (default: 10)Analyze funding trends and patterns.
Parameters:
time_window_days
: Analysis period (default: 90)category_filter
: Filter by categoryagency_filter
: Filter by agencymin_award_amount
: Minimum award filterinclude_forecasted
: Include forecasted opportunities (default: true)docker-compose up -d
npm install -g mcp-remote
# macOS cp claude_desktop_configs/config_local_docker.json \ ~/Library/Application\ Support/Claude/claude_desktop_config.json
# macOS cp claude_desktop_configs/config_local_stdio.json \ ~/Library/Application\ Support/Claude/claude_desktop_config.json
# Run test script python scripts/test_http_local.py # Debug connection issues bash scripts/debug_connection.sh # Manual test with curl curl -X POST http://localhost:8081/mcp \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
# Run all tests pytest # Run with coverage pytest --cov=src --cov-report=html # Run specific test categories pytest tests/unit/ pytest tests/integration/ pytest tests/live/ # Requires API key
If port 8081 is in use:
# Check what's using the port lsof -i :8081 # Edit docker-compose.yml to use a different port # Change "8081:8080" to "8082:8080"
# Check container status docker ps -a | grep grants-mcp # View detailed logs docker logs grants-mcp-server --tail 100 # Restart container docker-compose restart # Rebuild from scratch docker-compose down docker-compose build --no-cache docker-compose up -d
SIMPLER_GRANTS_API_KEY
is set in docker-compose.ymldocker logs grants-mcp-server
The containerized version is ready for cloud deployment:
# Build and push to Google Container Registry gcloud builds submit --tag gcr.io/YOUR_PROJECT/grants-mcp # Deploy to Cloud Run gcloud run deploy grants-mcp \ --image gcr.io/YOUR_PROJECT/grants-mcp \ --platform managed \ --port 8080 \ --set-env-vars SIMPLER_GRANTS_API_KEY=your_key
See specs/cloud_deployment.md
for detailed AWS deployment instructions.
src/mcp_server/
: Core server implementationscripts/
: Testing and utility scriptstests/
: Comprehensive test suitespecs/
: Technical specifications and documentationclaude_desktop_configs/
: Ready-to-use Claude Desktop configurationsgit checkout -b feature/your-feature
pytest
docker-compose build && docker-compose up -d
MIT License - see LICENSE file for details
For issues, questions, or contributions:
specs/
directory for technical documentationNote: This is an alpha release. API and features may change. Use in production with caution.# Deployment Test
Service accounts and permissions are now properly configured!