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! 🌌🚀✨
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。