Norbok7/Codelabs-MCP-Server
If you are the rightful owner of Codelabs-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 Model Context Protocol (MCP) server is a framework designed to facilitate the deployment and interaction with machine learning models, particularly language models, in a structured and efficient manner.
Absolutely, let's walk through setting up your custom GPT—Codelabs Learning Assistant 2025—as a Dockerized MCP (Model Context Protocol) server. This will allow your students to run it locally using Docker and interact with it through Visual Studio Code (VS Code).
🧰 Step 1: Install Docker
For Windows:
-
Download Docker Desktop:
- Visit the Docker Desktop for Windows page.
- Click on "Download for Windows".(datacamp.com)
-
Install Docker Desktop:
- Run the downloaded installer.
- Follow the installation prompts.
- During installation, ensure that the option to use WSL 2 is selected if prompted.(datacamp.com)
-
Start Docker Desktop:
- After installation, launch Docker Desktop from the Start menu.
- Wait for Docker to initialize; you'll see the Docker icon in your system tray when it's ready.(datacamp.com)
-
Verify Installation:
-
Open Command Prompt or PowerShell.
-
Type the following command and press Enter:
docker --version
-
You should see the Docker version information displayed.(knowledgehut.com)
-
For macOS:
-
Download Docker Desktop:
- Visit the Docker Desktop for Mac page.
- Click on "Download for Mac".
-
Install Docker Desktop:
- Open the downloaded
.dmg
file. - Drag the Docker icon to your Applications folder.(datacamp.com)
- Open the downloaded
-
Start Docker Desktop:
- Launch Docker from your Applications folder.
- Wait for Docker to initialize; the Docker icon will appear in your menu bar when it's ready.
-
Verify Installation:
-
Open Terminal.
-
Type the following command and press Enter:
docker --version
-
You should see the Docker version information displayed.(knowledgehut.com)
-
🛠️ Step 2: Prepare Your MCP Server Code
-
Create a Project Directory:
- Create a new folder on your computer, e.g.,
codelabs-mcp-server
.
- Create a new folder on your computer, e.g.,
-
Create the Server Script:
-
Inside this folder, create a file named
server.py
. -
Open
server.py
in your preferred code editor and paste the following code:from mcp.server.fastmcp import FastMCP import openai import os mcp = FastMCP("codelabs-assistant") @mcp.tool() async def answer_question(question: str) -> str: """Answers a question using the GPT model.""" openai.api_key = os.getenv("OPENAI_API_KEY") response = openai.ChatCompletion.create( model="gpt-4", messages=[{"role": "user", "content": question}] ) return response.choices[0].message["content"] if __name__ == "__main__": mcp.run(transport="stdio")
-
-
Create a Requirements File:
-
In the same folder, create a file named
requirements.txt
. -
Add the following lines to specify the dependencies:
openai mcp
-
-
Create a Dockerfile:
-
In the same folder, create a file named
Dockerfile
(no file extension). -
Add the following content to define the Docker image:
FROM python:3.11-slim WORKDIR /app COPY . . RUN pip install --no-cache-dir -r requirements.txt CMD ["python", "server.py"]
-
🧪 Step 3: Build the Docker Image
-
Open Terminal:
-
Navigate to the
codelabs-mcp-server
directory using thecd
command.cd path/to/codelabs-mcp-server
-
-
Build the Docker Image:
-
Run the following command to build your Docker image:
docker build -t codelabs-mcp-server .
-
Docker will process the
Dockerfile
and create an image namedcodelabs-mcp-server
.
-
🧩 Step 4: Configure VS Code for MCP
-
Create Configuration Directory:
- In your project directory (or the directory where students will work), create a folder named
.vscode
.
- In your project directory (or the directory where students will work), create a folder named
-
Create MCP Configuration File:
-
Inside the
.vscode
folder, create a file namedmcp.json
. -
Add the following content to configure the MCP server:
{ "inputs": [ { "type": "promptString", "id": "openai_api_key", "description": "Enter your OpenAI API Key", "password": true } ], "servers": { "codelabs-assistant": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "OPENAI_API_KEY=${input:openai_api_key}", "codelabs-mcp-server" ] } } }
-
🚀 Step 5: Run the MCP Server in VS Code
-
Open VS Code:
- Launch Visual Studio Code.
-
Open the Project Folder:
- Go to File > Open Folder and select the directory containing your project.
-
Access the Command Palette:
- Press
Ctrl+Shift+P
(Windows/Linux) orCmd+Shift+P
(macOS) to open the Command Palette.
- Press
-
Start the MCP Server:
- Type
MCP: List Servers
and select it. - In the list, find
codelabs-assistant
and click Start.
- Type
-
Enter OpenAI API Key:
- When prompted, enter your OpenAI API key.
- The server will start, and you can now interact with your custom GPT through VS Code's chat interface.
By following these steps, you've successfully set up your custom GPT as a Dockerized MCP server, enabling your students to run and interact with it locally through Visual Studio Code. If you need further assistance or have any questions, feel free to ask!