We have created a GitHub Codespace for you to experiment with building MCP servers without any local setup required.
The Codespace comes pre-configured with Python, the MCP SDK, and all the tools you need. You’ll just need to configure your Neo4j database credentials to get started.
In this lesson, you’ll learn how to launch your Codespace and set up your environment variables.
Get started
The repository, neo4j-graphacademy/genai-mcp-build-custom-tools-python, has been created for this course. It contains any starter code and resources you need.
You can use a GitHub codespace as an online IDE and workspace for this course. It will automatically clone the course repository and set up your environment.
GitHub Codespaces
You will need to login with a GitHub account. The GitHub Codespaces free monthly usage will cover the duration of this course.
Develop on your local machine
You will need Python 3.10 or higher installed.
This course uses uv as the Python package manager.
Install uv by following the installation instructions.
Clone the github.com/neo4j-graphacademy/genai-mcp-build-custom-tools-python repository:
git clone https://github.com/neo4j-graphacademy/genai-mcp-build-custom-tools-pythonNavigate to the project directory:
cd genai-mcp-build-custom-tools-pythonExplore the Repository
The repository contains a server/ directory where you will build your MCP server.
Here are the important directories:
-
server/- Your MCP server code will go here -
client/- An interactive Python client for testing your MCP server -
solutions/- Complete solutions for each of the challenges -
.github/- GitHub configuration including Codespace setup
Set Up Environment Variables
Throughout this course, you’ll connect your MCP server to a Neo4j database with real movie data.
We have created a Neo4j Sandbox instance for you to use during this course, loaded with thousands of movies, actors, directors, and user ratings.
To define the connection details as environment variables, create a .env file in the server/ directory with the following values:
NEO4J_URI={instance-scheme}://{instance-ip}:{instance-boltPort}
NEO4J_USERNAME={instance-username}
NEO4J_PASSWORD={instance-password}
NEO4J_DATABASE={instance-database}Accessing Your Credentials
Your Neo4j Sandbox credentials are displayed above.
Simply copy each value and paste it into your .env file:
- NEO4J_URI
-
bolt://{instance-ip}:{instance-boltPort}
- NEO4J_USERNAME
-
{instance-username}
- NEO4J_PASSWORD
-
{instance-password}
Have your own Neo4j Aura database?
If you have a Neo4j Aura database with the Recommendations dataset, you can use those credentials instead in your .env file.
Verify Your Setup
To verify your setup, run the test_environment.py script.
uv --directory client run test_environment.pyYou should see an OK message if you have set up your environment correctly. If any tests fail, check the contents of the .env file.
...
----------------------------------------------------------------------
Ran 3 tests in 0.366sAccessing Environment Variables in Python
Throughout the course, you’ll load environment variables using the python-dotenv package, and access them using Python’s os module:
# load the .env file
from dotenv import load_dotenv
load_dotenv()
# access the environment variables
import os
uri = os.getenv("NEO4J_URI", "bolt://localhost:7687")
username = os.getenv("NEO4J_USERNAME", "neo4j")
password = os.getenv("NEO4J_PASSWORD", "password")Summary
Congratulations! You now have everything set up:
-
GitHub Codespace - Your ready-to-use development environment
-
Neo4j Instance - A free Neo4j instance pre-loaded with movie data for you to use during the course
-
Environment variables - Secure credential management configured
-
Connection verified - You’ve confirmed your database is working
You’re all set to build your first MCP server!