unix14/rick-and-morty-mcp-server
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
π 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
andhttpx
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