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
- 🔍 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
andhttpx
for async performance.
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.
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" }
}
]
}
{
"S01E08: Rixty Minutes was aired in 17.03.2014"
}
- Python 3.11+
- FastAPI
- httpx (async HTTP client)
- python-dotenv
- Uvicorn
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
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")
pip install -r requirements.txt
uvicorn main:app --reload
Test it on: http://localhost:8000/docs
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.
- 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!
If you're curious about this, feel free to reach out via GitHub: github.com/unix14