Nasa Mcp 伺服器
概覽
什麼是 NASA-MCP-server?
NASA-MCP-server 是一個專為 NASA API 設計的模型上下文協議(MCP)伺服器。它提供了一個標準化的介面,使各種 AI 模型能夠與 NASA 廣泛的數據來源無縫互動。這個伺服器充當 AI 應用程序與 NASA 數據之間的橋樑,實現高效的數據檢索和處理。
NASA-MCP-server 的特點
- 標準化介面:MCP 伺服器為 AI 模型提供了一個一致且統一的介面,簡化了與 NASA 數據的整合過程。
- 數據可訪問性:它促進了對各種 NASA 數據集的輕鬆訪問,使開發者和研究人員更容易利用這些寶貴的信息。
- AI 模型兼容性:該伺服器旨在與各種 AI 模型協同工作,確保不同應用的靈活性和適應性。
- 開源:作為一個公共庫,NASA-MCP-server 開放供貢獻,允許開發者共同增強其功能和能力。
如何使用 NASA-MCP-server
-
克隆庫:首先從 GitHub 將 NASA-MCP-server 庫克隆到本地機器。
git clone https://github.com/ProgramComputer/NASA-MCP-server.git
-
設置環境:確保已安裝必要的依賴項。按照庫的 README 文件中的說明設置環境。
-
運行伺服器:使用提供的腳本或命令啟動伺服器。這將啟動 MCP 伺服器,使其準備好接受來自 AI 模型的請求。
-
與 AI 模型集成:使用伺服器提供的標準化 API 端點來連接您的 AI 模型。這將允許您的模型無縫地從 NASA 的數據庫中獲取數據。
-
貢獻:如果您有改進或新增功能的想法,考慮通過在 GitHub 上提交拉取請求來貢獻該項目。
常見問題解答
Q1: NASA-MCP-server 的目的是什么?
A1: NASA-MCP-server 作為 AI 模型與 NASA 數據來源之間的橋樑,提供了一個標準化的介面,以便更輕鬆地訪問和整合數據。
Q2: NASA-MCP-server 是開源的嗎?
A2: 是的,NASA-MCP-server 是一個開源項目,並在 GitHub 上可用,任何人都可以貢獻並增強其功能。
Q3: 我如何能夠貢獻到 NASA-MCP-server?
A3: 您可以通過分叉庫、進行更改並提交拉取請求來貢獻。確保遵循庫中提供的貢獻指南。
Q4: 我可以使用 NASA-MCP-server 訪問什麼類型的數據?
A4: 您可以訪問 NASA 提供的各種數據集,包括衛星影像、氣候數據和其他科學數據集。
Q5: 使用 NASA-MCP-server 需要特殊權限嗎?
A5: 不需要特殊權限來使用 NASA-MCP-server,因為它是公開可用的,任何對利用 NASA 數據感興趣的人都可以使用。
詳細
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 @programcomputer/nasa-mcp-server@latest
You can also pass the API key as a command line argument:
npx -y @programcomputer/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/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
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", "@programcomputer/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:
-
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)
-
JPL Solar System Dynamics API (ssd-api.jpl.nasa.gov):
- SBDB (Small-Body DataBase)
- SBDB Close-Approach Data
- Fireball Data
- Scout API
-
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/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
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:
- Build the project to ensure the latest changes are included
- Start the MCP Inspector with the NASA MCP server running
- 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
- Fork the repository
- Create your feature branch
- Run tests:
npm test
- Submit a pull request
License
ISC License - see LICENSE file for details
伺服器配置
{
"mcpServers": {
"nasa-mcp-server": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"ghcr.io/metorial/mcp-container--programcomputer--nasa-mcp-server--nasa-mcp-server",
"npm run start"
],
"env": {
"NASA_API_KEY": "nasa-api-key"
}
}
}
}