Table of Contents

Wrap Any API as an MCP Server
Model Context Protocol (MCP) is quickly becoming one of the most interesting ways to add new features to AI tools like Claude Desktop.
Here we told you about how to wrap any API as an MCP server using FastMCP in this guide. We'll do this by connecting NASA's public APIs to Claude Desktop. You will have a completely functional custom MCP server that talks to NASA's services, can be tested in the browser, and can be used as a local MCP tool through Claude Desktop by the end.
If you're a developer who is new to MCP, a creator who wants to integrate custom data sources to their AI processes, or anyone building automations using real time APIs, this lesson is for you.
Why should you wrap an API as an MCP server?
MCP lets AI models access outside resources in a safe and organized way. Instead of depending on plain text prompts to express what you want an API to perform, MCP tools provide precise schema definitions, safe execution, and consistent outcomes.
By enclosing the NASA API inside an MCP server, Claude Desktop can:
- Fetch NASA’s Astronomy Picture of the Day
- Look through NASA's picture library
- Get structured JSON results
- Use the data inside chats
- Automate workflows, summaries, and more
The same strategy works for any API you wish to integrate—weather APIs, banking APIs, your internal microservices, databases, etc.
Step 1: Clone the NASA MCP Repository
To get started immediately, clone the NASA MCP sample project:
git clone https://github.com/BpSpacer/nasa-api-mcpThis repository already provides a rudimentary FastMCP server implementation. Make sure you have Python and uv installed.
uv is a quick Python package manager and a great replacement for pip.
If you don’t have it:
pip install uvStep 2: Set Up the Environment
Before launching the server, you require an API key from NASA.
Go to the NASA API Portal, create an account, and generate your key. It’s free.
Now open the cloned project folder in your terminal:
uv venvActivate the environment:
Windows .venv\Scripts\activate
Mac/Linux source .venv/bin/activateOnce activated, install the required dependencies:
uv add python-dotenv
uv add python-dotenv requests notebook mcpYou may confirm the installed packages with:
uv listYour setup is now ready to execute the MCP server.
Step 3: Run the MCP Server
FastMCP offers an inspector tool that enables you test your MCP server graphically. Start it using:
npx @modelcontextprotocol/inspector uv run python nasa_mcp_server.pyAfter launching, you’ll see a local URL such as:
http://localhost:6274/?MCP_PROXY_AUTH_TOKEN=your-generated-tokenOpen this link in your browser.
Inside the inspector dashboard, click the Tools tab.
You should see the two NASA API tools:
get_nasa_apod obtains NASA’s Astronomy Picture of the Day
search_images_data queries NASA’s picture database
Click them to submit test queries and validate that your MCP server is working appropriately. This step is crucial. Claude Desktop will rely on these tools to fetch data.
Step 4: Connect Your MCP Server to Claude Desktop
Now it’s time to integrate the server with Claude Desktop.
Open Claude Desktop and navigate to:
Settings → Developer → Edit Config
This opens your claude_desktop_config.json.
Add your new server like this:
{
"mcpServers": {
"nasa-mcp": {
"command": "your-file-path",
"args": [
"--directory",
"main-folder-path",
"run",
"python",
"nasa_mcp_server.py"
]
}
}
}
Replace:
your-file-path the path to your executable or Python
main-folder-path your project directory
Save the file and restart Claude Desktop.
Under Developer MCP Servers, you should now see your NASA MCP server listed as operating.
If it appears in the list, the connection was successful.
Step 5: Chat with NASA APIs in Claude Desktop
With everything connected, you can now start using the NASA API straight in your Claude discussions. Try prompts like:
- Use this get_nasa_apod tool to fetch today’s Astronomy Picture of the Day.
- It will search the NASA image database for Mars rover images using search_images_data.
- Summarize the image description returned by NASA.
Claude may now call your custom MCP tools, retrieve real data from NASA, and use it naturally within the chat.
This offers up many possibilities for building data-rich assistants, scientific search tools, instructional apps, and more.
Wrapping an API as an MCP server is one of the cleanest ways to enhance AI desktop programs like Claude. Using FastMCP, uv, and Claude Desktop, you can establish powerful tool integrations with just a few steps.
In this article, we wrapped NASA’s public APIs, but you may follow the exact same method to integrate any.
Join the discusstion
No comments yet.
