nasa-mcp-server-demo

ankitzaveri/nasa-mcp-server-demo

3.2

If you are the rightful owner of nasa-mcp-server-demo and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The NASA MCP Server provides access to NASA's APIs, including the Astronomy Picture of the Day and the NASA Image Library, through the Model Context Protocol.

Tools
2
Resources
0
Prompts
0

NASA MCP Server

A Model Context Protocol (MCP) server that provides access to NASA's APIs:

  • APOD (Astronomy Picture of the Day): Get daily astronomical images and explanations
  • NASA Image Library: Search NASA's vast collection of images and videos

Features

  • 🚀 Access NASA's Astronomy Picture of the Day
  • 🔍 Search NASA's image and video library
  • 🛠️ Implements MCP protocol for easy integration
  • 🔑 Supports custom NASA API keys

Setup

1. Install Dependencies

On Windows with Python 3.12:

py -3.12 -m pip install -r requirements.txt

On Linux/Mac or with default Python:

pip install -r requirements.txt

Note: This project requires Python 3.10 or higher.

2. Configure API Key (Optional)

Get a free NASA API key at: https://api.nasa.gov/

Create a .env file:

cp .env.example .env

Edit .env and add your API key:

NASA_API_KEY=your_api_key_here

Note: The app works with DEMO_KEY but has rate limits. Get your own key for production use.

Running the Server

Option 1: Direct Server Mode

Run the MCP server directly (for integration with MCP clients):

Windows with Python 3.12:

py -3.12 server.py

Linux/Mac or default Python:

python server.py

Option 2: Interactive Testing with MCP Inspector (Recommended)

The MCP Inspector provides a web-based UI to interact with your MCP server.

Step 1: Install MCP Inspector
npm install -g @modelcontextprotocol/inspector
Step 2: Run the Inspector

Windows with Python 3.12:

npx @modelcontextprotocol/inspector py -3.12 server.py

Or use the provided script:

.\run_inspector.ps1

Linux/Mac or default Python:

npx @modelcontextprotocol/inspector python server.py
Step 3: Access the Web Interface

The inspector will start a local web server (typically at http://localhost:5173 or similar port).

Open the URL in your browser to:

  • 🔍 View available tools: See get_apod and search_nasa_images with their schemas
  • 🧪 Test tool calls: Execute tools with custom parameters and see real-time results
  • 📊 Inspect messages: View the complete MCP protocol request/response flow
  • 🐛 Debug: Monitor errors and responses from NASA APIs
Example Test Cases in Inspector:

Test 1: Get Today's APOD

  • Tool: get_apod
  • Parameters: {} (empty for today)

Test 2: Get Historical APOD

  • Tool: get_apod
  • Parameters: {"date": "2024-01-01"}

Test 3: Search Mars Images

  • Tool: search_nasa_images
  • Parameters: {"query": "mars rover", "media_type": "image"}

Test 4: Search Apollo 11 from 1969

  • Tool: search_nasa_images
  • Parameters: {"query": "apollo 11", "year_start": "1969", "year_end": "1969"}

Available Tools

1. get_apod

Get NASA's Astronomy Picture of the Day.

Parameters:

  • date (optional): Date in YYYY-MM-DD format (defaults to today)

Example:

{
  "date": "2024-01-01"
}

2. search_nasa_images

Search NASA's image and video library.

Parameters:

  • query (required): Search term (e.g., "mars rover", "nebula")
  • media_type (optional): "image", "video", or "audio" (defaults to "image")
  • year_start (optional): Start year for search range
  • year_end (optional): End year for search range

Example:

{
  "query": "apollo 11",
  "media_type": "image",
  "year_start": "1969",
  "year_end": "1969"
}

Integration

To use this MCP server with an MCP client, add it to your client configuration:

{
  "mcpServers": {
    "nasa": {
      "command": "python",
      "args": ["C:\\path\\to\\server.py"]
    }
  }
}

API Rate Limits

  • DEMO_KEY: 30 requests per hour, 50 requests per day
  • Personal Key: 1,000 requests per hour

Resources