Nasa Images

io.github.kaitoy由 GitHub 账号 kaitoy 发布v1.1.3更新于 Oct 24, 2026

MCP server with UI for NASA images

概览

AI 生成的概览

按关键词搜索 NASA 图片库,并在交互式图片查看器中展示结果,可逐张浏览匹配图片。

可以做什么
  • 通过 NASA Images API 按关键词搜索 NASA 图片库
  • 在当前搜索结果中逐张切换查看图片
  • 以资源形式提供当前显示图片的链接
  • 在客户端内渲染交互式 HTML 图片查看器界面
适用场景
适合让助手查找某个主题的 NASA 照片或任务影像并直观浏览结果,例如用于资料调研、教学或演示素材。
运行要求
以 Node.js 本地包形式运行(需 Node.js 18 或更高版本,npm 或 yarn),通过 stdio 通信,也可作为 HTTP 服务器运行在 3000 等端口。需要在 NASA_API_KEY 环境变量中提供 NASA API 密钥(可在 NASA 免费申请),并需要访问 NASA Images API 的出站 HTTPS 网络。
安装前请注意
需要把 NASA API 密钥放在 NASA_API_KEY 环境变量中,README 建议不要硬编码。请求会发往 NASA 公共 API,受速率限制(共享演示密钥约每小时 30 次,注册密钥每小时 1000 次)。HTTP 模式默认开启 CORS 供开发使用,README 指出生产环境需配置合适的 CORS 与限流。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Nasa Images,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

NASA Images MCP Server

A project to search NASA's image library using an MCP server and display images in an interactive UI.

🌟 Features:

  • Dual Transport Support: Supports both stdio and Streamable HTTP transport
  • Image Search: Search by keywords using NASA's Images API
  • Interactive UI: Beautiful image viewer using MCP Apps Pattern
  • Image Navigation: Display search results sequentially
  • Session Management: Stateful session management

[screenshot]

Requirements

  • Node.js 18 or higher
  • npm or yarn
  • NASA API Key (get free at nasa.gov/api)

Installation

  1. Clone the repository:
bash
cd nasa-images-mcp-server
  1. Install dependencies:
bash
npm install
  1. Set up environment variables:
bash
cp .env.example .env

Edit the .env file to configure your NASA API key:

env
NASA_API_KEY=your_api_key_herePORT=3000
  1. Build:
bash
npm run build

Getting a NASA API Key

  1. Visit https://api.nasa.gov/
  2. Enter your name and email address in the form
  3. The API key will be sent to your email immediately
  4. Add it to your .env file

Rate Limits:

  • DEMO_KEY: 30 requests/hour, 50 requests/day
  • Registered key: 1000 requests/hour

Usage

stdio Mode (Recommended for MCP Clients like Claude Desktop)

In stdio mode, the server communicates via stdin/stdout — no HTTP server is started. Logs are written to stderr.

Run with npx (no installation required)
bash
npx @kaitoy/nasa-images-mcp-server --stdio
Run from local build

Pass the --stdio flag to use stdio transport:

bash
node build/index.js --stdio
Claude Desktop Configuration

Using npx (recommended):

json
{  "mcpServers": {    "nasa-images": {      "command": "npx",      "args": ["-y", "@kaitoy/nasa-images-mcp-server", "--stdio"],      "env": {        "NASA_API_KEY": "your_api_key_here"      }    }  }}

Using local build:

json
{  "mcpServers": {    "nasa-images": {      "command": "node",      "args": ["/path/to/nasa-images-mcp-server/build/index.js", "--stdio"],      "env": {        "NASA_API_KEY": "your_api_key_here"      }    }  }}

HTTP Server Mode

bash
npm start

The server will start at http://localhost:3000.

Start on a Different Port

bash
PORT=3001 npm start

About Transports

stdio Transport

Suitable for local MCP clients (e.g., Claude Desktop) that launch the server as a subprocess.

  • Communicates via stdin/stdout
  • Single session per process
  • No network configuration required

Streamable HTTP Transport

The latest MCP HTTP transport protocol, suitable for remote or multi-client scenarios.

Key Features:

  • ✅ Stateful Sessions: Issues a unique session ID for each client
  • ✅ SSE Support: Supports push notifications from the server via Server-Sent Events
  • ✅ JSON-RPC over HTTP: Communication via standard HTTP request/response
  • ✅ Session Management: Automatic session lifecycle management

Integration with MCP Clients

Connecting with MCP Inspector (HTTP mode)

You can test the server using MCP Inspector:

bash
npx @modelcontextprotocol/inspector http://localhost:3000/mcp

Connecting with MCP Inspector (stdio mode)

bash
npx @modelcontextprotocol/inspector node /path/to/nasa-images-mcp-server/build/index.js --stdio

Using with Custom MCP Clients

Steps to connect from a custom client:

  1. Initialize Request (POST /mcp):
bash
curl -X POST http://localhost:3000/mcp \  -H "Content-Type: application/json" \  -H "Accept: application/json, text/event-stream" \  -d '{    "jsonrpc": "2.0",    "id": 1,    "method": "initialize",    "params": {      "protocolVersion": "2024-11-05",      "capabilities": {},      "clientInfo": {        "name": "my-client",        "version": "1.0.0"      }    }  }'

The response headers will include mcp-session-id.

  1. Subsequent Requests:
bash
curl -X POST http://localhost:3000/mcp \  -H "Content-Type: application/json" \  -H "Accept: application/json, text/event-stream" \  -H "mcp-session-id: <your-session-id>" \  -d '{    "jsonrpc": "2.0",    "id": 2,    "method": "tools/list"  }'
  1. SSE Stream (GET /mcp):
bash
curl -X GET "http://localhost:3000/mcp" \  -H "mcp-session-id: <your-session-id>" \  -H "Accept: text/event-stream"

Endpoints

EndpointMethodDescription
/GETServer information and endpoint list
/healthGETHealth check (includes active session count)
/mcpPOSTJSON-RPC requests (initialization, tool calls, etc.)
/mcpGETSSE stream (for server notifications)
/mcpDELETEClose session

Available Tools

1. search_nasa_images

Search NASA's image library.

Parameters:

  • query (string, required): Search query (e.g., "apollo 11", "mars rover")

Usage Example (JSON-RPC):

json
{  "jsonrpc": "2.0",  "id": 3,  "method": "tools/call",  "params": {    "name": "search_nasa_images",    "arguments": {      "query": "apollo 11 moon landing"    }  }}

2. get_next_image

Display the next image from the current search results.

Parameters: None

Usage Example (JSON-RPC):

json
{  "jsonrpc": "2.0",  "id": 4,  "method": "tools/call",  "params": {    "name": "get_next_image",    "arguments": {}  }}

Available Resources

nasa-image://current

Get the URL of the currently displayed image.

MIME Type: text/uri-list

ui://nasa-images/viewer

HTML UI resource for the image viewer.

MIME Type: text/html;profile=mcp-app

Architecture

stdio Mode

┌─────────────────────────────────────────────┐│     MCP Client (Claude Desktop, etc.)       ││                   ↕ stdin/stdout            │└───────────────────┼─────────────────────────┘                    │┌───────────────────┼─────────────────────────┐│  NASA Images MCP Server                     ││  ┌────────────────┴──────────────────────┐  ││  │  StdioServerTransport                 │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  McpServer (MCP Apps Pattern)         │  ││  │  - registerAppTool(search_nasa...)    │  ││  │  - registerAppTool(get_next_image)    │  ││  │  - registerAppResource(viewer UI)     │  ││  │  - registerResource(image URL)        │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  Session Manager                      │  ││  │  - Manage search state per user       │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  NASA API Client                      │  ││  │  - Image search                       │  ││  │  - Image URL retrieval                │  ││  └───────────────────────────────────────┘  │└───────────────────┼─────────────────────────┘                    │ HTTPS┌───────────────────┼─────────────────────────┐│         NASA Images API                     ││  https://images-api.nasa.gov/search         │└─────────────────────────────────────────────┘

HTTP Mode

┌─────────────────────────────────────────────┐│     MCP Client (Inspector, Custom App)      ││                                             ││  ┌────────────────────────────────────────┐ ││  │  HTTP Client                           │ ││  │  - POST /mcp (JSON-RPC requests)       │ ││  │  - GET /mcp (SSE stream)               │ ││  └────────────────────────────────────────┘ ││                   ↕                         │└───────────────────┼─────────────────────────┘                    │ HTTP/SSE┌───────────────────┼─────────────────────────┐│  NASA Images MCP Server (Express)           ││  ┌────────────────┴──────────────────────┐  ││  │  StreamableHTTPServerTransport        │  ││  │  - Session management                 │  ││  │  - JSON-RPC over HTTP                 │  ││  │  - SSE for notifications              │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  McpServer (MCP Apps Pattern)         │  ││  │  - registerAppTool(search_nasa...)    │  ││  │  - registerAppTool(get_next_image)    │  ││  │  - registerAppResource(viewer UI)     │  ││  │  - registerResource(image URL)        │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  Session Manager                      │  ││  │  - Manage search state per user       │  ││  └───────────────────────────────────────┘  ││  ┌───────────────────────────────────────┐  ││  │  NASA API Client                      │  ││  │  - Image search                       │  ││  │  - Image URL retrieval                │  ││  └───────────────────────────────────────┘  │└───────────────────┼─────────────────────────┘                    │ HTTPS┌───────────────────┼─────────────────────────┐│         NASA Images API                     ││  https://images-api.nasa.gov/search         │└─────────────────────────────────────────────┘

Main Components

  • src/index.ts: Express server and transport management
  • src/mcp-server.ts: MCP server logic (tool and resource registration)
  • src/session-manager.ts: Session management (search state persistence)
  • src/nasa-api.ts: NASA API client
  • src/types.ts: TypeScript type definitions

Development

Watch Mode

bash
npm run watch

Automatically rebuilds when files change.

Development Mode

bash
npm run dev

Builds and immediately starts the server.

Troubleshooting

Port Already in Use

Error: listen EADDRINUSE: address already in use

Solution: Specify a different port:

bash
PORT=3001 npm start

"Cannot find module" Error

Run:

bash
npm run build

to compile TypeScript.

API Rate Limit Error

  • If using DEMO_KEY, obtain your own API key from api.nasa.gov
  • Limited to 30 requests per hour

"Not Acceptable" Error

The client must accept both MIME types:

  • application/json
  • text/event-stream
bash
curl -H "Accept: application/json, text/event-stream" ...

Session Not Found

Save the mcp-session-id header returned after the initialization request and send it as the mcp-session-id header in subsequent requests.

Security Notes

  • This server has CORS enabled (for development)
  • In production, implement proper CORS settings and rate limiting
  • Manage NASA API keys via environment variables; do not hardcode them

License

MIT

References

Contributing

Pull requests are welcome! Bug reports and feature requests are accepted via Issues.

Support

If you encounter issues, please create an Issue or refer to the NASA API support page.

来源:README.md,提交 cda5828

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.1.3最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分