NASA MCP Server

ISC License
104
23
  • Apple
  • Linux

Integrations

  • Provides access to 20+ NASA data sources including APOD, Mars Rover Photos, EPIC, DONKI, NEO, EONET, TLE, JPL Solar System Dynamics, Earth Data APIs, and POWER, allowing AI models to retrieve and process space imagery, celestial object data, and Earth observation information through a standardized interface.

  • Implements input validation and sanitization for NASA API requests using Zod schemas to ensure proper formatting and security.

NASA MCP 服务器

一个用于 NASA API 的模型上下文协议 (MCP) 服务器,为 AI 模型提供标准化接口,使其能够与 NASA 的海量数据源进行交互。该服务器实现了官方的模型上下文协议规范。

非常感谢 MCP 社区的支持和指导!

特征

  • 通过单一、一致的界面访问 20 多个 NASA 数据源
  • 针对人工智能消费优化的标准化数据格式
  • 自动参数验证和错误处理
  • NASA API 密钥的速率限制管理
  • 全面的文档和示例
  • 支持各种 NASA 图像格式
  • 数据转换和格式化以实现 LLM 兼容性
  • 跨平台支持(Windows、macOS、Linux)

免责声明

**本项目与美国国家航空航天局 (NASA) 或其任何子公司或附属机构均无关联、认可或相关关系。**它是一个独立的实现,可访问 NASA 的公开 API。所有使用的 NASA 数据均公开,并受 NASA 数据使用政策的约束。

安装

使用 npx 运行

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

您还可以将 API 密钥作为命令行参数传递:

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

使用 SuperGateway 发送服务器发送事件 (SSE)

您可以使用SuperGateway进行服务器发送事件 (SSE)。

NASA-MCP-server 的开发者不认可 SuperGateway 仓库。此信息仅供希望自行实现 SSE 功能的用户参考。

手动安装

# Clone the repository git clone https://github.com/ProgramComputer/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

在光标上运行

配置 Cursor 🖥️ 注意:需要 Cursor 版本 0.45.6+

要在 Cursor 中配置 NASA MCP 服务器:

在您的 Cursor 配置目录中创建或编辑mcp.json文件,其中包含以下内容:

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

your-api-key替换为来自https://api.nasa.gov/的 NASA API 密钥。

添加配置后,重新启动 Cursor 即可看到新的 NASA 工具。Composer Agent 会在适当的情况下自动使用 NASA MCP 进行与空间相关的查询。

环境变量

可以使用以下环境变量配置服务器:

多变的描述
NASA_API_KEY您的 NASA API 密钥(从 api.nasa.gov 获取)

包含 NASA API

该 MCP 服务器集成了以下 NASA API:

  1. NASA开放API (api.nasa.gov):
    • APOD(每日天文图片)
    • EPIC(地球多色成像相机)
    • DONKI(空间天气通知、知识、信息数据库)
    • 洞察号(火星气象服务)
    • 火星探测器照片
    • NEO(近地天体网络服务)
    • EONET(地球观测站自然事件追踪器)
    • TLE(双线元件)
    • 美国宇航局图像和视频库
    • 系外行星档案
    • NASA 声音 API(测试版)
    • 电力(全球能源资源预测)
  2. JPL太阳系动力学API (ssd-api.jpl.nasa.gov):
    • SBDB(小体数据库)
    • SBDB近距离数据
    • 火球数据
    • 侦察 API
  3. 地球数据API
    • GIBS(全球图像浏览服务)
    • CMR(通用元数据存储库)——增强了高级搜索功能
    • EPIC(地球多色成像相机)
    • FIRMS(资源管理系统火灾信息)

API 方法

每个 NASA API 都通过标准化 MCP 方法公开:

APOD(每日天文图片)

{ "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 } }

火星探测器照片

{ "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 } }

近地天体

{ "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(全球图像浏览服务)

{ "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" } }

电力(全球能源资源预测)

{ "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) } }

有关所有可用方法和参数的完整文档,请参阅/docs目录中的 API 参考。

日志系统

该服务器包括全面的日志记录:

  • 运营状况及进展
  • 性能指标
  • 速率限制跟踪
  • 错误条件
  • 请求验证

日志消息示例:

[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

安全注意事项

该 MCP 服务器遵循模型上下文协议规范实现安全最佳实践:

  • 使用 Zod 模式进行输入验证和清理
  • 禁止执行任意代码
  • 防止命令注入
  • 适当的错误处理以防止信息泄露
  • API 请求的速率限制和超时控制
  • 没有可跨会话利用的持久状态

发展

# Clone the repository git clone https://github.com/ProgramComputer/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

使用 MCP Inspector 进行测试

NASA MCP 服务器包含一个脚本,可帮助您使用 MCP 检查器测试 API:

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

这将:

  1. 构建项目以确保包含最新的更改
  2. 在 NASA MCP 服务器运行的情况下启动 MCP 检查器
  3. 允许您以交互方式测试所有 NASA API

测试请求示例

该存储库包含每个 API 的示例测试请求,您可以将其复制并粘贴到 MCP 检查器中:

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

有关详细示例,请参阅Inspector 测试示例文档。

MCP 客户端使用

此服务器遵循官方模型上下文协议 (Model Context Protocol)。以下是如何将其与 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" } });

贡献

  1. 分叉存储库
  2. 创建你的功能分支
  3. 运行测试: npm test
  4. 提交拉取请求

执照

ISC 许可证 - 详情请参阅许可证文件

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

模型上下文协议服务器为 AI 模型提供标准化接口,以便与 NASA 的大量数据源(包括 APOD、火星探测器照片、卫星图像和空间天气数据)进行交互。

  1. Features
    1. Disclaimer
      1. Installation
        1. Running with npx
        2. Using SuperGateway for Server-Sent Events (SSE)
        3. Manual Installation
        4. Running on Cursor
      2. Environment Variables
        1. Included NASA APIs
          1. API Methods
            1. APOD (Astronomy Picture of the Day)
            2. Mars Rover Photos
            3. Near Earth Objects
            4. GIBS (Global Imagery Browse Services)
            5. POWER (Prediction Of Worldwide Energy Resources)
          2. Logging System
            1. Security Considerations
              1. Development
                1. Testing with MCP Inspector
                  1. Example Test Requests
                2. MCP Client Usage
                  1. Contributing
                    1. License

                      Related MCP Servers

                      • -
                        security
                        F
                        license
                        -
                        quality
                        A Model Context Protocol server that provides persistent task management capabilities for AI assistants, allowing them to create, update, and track tasks beyond their usual context limitations.
                        Last updated -
                        1
                        TypeScript
                      • -
                        security
                        F
                        license
                        -
                        quality
                        A demonstration implementation of the Model Context Protocol server that facilitates communication between AI models and external tools while maintaining context awareness.
                        Last updated -
                        Python
                        • Linux
                        • Apple
                      • A
                        security
                        F
                        license
                        A
                        quality
                        A Model Context Protocol server implementation that provides structured, AI-friendly access to eRegulations data, making it easier for AI models to answer user questions about administrative procedures.
                        Last updated -
                        4
                        28
                        TypeScript
                        • Linux
                        • Apple
                      • -
                        security
                        A
                        license
                        -
                        quality
                        A customizable Model Context Protocol server implementation that enables AI models to interact with external tools including weather queries, Google search, and camera control functionality.
                        Last updated -
                        8
                        Python
                        Apache 2.0
                        • Linux
                        • Apple

                      View all related MCP servers

                      ID: o0n1e0no5o