Instant Schema Prototyping: VS Code + AI + MariaDB MCP

AI models like OpenAI’s GPT, Anthropic’s Claude, and others already are excellent tools for writing applications. With the help of the Model Context Protocol (MCP), AI models can invoke external services and even execute code, including code that runs in your database! In this article, I’ll show you how to start a local MariaDB MCP Server and configure VS Code to use it as a companion AI developer that can create your database schema, insert data, run queries, and more.
Where does MCP fit in the picture?
MariaDB already supports AI workloads with native vector operations—VECTOR columns, vector indexes, and efficient similarity search. Now with the open-source MariaDB MCP Server, developers can expose database access to LLMs in a controlled way. Natural language input is mapped to structured SQL through secure function calls, making it possible for models to query, update, and interact with the database using secure function calls exposed by the MariaDB MCP Server.
In general, an MCP server exposes predefined function calls to backend logic, APIs, or databases. Using MariaDB as an example, the following diagram illustrates the concept:

The process goes like this:
- The user introduces some input. For example “create a table for storing to-do items.”
- The LLM takes the input and generates a tool call. The call is typically a JSON document. So, instead of replying with words in English, the LLM replies with a JSON document. The LLM doesn’t execute anything directly—after all, it can only generate text.
- The MCP client receives the tool call. The environment running the LLM (e.g., VS Code, or an orchestrator like OpenAI function calling) reads the JSON document, connects to the right MCP server and sends the request to it.
- The MCP Server runs the logic. The MCP server is a standalone process that receives the request, runs the logic (e.g., execute a CREATE TABLE statement), and responds with another JSON document.
- The MCP client passes the response back to the LLM. This happens in plain English which is what the LLM understands.
- The LLM uses that response. It uses it as context to generate the final reply to the user.
Running the MariaDB MCP Server using Docker Compose
You can start a MariaDB MCP Server directly using Python tooling, or you can run it in a Docker container instead. Many MCP clients like VS Code, Windsurf, and others allow you to use these options and others. Here, I provide a convenient Docker Compose file that starts both the MariaDB Server (database) and the MariaDB MCP Server.
For this to work you need to clone the MariaDB MCP Server repository from GitHub:
git clone https://github.com/MariaDB/mcp.git
In the root directory of this project, create a new .env file with the following content:
DB_HOST=mariadb
DB_USER=user
DB_PASSWORD=password123
DB_PORT=3306
DB_NAME=demo
MCP_READ_ONLY=false
MCP_MAX_POOL_SIZE=10
EMBEDDING_PROVIDER=openai
OPENAI_API_KEY=[YOUR_API_KEY_HERE]
Replace YOUR_API_KEY_HERE
with your OpenAI API Key. If you prefer, you can use other models. See the instructions here for more information.
When speaking with Ryan Killea (AI Engineer at MariaDB plc), he mentioned an important security feature:
“If a developer is worried about the ability of the MCP server to access data or alter tables on a production database they can either use the read only mode for the MCP server or specify a user with permissions they are comfortable with.”
Open the docker-compose.yml file and make sure that the connection credentials match the ones in your .env file. Notice that with the current version of this Docker Compose file, if you change the MariaDB root password, you have to specify it in two places (environment
and healthcheck
sections). Here’s an example:
services:
mariadb-server:
image: mariadb:11
container_name: mariadb
environment:
MARIADB_ROOT_PASSWORD: rootpassword123
MARIADB_DATABASE: demo
MARIADB_USER: user
MARIADB_PASSWORD: password123
ports:
- "3306:3306"
healthcheck:
test: ["CMD", "mariadb-admin", "ping", "-h", "127.0.0.1", "-p'rootpassword123'"]
interval: 5s
timeout: 3s
retries: 10
mariadb-mcp:
build: .
container_name: mariadb-mcp
env_file: .env
ports:
- "9001:9001"
depends_on:
mariadb-server:
condition: service_healthy
This Docker Compose file defines two services:
mariadb-server
: The MariaDB database (server) with a demo database (schema) and a user and password for your applications and MCP client. The server listens for connections on port 3306. A healthcheck is provided so other services that require MariaDB up and running can wait for it to become available.mariadb-mcp
: The MariaDB MCP Server listening on port 9001. This service is built using the Dockerfile provided in the GitHub repository.
Start the services by running the following command:
docker compose up -d
Check the logs with:
docker logs mariadb-mcp
Configuring VS Code for MariaDB MCP Server
With the MariaDB MCP Server up and running, you can proceed to configure it on your MCP client, which in this case is VS Code. You can add an MCP server using the MCP: Add Server… option in VS Code:

Select HTTP (or Server-Sent Events), introduce the URL http://127.0.0.1:9001/sse, give it a name (for example mariadb-mcp), and choose between making the MCP server available to your current or all workspaces. At this point VS Code is ready!
Interacting with MariaDB in plain English
Open the chat panel in VS Code. Make sure it is in Agent mode:

Enter a prompt like the following:
I’m implementing a TO-DO application. Don’t worry about the actual implementation. For now, just create the MariaDB tables necessary for this app. Use the “demo” database/schema. Also, populate them with example data.
Send this prompt and see VS Code do the job for you! Ask it to do things such as listing the number of to-do items per user, or deleting the example data. If you connect directly to the MariaDB server you should be able to see that the tables and data are indeed there.
What’s next?
From here, you can continue to vibe-code your app or do anything AI enables you to do. For example, I find it useful for implementing services in Java with native SQL queries when using persistence frameworks like MyBatis or jOOQ, but the same applies to other programming languages and tools for that matter. I don’t even have to show the database schema or type table names 100% correctly. The LLM does its job and understands my intentions (mostly!) and the MariaDB MCP Server enables it to interact with the actual database.