rick-and-morty-mcp-server

unix14/rick-and-morty-mcp-server

3.1

If you are the rightful owner of rick-and-morty-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Rick and Morty API MCP is a FastAPI project that leverages AI to interact with the Rick and Morty API, processing natural language queries to extract meaningful data.

🧠 Rick and Morty API MCP

This is a small AI-powered FastAPI project that interacts with the Rick and Morty API, designed to process free-form user text (like "Tell me about an episode with Blips") and extract meaningful queries using an MCP-style endpoint (Model Context Protocol).

πŸ“š Built as part of my personal learning journey into Python, AI agent architecture, and API design.
πŸ§‘β€πŸ’» GitHub: unix14


Rick and Morty Inspired Header


πŸš€ Features

  • πŸ” Free-text AI endpoint (/mcp) for extracting intent and arguments from natural language.
  • πŸŽ₯ Filters episodes by name keywords and returns air dates in a friendly format.
  • πŸ‘€ (WIP) Character search functionality.
  • πŸ“¦ Cleanly loads secrets (e.g., API keys) from .env using a separate config file.
  • ⚑ Uses FastAPI and httpx for async performance.

Live Preview

You can access a live preview of the Rick and Morty MCP Server running here.

Feel free to test the API and explore its features through this URL.


πŸ§ͺ Example

Request:

POST /mcp
{
  "messages": [
    { "role": "user", "content": "Give me details about an episode with something like Rixty" }
  ],
  "data_requests": [
    {
      "name": "get_episodes_by_name",
      "arguments": { "name_keyword": "Rixty" }
    }
  ]
}

Response:

{
  "S01E08: Rixty Minutes was aired in 17.03.2014"
}

πŸ›  Tech Stack

  • Python 3.11+
  • FastAPI
  • httpx (async HTTP client)
  • python-dotenv
  • Uvicorn

πŸ“ Project Structure

rick-and-morty-api-mcp/
β”œβ”€β”€ main.py        # FastAPI app with /mcp endpoint
β”œβ”€β”€ config.py      # Loads API keys and env variables
β”œβ”€β”€ .env           # Local secret store
β”œβ”€β”€ test_*.py      # Simple test scripts
└── README.md

πŸ” Environment Setup

Create a .env file in the root:

MY_API_KEY=your-key-here

Then in config.py, it's loaded like this:

from dotenv import load_dotenv
import os

load_dotenv()
API_KEY = os.getenv("MY_API_KEY")

▢️ Running the Server

pip install -r requirements.txt
uvicorn main:app --reload

Test it on: http://localhost:8000/docs


πŸ“ˆ Motivation

I built this project as part of my self-guided study in:

  • Natural Language to structured data pipelines
  • AI-oriented API architecture (MCP-style thinking)
  • Async APIs and Python backend development

It’s a stepping stone towards building intelligent agents that understand human intent through structured context.


🧠 Future Ideas

  • Integrate OpenAI or LLMs to automatically convert user messages to data_requests
  • Add more endpoint support (characters, locations, episodes, etc.)
  • Improve fuzzy matching and scoring on episode names
  • Add a simple front-end for fun!

πŸ“« Contact

If you're curious about this, feel free to reach out via GitHub: github.com/unix14