本指南详细介绍了 NASA MCP 服务器的安装、配置、功能及使用方法,帮助你快速上手并安全使用该服务器。
# 克隆仓库
git clone https://github.com/ProgramComputer/NASA-MCP-server.git
# 安装项目依赖
npm install
# 复制示例环境文件并进行修改
cp .env.example .env
# 开发模式启动服务器
npm run dev
# 生产模式构建并启动
npm start
logs/ 目录中,默认情况下启用文件输出。[INFO] 服务器初始化成功
[WARNING] 速率限制已达到阈值(80%)
[ERROR] 参数错误:'date' 必须符合 YYYY-MM-DD 格式
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { HttpClientTransport } from "@modelcontextprotocol/sdk/client/http.js";
const 运输 = new HttpClientTransport({
url: "http://localhost:3000",
});
const 客户端 = new Client({
name: "mcp-client",
version: "1.0.0",
});
await 客户端.connect(运输);
// 示例:获取今天的天文学图片
const apodResult = await 客户端.request({
method: "nasa/apod",
params: {}
});
// 示例:获取火星车照片
const marsRoverResult = await 客户端.request({
method: "nasa/mars-rover",
params: { rover: "curiosity", sol: 1000 }
});
// 示例:查询近地天体
const neoResults = await 客户端.request({
method: "nasa/neo",
params: {
start_date: '2023-01-01',
end_date: '2023-01-07'
}
});
// 示例:获取卫星影像
const satelliteImage = await 客户端.request({
method: "nasa/gibs",
params: {
layer: 'MODIS_Terra_CorrectedReflectance_TrueColor',
date: '2023-01-01'
}
});
// 示例:使用 POWER API
const powerData = await 客户端.request({
method: "nasa/power",
params: {
latitude: 34.0522,
longitude: -118.2437,
start_date: '2023-01-01',
end_date: '2023-12-31'
}
});
# 克隆仓库
git clone https://github.com/ProgramComputer/NASA-MCP-server.git
# 安装项目依赖
npm install
# 复制示例环境文件并进行修改
cp .env.example .env
# 开发模式启动服务器
npm run dev
# 生产模式构建并启动
npm start
# 在开发模式下构建
npm run build
# 在生产模式下构建
npm run build -- --env production
# 运行单元测试
npm test
# 覆盖率测试
npm run test:coverage
REACT_APP_API_KEY=your_api_key_here
config.json 中配置允许访问的 IP 地址。.
├── src/ # 源代码目录
│ ├── server.js # 主服务器文件
│ └── routes/ # 路由定义
├── public/ # 公共资源目录
│ └── config.json # 配置文件
└── logs/ # 日志输出目录
以上为 NASA MCP 服务器的详细使用指南,如有任何问题,请随时联系支持团队。