Skip to content

AI-powered FastAPI server that turns natural language into structured Rick & Morty API queries. Built for fun & learning by Eyal Yaakobi.

Notifications You must be signed in to change notification settings

unix14/rick-and-morty-mcp-server

Repository files navigation

🧠 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

About

AI-powered FastAPI server that turns natural language into structured Rick & Morty API queries. Built for fun & learning by Eyal Yaakobi.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published