The NASA MCP Server provides a standardized interface for AI models to interact with NASA's vast array of data sources, offering access to over 20 NASA APIs through a consistent Model Context Protocol implementation. This server makes NASA's space and Earth science data easily accessible for AI applications.
The easiest way to run the NASA MCP Server is using npx:
env NASA_API_KEY=YOUR_API_KEY npx -y @programcomputer/nasa-mcp-server@latest
Alternatively, you can pass the API key as a command line argument:
npx -y @programcomputer/nasa-mcp-server@latest --nasa-api-key=YOUR_API_KEY
If you prefer a manual setup:
# 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
For Cursor users (version 0.45.6+), create or edit an mcp.json
file in your Cursor configuration directory:
{
"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/. Restart Cursor to see the NASA tools.
The server provides access to numerous NASA data sources including:
{
"method": "nasa/apod",
"params": {
"date": "2023-01-01",
"count": 5,
"thumbs": true
}
}
{
"method": "nasa/mars-rover",
"params": {
"rover": "curiosity",
"sol": 1000,
"camera": "FHAZ"
}
}
{
"method": "nasa/neo",
"params": {
"start_date": "2023-01-01",
"end_date": "2023-01-07"
}
}
{
"method": "nasa/gibs",
"params": {
"layer": "MODIS_Terra_CorrectedReflectance_TrueColor",
"date": "2023-01-01",
"format": "png"
}
}
{
"method": "nasa/power",
"params": {
"parameters": "T2M,PRECTOTCORR,WS10M",
"community": "re",
"latitude": 40.7128,
"longitude": -74.0060,
"start": "20220101",
"end": "20220107"
}
}
Here's how to use the NASA MCP Server 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'
}
});
Configure the server using these environment variables:
Variable | Description |
---|---|
NASA_API_KEY |
Your NASA API key (get at api.nasa.gov) |
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "nasa-mcp" '{"command":"npx","args":["-y","@programcomputer/nasa-mcp-server@latest"],"env":{"NASA_API_KEY":"your-api-key"}}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"nasa-mcp": {
"command": "npx",
"args": [
"-y",
"@programcomputer/nasa-mcp-server@latest"
],
"env": {
"NASA_API_KEY": "your-api-key"
}
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"nasa-mcp": {
"command": "npx",
"args": [
"-y",
"@programcomputer/nasa-mcp-server@latest"
],
"env": {
"NASA_API_KEY": "your-api-key"
}
}
}
}
3. Restart Claude Desktop for the changes to take effect