Skip to content

Latest commit

 

History

History
79 lines (49 loc) · 2.96 KB

File metadata and controls

79 lines (49 loc) · 2.96 KB

Custom MCP Host for the NASA PDS MCP Server

This directory contains the Gradio-based web interface for interacting with the NASA Planetary Data System (PDS) MCP server for exploring NASA planetary data through an AI agent powered by HuggingFace's smolagents library and the OpenAI SDK.

NASA PDS MCP Host Interface

This implementation serves as an example of a custom MCP Host, showing that this MCP server can go beyond 3rd party clients, and it can be integrated and configured for downstream applications.

Ex: There is a suggested instructions prompt here for the PDS MCP Server. This needs to be configured on the MCP client side.

Overview

A simplified Gradio application specifically configured for the NASA PDS MCP server:

  • MCP Integration: Direct integration with the PDS MCP server using smolagent's MCPClient
  • Tool Discovery: Automatically discovers and loads available PDS tools
  • OpenAI Integration: Uses OpenAI's GPT-4.1 model for agent reasoning
  • Streaming Support: Real-time response streaming for better user experience

Usage

Prerequisites

  1. Install required dependencies from requirements.txt

  2. Set up environment variables in a .env file:

PYTHON_PATH=/path/to/your/python
MCP_SERVER_PATH=/path/to/pds_mcp_server.py
OPENAI_API_KEY=your_openai_api_key_here

Running the Gradio Interface

python pds-mcp-client.py

Customization

Modifying the Agent

The pds-mcp-client.py file can be customized to:

  • Change the model provider (modify model_id in OpenAIServerModel)
  • Adjust agent parameters (max_steps, streaming options) or type (ToolCallingAgent or CodeAgent)
  • Modify prompt templates for different use cases and instructions

UI

The GradioUI is originally a pre-built smolagents component. It has already been altered here in gradio_smolagents_ui.py. Feel free to alter it more for your use case.

Technical Details

Architecture

  • Frontend: Gradio web interface with real-time updates (customized from HuggingFace's GradioUI component)
  • Backend: smolagents framework with MCP client integration
  • Data Source: NASA PDS Registry API via MCP server
  • Model: OpenAI GPT-4.1 (can be configured to any model provider HuggingFace supports)

MCP Host Architecture

Troubleshooting

Common Issues

  1. API Key Not Working

    • Ensure the API key is valid and has sufficient credits
    • Check that the key is properly entered in the UI
    • Verify the key has access to the required model
  2. MCP Server Connection Issues

    • Verify the MCP server path in environment variables
    • Ensure the MCP server is running and accessible
    • Check Python path configuration