nasa-mcp-server
Provides access to NASA's open APIs including astronomy imagery, Mars rover photos, asteroid tracking, Earth observations, and media library through natural language interaction.
README
NASA MCP Server
A comprehensive Model Context Protocol (MCP) server providing access to NASA's open APIs, including astronomy imagery, Mars rover photos, asteroid tracking, Earth observations, and NASA's media library.
✨ Features
🌌 Astronomy Picture of the Day (APOD)
- Daily astronomy images with scientific explanations
- Historical APOD lookup by date or date range
- Random APOD discovery
- High-resolution image support
🚀 Mars Rover Photos
- Photos from all active and historical rovers (Curiosity, Perseverance, Opportunity, Spirit)
- Search by Martian sol (day) or Earth date
- Multiple camera support (FHAZ, RHAZ, MAST, CHEMCAM, etc.)
- Latest mission updates and rover manifests
☄️ Near Earth Objects (Asteroids)
- Real-time asteroid approach tracking
- Potentially hazardous asteroid identification
- Detailed orbital and physical characteristics
- Comprehensive asteroid database browsing
📸 NASA Media Library
- Search NASA's vast image and video collection
- High-resolution space imagery
- Historical mission photography
- Educational content discovery
🚄 Performance & Reliability
- Smart caching (30min for images, 10min for dynamic data)
- Rate limit awareness and management
- Comprehensive error handling
- Multi-tier caching strategy
🚀 Quick Start
Prerequisites
- Python 3.8+
- NASA API key (get free at api.nasa.gov)
- pip or uv package manager
Installation
- Clone the project:
git clone https://github.com/jezweb/nasa-mcp-server.git
cd nasa-mcp-server
- Install dependencies:
pip install -r requirements.txt
- Configure environment:
cp .env.example .env
# Edit .env with your NASA API key
- Run the server:
# STDIO transport (default)
python nasa_server.py
# HTTP transport
TRANSPORT=http PORT=8000 python nasa_server.py
# Development with FastMCP
fastmcp dev nasa_server.py
# Test the server
python nasa_server.py --test
🛠 Available Tools
APOD Tools
get_apod
Get today's Astronomy Picture of the Day or specific date.
Parameters:
date_str(optional): Date in YYYY-MM-DD formathd(bool): Request high-definition image URL (default: true)include_concepts(bool): Include concept tags (default: false)
Example:
{
"date_str": "2024-01-15",
"hd": true,
"include_concepts": false
}
get_random_apod
Get random APOD images for discovery.
Parameters:
count(int): Number of random images (1-100, default: 5)
get_apod_date_range
Get APOD images for a date range.
Parameters:
start_date(str): Start date in YYYY-MM-DD formatend_date(str): End date in YYYY-MM-DD format (max 7 days)hd(bool): Request high-definition images (default: true)
Mars Rover Tools
get_mars_photos_by_sol
Get Mars rover photos by Martian sol (day).
Parameters:
rover(str): Rover name (curiosity, perseverance, opportunity, spirit)sol(int): Martian sol number (default: 1000)camera(optional): Camera abbreviation (fhaz, rhaz, mast, chemcam, etc.)page(int): Page number for pagination (default: 1)
Example:
{
"rover": "curiosity",
"sol": 3000,
"camera": "mast"
}
get_mars_photos_by_date
Get Mars rover photos by Earth date.
Parameters:
rover(str): Rover name (default: "curiosity")earth_date(optional): Date in YYYY-MM-DD format (defaults to today)camera(optional): Camera abbreviation
get_latest_mars_photos
Get the latest photos from a Mars rover.
Parameters:
rover(str): Rover name (default: "curiosity")camera(optional): Camera abbreviation
get_rover_manifest
Get Mars rover mission information and photo availability.
Parameters:
rover(str): Rover name (default: "curiosity")
Asteroid Tools
get_asteroids_feed
Get asteroids approaching Earth within a date range.
Parameters:
start_date(optional): Start date in YYYY-MM-DD format (defaults to today)end_date(optional): End date in YYYY-MM-DD format (max 7 days from start)detailed(bool): Include detailed orbital data (default: false)
Example:
{
"start_date": "2024-08-18",
"end_date": "2024-08-25",
"detailed": true
}
lookup_asteroid
Look up specific asteroid by NASA JPL ID.
Parameters:
asteroid_id(str): NASA JPL small body database ID
browse_asteroids
Browse the Near Earth Objects database.
Parameters:
page(int): Page number (0-based, default: 0)size(int): Results per page (max 20, default: 20)
NASA Media Tools
search_nasa_media
Search NASA's image and video library.
Parameters:
query(str): Search termsmedia_type(str): Type of media (image, video, audio) (default: "image")page(int): Page number (default: 1)page_size(int): Results per page (max 100, default: 100)
Example:
{
"query": "apollo moon landing",
"media_type": "image",
"page": 1,
"page_size": 20
}
📋 Resources
nasa://api/status
Get API status, usage statistics, and rate limiting information.
nasa://cache/stats
Get cache performance statistics for both image and dynamic caches.
nasa://rovers/info
Get detailed information about all Mars rovers, their cameras, and capabilities.
🎯 Prompts
space_exploration
Generate comprehensive space exploration analysis for any topic.
Parameters:
topic(str): Space exploration topic to analyze
mars_mission_report
Create detailed Mars rover mission reports.
Parameters:
rover(str): Rover name (default: "curiosity")
asteroid_watch
Generate asteroid monitoring and threat assessment reports.
Parameters:
days_ahead(int): Days to monitor (default: 30)
daily_space_brief
Generate comprehensive daily space exploration briefings.
⚙️ Configuration
Edit the .env file to customize server behavior:
# API Configuration
API_KEY=your_nasa_api_key_here
DEFAULT_COUNT=10
# Cache Settings
CACHE_TTL_IMAGES=1800 # 30 minutes
CACHE_TTL_DYNAMIC=600 # 10 minutes
# Rate Limiting
MAX_HOURLY_CALLS=1000 # For registered API keys
DEMO_HOURLY_LIMIT=30 # For DEMO_KEY
# Server Settings
LOG_LEVEL=INFO
TRANSPORT=stdio
PORT=8000
NASA API Key
- Free Tier (DEMO_KEY): 30 requests/hour, 50/day per IP
- Registered Key: 1,000 requests/hour (free signup at api.nasa.gov)
🚀 Deployment
Local Installation (Claude Desktop)
fastmcp install claude-desktop nasa_server.py
FastMCP Cloud Deployment
- Create GitHub repository:
git init
git add .
git commit -m "NASA MCP Server"
gh repo create nasa-mcp-server --public
git push -u origin main
-
Deploy on fastmcp.cloud:
- Sign in with GitHub
- Create new project from repository
- Set entrypoint:
nasa_server.py - Add environment variables from
.env - Deploy
-
Connect to Claude Desktop:
{
"mcpServers": {
"nasa": {
"url": "https://your-project.fastmcp.app/mcp",
"transport": "http"
}
}
}
📚 Usage Examples
Space Exploration Analysis
"Analyze the current status of Mars exploration missions and show me recent rover discoveries."
Asteroid Monitoring
"What potentially hazardous asteroids are approaching Earth in the next 30 days?"
Daily Space Brief
"Give me today's space exploration update including APOD, Mars photos, and Earth imagery."
Historical Space Events
"Show me APOD images from the Apollo 11 anniversary week in July 2019."
Mars Mission Comparison
"Compare the latest photos from Curiosity and Perseverance rovers, what are they currently investigating?"
Educational Content
"Search NASA's media library for educational content about black holes and show me the most relevant images."
🔧 Development
Testing
# Run test mode
python nasa_server.py --test
# Test with FastMCP client
fastmcp dev nasa_server.py
Logging
Enable debug logging in .env:
LOG_LEVEL=DEBUG
Adding New Features
The server is modular and extensible:
- Add new tools by creating
@mcp.tooldecorated functions - Add new resources using
@mcp.resource(uri)decorators - Add new prompts using
@mcp.prompt(name)decorators - Update configuration in
Configclass - Add caching strategy for new endpoints
🚨 Rate Limits & Best Practices
- DEMO_KEY: 30 requests/hour, 50/day per IP address
- Registered Key: 1,000 requests/hour
- Caching: 30 minutes for images, 10 minutes for dynamic data
- Batch Requests: Use date ranges and pagination wisely
- Error Handling: Server gracefully handles API limits and errors
📖 API Documentation
🤝 Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Update documentation
- Submit a pull request
📄 License
MIT License - see LICENSE file for details.
🆘 Support
Explore the universe with NASA's data! 🌌🚀✨
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.