NASA MCP Server

NASA MCP Server

Provides standardized access to 20+ NASA data sources including astronomy pictures, Mars rover photos, near-Earth objects, satellite imagery, space weather, and planetary data through a unified interface optimized for AI consumption.

Category
访问服务器

README

NPM Version

NASA MCP Server

A Model Context Protocol (MCP) server for NASA APIs, providing a standardized interface for AI models to interact with NASA's vast array of data sources. This server implements the official Model Context Protocol specification.

Big thanks to the MCP community for their support and guidance!

Features

  • Access to 20+ NASA data sources through a single, consistent interface
  • Standardized data formats optimized for AI consumption
  • Automatic parameter validation and error handling
  • Rate limit management for NASA API keys
  • Comprehensive documentation and examples
  • Support for various NASA imagery formats
  • Data conversion and formatting for LLM compatibility
  • Cross-platform support (Windows, macOS, Linux)

Disclaimer

This project is not affiliated with, endorsed by, or related to NASA (National Aeronautics and Space Administration) or any of its subsidiaries or its affiliates. It is an independent implementation that accesses NASA's publicly available APIs. All NASA data used is publicly available and subject to NASA's data usage policies.

Installation

Running with npx

env NASA_API_KEY=YOUR_API_KEY npx -y @bachstudio/nasa-mcp-server@latest

You can also pass the API key as a command line argument:

npx -y @bachstudio/nasa-mcp-server@latest --nasa-api-key=YOUR_API_KEY

Using SuperGateway for Server-Sent Events (SSE)

You can use SuperGateway for Server-Sent Events (SSE).

The developers of NASA-MCP-server DO NOT ENDORSE the SuperGateway repository. This information is provided for those who wish to implement SSE functionality at their own discretion.

Manual Installation

# Clone the repository
git clone https://github.com/BACH-AI-Tools/NASA-MCP-server.git

# Install dependencies
cd NASA-MCP-server
npm install

# Run with your API key
NASA_API_KEY=YOUR_API_KEY npm start

Running on Cursor

Configuring Cursor 🖥️ Note: Requires Cursor version 0.45.6+

To configure NASA MCP Server in Cursor:

Create or edit an mcp.json file in your Cursor configuration directory with the following content:

{
  "mcpServers": {
    "nasa-mcp": {
      "command": "npx",
      "args": ["-y", "@bachstudio/nasa-mcp-server@latest"],
      "env": {
        "NASA_API_KEY": "your-api-key"
      }
    }
  }
}

Replace your-api-key with your NASA API key from https://api.nasa.gov/.

After adding the configuration, restart Cursor to see the new NASA tools. The Composer Agent will automatically use NASA MCP when appropriate for space-related queries.

Environment Variables

The server can be configured with the following environment variables:

Variable Description
NASA_API_KEY Your NASA API key (get at api.nasa.gov)

Included NASA APIs

This MCP server integrates the following NASA APIs:

  1. NASA Open API (api.nasa.gov):

    • APOD (Astronomy Picture of the Day)
    • EPIC (Earth Polychromatic Imaging Camera)
    • DONKI (Space Weather Database Of Notifications, Knowledge, Information)
    • Insight (Mars Weather Service)
    • Mars Rover Photos
    • NEO (Near Earth Object Web Service)
    • EONET (Earth Observatory Natural Event Tracker)
    • TLE (Two-Line Element)
    • NASA Image and Video Library
    • Exoplanet Archive
    • NASA Sounds API (Beta)
    • POWER (Prediction Of Worldwide Energy Resources)
  2. JPL Solar System Dynamics API (ssd-api.jpl.nasa.gov):

    • SBDB (Small-Body DataBase)
    • SBDB Close-Approach Data
    • Fireball Data
    • Scout API
  3. Earth Data APIs:

    • GIBS (Global Imagery Browse Services)
    • CMR (Common Metadata Repository) - Enhanced with advanced search capabilities
    • EPIC (Earth Polychromatic Imaging Camera)
    • FIRMS (Fire Information for Resource Management System)

API Methods

Each NASA API is exposed through standardized MCP methods:

APOD (Astronomy Picture of the Day)

{
  "method": "nasa/apod",
  "params": {
    "date": "2023-01-01", // Optional: YYYY-MM-DD format
    "count": 5, // Optional: Return a specified number of random images
    "thumbs": true // Optional: Return URL of video thumbnail
  }
}

Mars Rover Photos

{
  "method": "nasa/mars-rover",
  "params": {
    "rover": "curiosity", // Required: "curiosity", "opportunity", or "spirit"
    "sol": 1000, // Either sol or earth_date is required
    "earth_date": "2023-01-01", // YYYY-MM-DD format
    "camera": "FHAZ" // Optional: Filter by camera type
  }
}

Near Earth Objects

{
  "method": "nasa/neo",
  "params": {
    "start_date": "2023-01-01", // Required: YYYY-MM-DD format
    "end_date": "2023-01-07" // Required: YYYY-MM-DD format (max 7 days from start)
  }
}

GIBS (Global Imagery Browse Services)

{
  "method": "nasa/gibs",
  "params": {
    "layer": "MODIS_Terra_CorrectedReflectance_TrueColor", // Required: Layer ID
    "date": "2023-01-01", // Required: YYYY-MM-DD format
    "format": "png" // Optional: "png" or "jpg"
  }
}

POWER (Prediction Of Worldwide Energy Resources)

{
  "method": "nasa/power",
  "params": {
    "parameters": "T2M,PRECTOTCORR,WS10M", // Required: Comma-separated list
    "community": "re", // Required: Community identifier
    "latitude": 40.7128, // Required: Latitude
    "longitude": -74.0060, // Required: Longitude
    "start": "20220101", // Required: Start date (YYYYMMDD)
    "end": "20220107" // Required: End date (YYYYMMDD)
  }
}

For complete documentation of all available methods and parameters, see the API reference in the /docs directory.

Logging System

The server includes comprehensive logging:

  • Operation status and progress
  • Performance metrics
  • Rate limit tracking
  • Error conditions
  • Request validation

Example log messages:

[INFO] NASA MCP Server initialized successfully
[INFO] Processing APOD request for date: 2023-01-01
[INFO] Fetching Mars Rover data for Curiosity, sol 1000
[WARNING] Rate limit threshold reached (80%)
[ERROR] Invalid parameter: 'date' must be in YYYY-MM-DD format

Security Considerations

This MCP server implements security best practices following the Model Context Protocol specifications:

  • Input validation and sanitization using Zod schemas
  • No execution of arbitrary code
  • Protection against command injection
  • Proper error handling to prevent information leakage
  • Rate limiting and timeout controls for API requests
  • No persistent state that could be exploited across sessions

Development

# Clone the repository
git clone https://github.com/BACH-AI-Tools/NASA-MCP-server.git

# Install dependencies
npm install

# Copy the example environment file and update with your API keys
cp .env.example .env

# Build the TypeScript code
npm run build

# Start the development server
npm run dev

# Run tests
npm test

Testing with MCP Inspector

The NASA MCP Server includes a script to help you test the APIs using the MCP Inspector:

# Run the provided test script
./scripts/test-with-inspector.sh

This will:

  1. Build the project to ensure the latest changes are included
  2. Start the MCP Inspector with the NASA MCP server running
  3. Allow you to interactively test all the NASA APIs

Example Test Requests

The repository includes example test requests for each API that you can copy and paste into the MCP Inspector:

# View the example test requests
cat docs/inspector-test-examples.md

For detailed examples, see the Inspector Test Examples document.

MCP Client Usage

This server follows the official Model Context Protocol. Here's an example of how to use it with the MCP SDK:

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { HttpClientTransport } from "@modelcontextprotocol/sdk/client/http.js";

const transport = new HttpClientTransport({
  url: "http://localhost:3000",
});

const client = new Client({
  name: "mcp-client",
  version: "1.0.0",
});

await client.connect(transport);

// Example: Get today's Astronomy Picture of the Day
const apodResult = await client.request({
  method: "nasa/apod", 
  params: {}
});

// Example: Get Mars Rover photos
const marsRoverResult = await client.request({
  method: "nasa/mars-rover",
  params: { rover: "curiosity", sol: 1000 }
});

// Example: Search for Near Earth Objects
const neoResults = await client.request({
  method: "nasa/neo",
  params: {
    start_date: '2023-01-01',
    end_date: '2023-01-07'
  }
});

// Example: Get satellite imagery from GIBS
const satelliteImage = await client.request({
  method: "nasa/gibs",
  params: {
    layer: 'MODIS_Terra_CorrectedReflectance_TrueColor',
    date: '2023-01-01'
  }
});

// Example: Use the new POWER API
const powerData = await client.request({
  method: "nasa/power",
  params: {
    parameters: "T2M,PRECTOTCORR,WS10M",
    community: "re",
    latitude: 40.7128,
    longitude: -74.0060,
    start: "20220101",
    end: "20220107"
  }
});

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Run tests: npm test
  4. Submit a pull request

License

ISC License - see LICENSE file for details

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选