Feedback

Chat Icon

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Building an Advanced Netflix MCP: Introduction and Setup
77%

Coding Requirements

Create a new directory for our FastMCP server project, navigate into it, install FastMCP, and start a new virtual environment:

# Create a new directory for the FastMCP server
mkdir -p $HOME/workspace/fastmcp_netflix/server
cd $HOME/workspace/fastmcp_netflix/server

# Start a new virtual environment
uv init --bare --python=3.12

# Install the required dependencies
uv add "fastmcp[openai]==3.0.2" \
    "psycopg2-binary==2.9.11" \
    "py-key-value-aio[redis]==0.4.4" \
    "sqlalchemy==2.0.46" \
    "python-dotenv==1.2.1"

Since our server will need to connect to the PostgreSQL database, we installed psycopg2, which is a popular PostgreSQL adapter for Python. We also installed SQLAlchemy, which is an Object-Relational Mapping (ORM) library that provides a high-level interface for working with databases in Python.

SQLAlchemy is the ORM and database toolkit you use in our Python code to define models and interact with the database in a high-level way. However, psycopg2 (or psycopg2-binary) is the PostgreSQL driver that SQLAlchemy uses under the hood to actually connect to and communicate with your PostgreSQL database.

To use Redis for state management, we installed the py-key-value-aio library with Redis support, which provides an asynchronous interface for working with Redis in Python

We also installed python-dotenv to manage our environment variables, which will include our database connection details.

Since we're going to use the MCP server to summarize movie metadata using an LLM, we need to access to another API which is the OMDB API (Open Movie Database). This service provides a free RESTful API to access movie metadata, and we will use it to fetch additional information about movies in our database. To authenticate with the OMDB API, we need an API key, which you can obtain for free by registering on their website.

Let's first create a .env file in the root of our server project:

cat > $HOME/workspace/fastmcp_netflix/server/.env <
DB_HOST=localhost

DB_PORT=5432

DB_NAME=netflix

Practical MCP with FastMCP & LangChain

Engineering the Agentic Experience

Enroll now to unlock current content and receive all future updates for free. Your purchase supports the author and fuels the creation of more exciting content. Act fast, as the price will rise as the course nears completion!