How to integrate Nasa MCP with CrewAI

Trusted by
AWS
Glean
Zoom
Airtable

30 min · no commitment · see it on your stack

Nasa logo
CrewAI logo
divider

Introduction

This guide walks you through connecting Nasa to CrewAI using the Composio tool router. By the end, you'll have a working Nasa agent that can show me mars rover photos from curiosity on sol 1000, list recent natural disaster events worldwide, find all eonet event categories available through natural language commands.

This guide will help you understand how to give your CrewAI agent real control over a Nasa account through Composio's Nasa MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Nasa with

TL;DR

Here's what you'll learn:
  • Get a Composio API key and configure your Nasa connection
  • Set up CrewAI with an MCP enabled agent
  • Create a Tool Router session or standalone MCP server for Nasa
  • Build a conversational loop where your agent can execute Nasa operations

What is CrewAI?

CrewAI is a powerful framework for building multi-agent AI systems. It provides primitives for defining agents with specific roles, creating tasks, and orchestrating workflows through crews.

Key features include:

  • Agent Roles: Define specialized agents with specific goals and backstories
  • Task Management: Create tasks with clear descriptions and expected outputs
  • Crew Orchestration: Combine agents and tasks into collaborative workflows
  • MCP Integration: Connect to external tools through Model Context Protocol

What is the Nasa MCP server, and what's possible with it?

The Nasa MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to NASA's public data APIs. It provides structured and secure access to a wealth of Earth science, planetary, and event data, so your agent can search datasets, fetch Mars rover photos, explore natural events, and visualize scientific information on your behalf.

  • Search NASA science data collections: Empower your agent to query and filter massive datasets from the Common Metadata Repository (CMR) by spatial, temporal, or metadata criteria.
  • Retrieve Mars rover imagery: Ask your agent to fetch stunning photos captured by Mars rovers for specific Martian days, enabling research and exploration right from your workflow.
  • Monitor natural events worldwide: Let your agent pull up-to-date lists of global natural events—like wildfires, storms, or volcanic activity—using NASA's EONET feeds in ATOM or RSS formats.
  • Visualize and analyze event categories and layers: Direct your agent to explore available data layers and event categories for advanced event visualization and filtering in scientific research.
  • Access detailed event source and magnitude data: Have your agent retrieve metadata about event sources and magnitudes, making it easier to understand the context and scale of natural phenomena tracked by NASA.

Supported Tools & Triggers

Tools
Browse Near Earth ObjectsBrowse the complete NASA near-Earth object (asteroid) dataset with pagination support.
Create Graph RequestTool to create orbital and position graphs for NASA satellites using the Satellite Situation Center (SSC) web service.
Delete CMR AssociationTool to delete an existing association between concepts in NASA's Common Metadata Repository.
Delete CMR ACLTool to delete an Access Control List (ACL) from NASA's Common Metadata Repository.
Download Citation DocumentDownloads a document file from a NASA NTRS (NASA Technical Reports Server) citation.
Get AGAGE Data FilesTool to retrieve information about AGAGE (Advanced Global Atmospheric Gases Experiment) data files.
Get AGAGE Data by File NameSearch for AGAGE (Advanced Global Atmospheric Gases Experiment) data files by file name.
Get AGAGE Data JSON for GraphRetrieve AGAGE atmospheric composition data in JSON format optimized for graphing.
Get AGAGE Data VersionsTool to retrieve information on all AGAGE (Advanced Global Atmospheric Gases Experiment) data versions.
Get Astronomy Picture of the DayRetrieves NASA's Astronomy Picture of the Day (APOD) for a specified date or today.
Get Citation by IDTool to retrieve detailed citation information from NASA Technical Reports Server (NTRS) by citation ID.
Get Citation DownloadsTool to retrieve all available download links for a NASA technical report or publication by citation ID.
Get Citation Revision IDTool to retrieve citation revision IDs from NASA Common Metadata Repository (CMR) GraphQL API.
Get Citations AutocompleteTool to get autocomplete suggestions from NASA NTRS (Technical Reports Server) citations.
Get Citations RedistributionsTool to retrieve redistributed citations from NASA's Technical Reports Server (NTRS).
Get CMR CollectionsTool to retrieve collections from the Common Metadata Repository (CMR).
Get CMR GranulesSearch for data granules in NASA's Common Metadata Repository (CMR).
Get AGAGE CompoundsTool to retrieve information on all data compounds available in NASA's AGAGE (Advanced Global Atmospheric Gases Experiment) API.
Get Data by File NameGet information about specific TOLNet (Tropospheric Ozone Lidar Network) data files by file name.
Get AGAGE Data DownloadDownload AGAGE (Advanced Global Atmospheric Gases Experiment) data files by ID.
Get Data FrequenciesRetrieves all available data frequency options from NASA's AGAGE (Advanced Global Atmospheric Gases Experiment) mission.
Get TOLNet Data JSONTool to retrieve JSON versions of TOLNet (Tropospheric Ozone Lidar Network) data by ID.
Get TOLNet Data JSON for GraphTool to retrieve JSON versions of TOLNet data including O3_Number_Density (ozone mixing ratio) and temporal boundaries.
Get DocumentTool to retrieve metadata for a single TOLNet (Tropospheric Ozone Lidar Network) document by ID.
Get Document DownloadDownload a single TOLNet (Tropospheric Ozone Lidar Network) document by ID.
Get TOLNet DocumentsTool to retrieve document information from NASA's TOLNet (Tropospheric Ozone Lidar Network) archive.
Get DONKI CME DataTool to retrieve Coronal Mass Ejection (CME) data from NASA's DONKI database.
Get DONKI CME AnalysisTool to retrieve Coronal Mass Ejection (CME) analysis data from NASA's DONKI (Database Of Notifications, Knowledge, Information) system.
Get DONKI Geomagnetic StormsTool to retrieve Geomagnetic Storm (GST) data from NASA's Space Weather Database Of Notifications, Knowledge, Information (DONKI).
Get DONKI HSS DataTool to retrieve High Speed Stream (HSS) data from NASA's DONKI space weather database.
Get DONKI IPS DataTool to retrieve Interplanetary Shock (IPS) data from NASA's DONKI space weather database.
Get DONKI Magnetopause Crossing DataTool to retrieve Magnetopause Crossing (MPC) events from NASA's DONKI space weather database.
Get DONKI Space Weather NotificationsTool to retrieve space weather notifications from NASA's DONKI (Space Weather Database Of Notifications, Knowledge, Information).
Get DONKI Radiation Belt Enhancement EventsRetrieves Radiation Belt Enhancement (RBE) events from NASA's DONKI Space Weather Database.
Get DONKI SEP EventsGet Solar Energetic Particle (SEP) events from NASA's DONKI space weather database.
Get DONKI Solar FlaresTool to retrieve Solar Flare (FLR) events from NASA's DONKI (Space Weather Database Of Notifications, Knowledge, Information).
Get DONKI WSA-ENLIL SimulationsRetrieve WSA-ENLIL solar wind model simulation data from NASA's DONKI system.
Get EONET CategoriesTool to retrieve a list of all event categories from EONET.
Get EONET Category EventsTool to retrieve natural events filtered by a specific category from NASA's EONET.
Get EONET Event by IDTool to retrieve a specific natural event by its unique ID from NASA's Earth Observatory Natural Event Tracker (EONET).
Get EONET EventsTool to retrieve natural events from NASA's Earth Observatory Natural Event Tracker (EONET).
Get EONET Events (ATOM)Tool to retrieve a list of natural events in ATOM format.
Get EONET Events GeoJSONTool to retrieve natural events from NASA's Earth Observatory Natural Event Tracker (EONET) in GeoJSON format.
Get EONET Events RSSRetrieve natural events from NASA's Earth Observatory Natural Event Tracker (EONET) in RSS/GeoRSS XML format.
Get EONET LayersRetrieves NASA EONET imagery layers for visualizing natural events.
GET EONET MagnitudesTool to retrieve a list of available event magnitudes and their descriptions.
Get EONET SourcesRetrieves the complete list of event data sources available in NASA's EONET (Earth Observatory Natural Event Tracker) system.
Get EPIC Aerosol Imagery MetadataTool to retrieve metadata for the most recent aerosol index imagery from NASA's DSCOVR EPIC camera.
Get EPIC Aerosol Imagery by DateRetrieves metadata for aerosol index imagery from NASA's EPIC camera for a specific date.
Get EPIC Cloud Fraction ImageryRetrieve metadata for the most recent cloud fraction imagery from NASA's DSCOVR EPIC camera.
Get EPIC Cloud Imagery by DateGet metadata for cloud fraction imagery from DSCOVR EPIC camera for a specific date.
Get EPIC Enhanced Color ImageryRetrieves metadata for the most recent enhanced color Earth imagery from the DSCOVR EPIC camera.
Get EPIC Enhanced Color Imagery by DateRetrieves metadata for enhanced color Earth imagery from DSCOVR EPIC for a specific date.
Get EPIC Natural Color ImageryRetrieve metadata for the most recent natural color Earth imagery from NASA's DSCOVR EPIC camera.
Get EPIC Natural Color Images by DateRetrieves metadata for natural color Earth imagery from DSCOVR EPIC for a specific date.
Get File TypesTool to retrieve information on all data file types from NASA's TOLNET API.
Get GeneLab Data System FilesRetrieves file metadata from NASA's GeneLab Data System (GLDS) for specified dataset IDs.
Get ICESat-2 TracksRetrieves a list of ICESat-2 satellite tracks (Reference Ground Tracks - RGTs) within a specified geographic bounding box.
Get Image Asset ManifestRetrieve a media asset's manifest from the NASA Image and Video Library, including links to all available sizes and formats.
Get Image Metadata LocationRetrieve the location URL of a media asset's metadata manifest from the NASA Image and Video Library.
Get InSight Mars Weather DataRetrieves Mars weather data from NASA's InSight lander at Elysium Planitia.
Get Instruments GroupsTool to retrieve information on all instrument groups from NASA's TOLNET API.
Get Landing PageTool to retrieve the NASA STAC API landing page (root endpoint).
Get ICESat-2 Level-3A DataTool to access ICESat-2 Level-3A product data from OpenAltimetry.
Get Mars Rover PhotosRetrieves photos taken by NASA Mars rovers (Perseverance, Curiosity, Opportunity, Spirit) on a specific Martian sol (day).
Get NEO LookupLookup a specific asteroid by its NASA SPK-ID.
Get OSDR BiospecimenTool to retrieve detailed information about a specific biospecimen from NASA's Open Science Data Repository (OSDR).
Get OSDR ExperimentRetrieve detailed information about a specific OSDR (Open Science Data Repository) experiment by its identifier.
Get OSDR HardwareRetrieve detailed information about specific hardware from NASA's Open Science Data Repository (OSDR).
Get OSDR Study MetadataRetrieve complete metadata for an OSDR (Open Science Data Repository) study dataset.
Get OSDR Mission DetailsRetrieve detailed information about a specific space mission from NASA's Open Science Data Repository (OSDR).
Get OSDR Payload DetailsRetrieve detailed metadata for a specific OSDR payload by its identifier.
Get OSDR Subject InformationRetrieve detailed information about a specific subject (biospecimen) from NASA's Open Science Data Repository (OSDR).
Get OSDR Vehicle InformationRetrieve detailed information about a specific vehicle from NASA's Open Science Data Repository (OSDR).
Get POWER Climatology DataRetrieves long-term climatology data for a specific location from NASA POWER (Prediction Of Worldwide Energy Resources).
Get POWER Daily DataRetrieves daily average solar and meteorological data from NASA POWER (Prediction Of Worldwide Energy Resources).
Get POWER Daily Regional DataTool to retrieve daily average solar and meteorological data for a regional bounding box from NASA POWER (Prediction Of Worldwide Energy Resources).
Get POWER Monthly DataRetrieves monthly average solar and meteorological data for a specific location from NASA POWER (Prediction Of Worldwide Energy Resources).
Get POWER Hourly Temporal DataRetrieves hourly climate and meteorological data from NASA POWER (Prediction of Worldwide Energy Resources) API for a specific location and date range.
Get Processing TypesTool to retrieve information on all data instruments from NASA's AGAGE mission.
Get Product TypesTool to retrieve all data product types from NASA's TOLNET (TOLNet Ozone Lidar Network) API.
Get Satellite LocationsRetrieves satellite location data from NASA's Satellite Situation Center (SSC).
Get AGAGE Data StationsTool to retrieve information on all AGAGE (Advanced Global Atmospheric Gases Experiment) data stations.
Get TechPort ProjectRetrieves detailed information about a specific NASA technology project from TechPort.
Get TOLNet DataTool to retrieve information about TOLNet (Tropospheric Ozone Lidar Network) data files.
Get TOLNet Data CalendarTool to retrieve a date-driven list of all available TOLNet (Tropospheric Ozone Lidar Network) data.
Get Video CaptionsRetrieves the location URL of caption files for NASA video assets from the NASA Image and Video Library.
List EPIC Aerosol DatesTool to retrieve a list of all dates with available aerosol index EPIC imagery.
List EPIC Cloud Fraction DatesRetrieve a listing of all dates with available cloud fraction Earth imagery from DSCOVR EPIC.
List EPIC Enhanced Color DatesRetrieves a listing of all dates with available enhanced color Earth imagery from NASA's DSCOVR EPIC (Earth Polychromatic Imaging Camera).
List EPIC Natural Color DatesRetrieve a listing of all dates with available natural color Earth imagery from DSCOVR EPIC.
List Ground StationsRetrieves the complete list of ground stations available from NASA's Satellite Situation Center (SSC).
List Satellite Locations (GSE/GEO)Retrieves satellite/observatory location data in GSE and GEO coordinate systems from NASA's SSC (Satellite Situation Center).
List ObservatoriesTool to retrieve descriptions of all observatories available from NASA's Satellite Situation Center (SSC).
List OSDR BiospecimensTool to retrieve a list of all biospecimens from the NASA Open Science Data Repository (OSDR).
List OSDR ExperimentsTool to retrieve a list of all experiments from NASA's Open Science Data Repository (OSDR).
List OSDR HardwareTool to retrieve a list of all hardware from NASA's Open Science Data Repository (OSDR).
List OSDR MissionsTool to retrieve a list of all space missions from the NASA Open Science Data Repository (OSDR).
List OSDR PayloadsTool to retrieve a list of all payloads from the NASA Open Science Data Repository (OSDR).
List OSDR SubjectsTool to retrieve a list of all subjects from the NASA Open Science Data Repository (OSDR).
List OSDR VehiclesTool to retrieve a list of all vehicles from the NASA Open Science Data Repository (OSDR).
Query CitationTool to query citation metadata from NASA's GraphQL Earthdata API.
Query Citations via GraphQLTool to query NASA Common Metadata Repository (CMR) GraphQL API for collection citations.
Query CMR CollectionTool to query a single collection from NASA's Common Metadata Repository using its unique concept ID.
Query CMR CollectionsTool to query multiple collections from NASA's Common Metadata Repository via GraphQL.
Query CMR Granule by Concept IDQuery for a single granule (individual data file) from NASA's Common Metadata Repository using its unique concept ID.
Query CMR GranulesTool to query for multiple granules (individual data files) from NASA's Common Metadata Repository via GraphQL.
Query CMR GridsQuery for multiple grids from NASA's Common Metadata Repository (CMR) via GraphQL.
Query CMR ServiceTool to query a single service from NASA's Common Metadata Repository using its unique concept ID.
Query CMR ServicesTool to query for multiple services from NASA's Common Metadata Repository via GraphQL.
Query CMR SubscriptionTool to query a single subscription from NASA's Common Metadata Repository using its unique concept ID.
Query CMR SubscriptionsQuery for multiple subscriptions from NASA's Common Metadata Repository (CMR).
Query CMR ToolTool to query a single tool from NASA's Common Metadata Repository using its unique concept ID.
Query CMR ToolsTool to query multiple tools from NASA's Common Metadata Repository using GraphQL.
Query CMR VariableTool to query a single variable from NASA's Common Metadata Repository using its unique concept ID.
Query Collection DraftTool to query a NASA Earthdata collection draft by ID using the GraphQL API.
Query Data Quality SummariesQuery data quality summaries from NASA's Common Metadata Repository (CMR) GraphQL API.
Query Data Quality SummaryQuery for a single Data Quality Summary from NASA's Common Metadata Repository (CMR) using GraphQL.
Query Exoplanet ArchiveTool to query NASA's Exoplanet Archive NSTED API for exoplanet and related astronomical data.
Query Order OptionTool to query a single order option from NASA Earthdata GraphQL API.
Query Order OptionsTool to query order options for a NASA Earthdata collection using the GraphQL API.
Query PermissionsTool to query permissions from NASA's Common Metadata Repository (CMR) GraphQL API.
Query CMR ProvidersTool to query for a list of data providers from NASA's Common Metadata Repository via GraphQL.
Query Tag DefinitionsTool to query tag definitions from NASA's Common Metadata Repository (CMR) GraphQL API.
Query Tool DraftTool to query a tool draft from NASA's Common Metadata Repository (CMR) GraphQL API.
Query VisualizationTool to query a single visualization from NASA's Common Metadata Repository using its unique concept ID.
Query VisualizationsTool to query for visualizations from NASA's Common Metadata Repository via GraphQL.
Restore Citation RevisionTool to restore a previous version of a citation record within NASA's Common Metadata Repository.
Restore Collection RevisionTool to restore a collection to a previous revision in NASA's Common Metadata Repository.
Restore Visualization RevisionTool to restore a previous revision of a visualization in NASA's Common Metadata Repository.
Search NTRS CitationsTool to search NASA Technical Reports Server (NTRS) citations database.
Search Near Earth ObjectsSearch for near-Earth objects (asteroids) by their closest approach date to Earth.
Search OSDRTool to search NASA Open Science Data Repository (OSDR) for space biology experiments and studies.
Search Public Space DocumentsSearch NASA public space technical documents in the NTRS (NASA Technical Reports Server) repository.
Search SVS VisualizationsTool to search for visualizations in the Scientific Visualization Studio (SVS).
Search Technology Transfer SoftwareSearch NASA's Technology Transfer software catalog for available tools and applications.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before starting, make sure you have:
  • Python 3.9 or higher
  • A Composio account and API key
  • A Nasa connection authorized in Composio
  • An OpenAI API key for the CrewAI LLM
  • Basic familiarity with Python

Getting API Keys for OpenAI and Composio

OpenAI API Key
  • Go to the OpenAI dashboard and create an API key. You'll need credits to use the models, or you can connect to another model provider.
  • Keep the API key safe.
Composio API Key
  • Log in to the Composio dashboard.
  • Navigate to your API settings and generate a new API key.
  • Store this key securely as you'll need it for authentication.

Install dependencies

bash
pip install composio crewai crewai-tools[mcp] python-dotenv
What's happening:
  • composio connects your agent to Nasa via MCP
  • crewai provides Agent, Task, Crew, and LLM primitives
  • crewai-tools[mcp] includes MCP helpers
  • python-dotenv loads environment variables from .env

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here
OPENAI_API_KEY=your_openai_api_key_here

Create a .env file in your project root.

What's happening:

  • COMPOSIO_API_KEY authenticates with Composio
  • USER_ID scopes the session to your account
  • OPENAI_API_KEY lets CrewAI use your chosen OpenAI model

Import dependencies

python
import os
from composio import Composio
from crewai import Agent, Task, Crew
from crewai_tools import MCPServerAdapter
import dotenv

dotenv.load_dotenv()

COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")
What's happening:
  • CrewAI classes define agents and tasks, and run the workflow
  • MCPServerHTTP connects the agent to an MCP endpoint
  • Composio will give you a short lived Nasa MCP URL

Create a Composio Tool Router session for Nasa

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)
session = composio_client.create(user_id=COMPOSIO_USER_ID, toolkits=["nasa"])

url = session.mcp.url
What's happening:
  • You create a Nasa only session through Composio
  • Composio returns an MCP HTTP URL that exposes Nasa tools

Initialize the MCP Server

python
server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users search the internet effectively",
        backstory="You are a helpful assistant with access to search tools.",
        tools=tools,
        verbose=False,
        max_iter=10,
    )
What's Happening:
  • Server Configuration: The code sets up connection parameters including the MCP server URL, streamable HTTP transport, and Composio API key authentication.
  • MCP Adapter Bridge: MCPServerAdapter acts as a context manager that converts Composio MCP tools into a CrewAI-compatible format.
  • Agent Setup: Creates a CrewAI Agent with a defined role (Search Assistant), goal (help with internet searches), and access to the MCP tools.
  • Configuration Options: The agent includes settings like verbose=False for clean output and max_iter=10 to prevent infinite loops.
  • Dynamic Tool Usage: Once created, the agent automatically accesses all Composio Search tools and decides when to use them based on user queries.

Create a CLI Chatloop and define the Crew

python
print("Chat started! Type 'exit' or 'quit' to end.\n")

conversation_context = ""

while True:
    user_input = input("You: ").strip()

    if user_input.lower() in ["exit", "quit", "bye"]:
        print("\nGoodbye!")
        break

    if not user_input:
        continue

    conversation_context += f"\nUser: {user_input}\n"
    print("\nAgent is thinking...\n")

    task = Task(
        description=(
            f"Conversation history:\n{conversation_context}\n\n"
            f"Current request: {user_input}"
        ),
        expected_output="A helpful response addressing the user's request",
        agent=agent,
    )

    crew = Crew(agents=[agent], tasks=[task], verbose=False)
    result = crew.kickoff()
    response = str(result)

    conversation_context += f"Agent: {response}\n"
    print(f"Agent: {response}\n")
What's Happening:
  • Interactive CLI Setup: The code creates an infinite loop that continuously prompts for user input and maintains the entire conversation history in a string variable.
  • Input Validation: Empty inputs are ignored to prevent processing blank messages and keep the conversation clean.
  • Context Building: Each user message is appended to the conversation context, which preserves the full dialogue history for better agent responses.
  • Dynamic Task Creation: For every user input, a new Task is created that includes both the full conversation history and the current request as context.
  • Crew Execution: A Crew is instantiated with the agent and task, then kicked off to process the request and generate a response.
  • Response Management: The agent's response is converted to a string, added to the conversation context, and displayed to the user, maintaining conversational continuity.

Complete Code

Here's the complete code to get you started with Nasa and CrewAI:

python
from crewai import Agent, Task, Crew, LLM
from crewai_tools import MCPServerAdapter
from composio import Composio
from dotenv import load_dotenv
import os

load_dotenv()

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

# Initialize Composio and create a session
composio = Composio(api_key=COMPOSIO_API_KEY)
session = composio.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["nasa"],
)
url = session.mcp.url

# Configure LLM
llm = LLM(
    model="gpt-5",
    api_key=os.getenv("OPENAI_API_KEY"),
)

server_params = {
    "url": url,
    "transport": "streamable-http",
    "headers": {"x-api-key": COMPOSIO_API_KEY},
}

with MCPServerAdapter(server_params) as tools:
    agent = Agent(
        role="Search Assistant",
        goal="Help users with internet searches",
        backstory="You are an expert assistant with access to Composio Search tools.",
        tools=tools,
        llm=llm,
        verbose=False,
        max_iter=10,
    )

    print("Chat started! Type 'exit' or 'quit' to end.\n")

    conversation_context = ""

    while True:
        user_input = input("You: ").strip()

        if user_input.lower() in ["exit", "quit", "bye"]:
            print("\nGoodbye!")
            break

        if not user_input:
            continue

        conversation_context += f"\nUser: {user_input}\n"
        print("\nAgent is thinking...\n")

        task = Task(
            description=(
                f"Conversation history:\n{conversation_context}\n\n"
                f"Current request: {user_input}"
            ),
            expected_output="A helpful response addressing the user's request",
            agent=agent,
        )

        crew = Crew(agents=[agent], tasks=[task], verbose=False)
        result = crew.kickoff()
        response = str(result)

        conversation_context += f"Agent: {response}\n"
        print(f"Agent: {response}\n")

Conclusion

You now have a CrewAI agent connected to Nasa through Composio's Tool Router. The agent can perform Nasa operations through natural language commands.

Next steps:

  • Add role-specific instructions to customize agent behavior
  • Plug in more toolkits for multi-app workflows
  • Chain tasks for complex multi-step operations

How to build Nasa MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Nasa MCP?

With a standalone Nasa MCP server, the agents and LLMs can only access a fixed set of Nasa tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Nasa and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with CrewAI?

Yes, you can. CrewAI fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Nasa tools.

Can I manage the permissions and scopes for Nasa while using Tool Router?

Yes, absolutely. You can configure which Nasa scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Nasa data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.