To explore Docker MCP Toolkit, we will use two MCP server in the toolkit, namely PostgreSQL and Playwright.
Companion Video: https://youtu.be/43oJi_gAucU
What is Docker MCP Toolkit?
The Docker MCP Toolkit enables hosting and managing MCP servers. These servers expose APIs for specific development tasks, such as retrieving GitHub issue data or querying databases using natural language.
Prerequisites
You will need the following before you can continue:
- Docker Desktop (latest version)
- Visual Studio Code (latest version)
- GitHub Copilot extension for VS Code
- GitHub Copilot with Chat and Agent Mode enabled
1) Explore PostgreSQL MCP Server
We will use natural language to query a PostgreSQL database that is already pre-loaded with the sample Northwind database. To run the PostgreSQL server in a docker container on your computer, execute the following command from any terminal window:
docker run --name psqlnw -e POSTGRES_PASSWORD=VerySecret -p 5433:5432 -d melmasry/nw-psql:1.0.0
Start “Docker Desktop” on your computer and go to the Containers tab on the left navigation. You will see that the psqlnw container is running.
Next, let us use the Docker MCP Toolkit. In Docker Desktop, click on “MCP Toolkit” in the left navigation.
Click on the Catalog tab. This will show you a list of MCP Servers that are ready for you to explore.
We will start with PostgreSQL. Find the PostgreSQL MCP Server by entering ‘postgr’ in the filter field. Then click on + to add it to your list.
You will be asked to enter a secret. This is nothing but the connection string and it is based on this format:
postgresql://readonly_user:readonly_password@host:port/database_name
In our case, this would be:
postgresql://postgres:VerySecret@host.docker.internal:5433/northwind
Click on the "My Servers" tab to see the MCP servers that you have chosen.Connect Docker MCP Toolkit to Visual Studio Code
Let us query our northwind database in PostgreSQL from VS Code. Go to a working directory and execute these commands to create an empty folder on your computer:
mkdir mcp-servercd mcp-server
In the same terminal window, logout and login into docker with:
docker logout
docker login
Start VS Code in the folder with
code .
In VS Code, open the Command Palette by pressing Ctrl + Shift + P (or Cmd + Shift + P on macOS).
Select “Add MCP Server”.
Enter the gateway command:
docker mcp gateway run
Give the server an ID named:
my-mcp-server
Choose “Workspace Available in this workspace, runs locally”.
Click Trust.
A file named mcp.json is created in a .vscode folder with this content:
Note that the server is running.
Inside the Github Copilot Chat window, choose Agent and any Claude model. Click on the tools icon to see active MCP servers.
You will find MCP servers that are configured in VS Code. Among them will be the one we enabled in the Docker MCP Toolkit.
You will notice that it only has one tool: “query Run a read-only SQL query”. This is all that is needed to query the northwind database.
Click ok the Ok button to close the tools popup.
Enter this prompt in the GitHub Copilot window:
What are the tables in the PostgreSQL northwind database?
You will be asked to click on the Allow button.
Try this other prompt:
What are the products supplied by "Exotic Liquids"?
You will get a similar response to this:
You now have two MCP servers in our list: Playwright and PostgreSQL.
Back in VS Code, restart the MCP Server in the .vscode/mcp.json file.
In the VS Code GitHub Copilot Chat window, enter this prompt:
Using the tools provided from the Docker MCP Server, navigate to https://www.bbc.com/, find the two most important business stories.
I got the following response at the time of writing this article:
No comments:
Post a Comment