- Home
- MCP servers
- DB Agent
DB Agent
- typescript
0
GitHub Stars
typescript
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
You run a MySQL-focused MCP server that lets you execute queries against a MySQL database from MCP clients. It supports read-only queries without authentication for convenient development, and write operations with authentication for production safety.
How to use
Connect your MCP client to the server at the default HTTP endpoint and use the two provided tools to run queries against your MySQL database. Use the read-only tool for SELECT, SHOW, DESCRIBE, DESC, and EXPLAIN queries without authentication. Use the write tool for INSERT, UPDATE, DELETE, CREATE, DROP, and ALTER queries, which requires user authentication.
Prerequisites you’ll typically have: you run the MCP server locally or on a host, and you point your MCP client at the server URL. If you enable authentication, you must supply a valid API key in your client requests.
How to install
Follow these concrete steps to set up the MCP server and its MySQL backend.
- Install dependencies for the MCP server using Bun.
bun install
- Configure environment variables. Create a file named
.envwith the following values to connect to MySQL and run the server.
# Database settings (required)
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASS=root
DB_NAME=appdb
# Server settings (optional)
PORT=3000
# Authentication settings (optional)
AUTH_ENABLED=false # set to true to enable auth
API_KEY=your-secret-api-key # required when AUTH_ENABLED=true
Additional configuration and startup notes
If you enable authentication (AUTH_ENABLED=true), the API key must be provided by clients in one of these headers: Authorization: Bearer <API_KEY>, Authorization: ApiKey <API_KEY>, or X-API-Key: <API_KEY>.
- Start the MySQL container (required for the database backend). You can build and run the MySQL image as shown.
docker build -t local-mcp-mysql ./docker/mysql
docker run -d \
-p 3306:3306 \
--name mcp-mysql \
-e MYSQL_ROOT_PASSWORD=root \
local-mcp-mysql
docker exec -it mcp-mysql mysql -uroot -proot appdb
Starting the MCP server
- Start the MCP server. It runs as an HTTP server by default and serves requests at the standard path. The default URL is
http://localhost:3000/mcp. If you want to change the listening port, set thePORTenvironment variable before starting the server.
bun run start
To start on a custom port, specify the port environment variable first.
PORT=8080 bun run start
MCP client configuration
Configure your MCP client to connect to the server. Use the HTTP endpoint for remote access. If you enable authentication, include the API key in the request headers as described earlier.
Security and authentication
By default authentication is disabled for development. In production, enable authentication by setting AUTH_ENABLED=true and supply an API_KEY. Ensure clients provide a valid API key in requests.
Available tools
run_query_readonly
Execute read-only SQL statements such as SELECT, SHOW, DESCRIBE, DESC, and EXPLAIN without requiring authentication.
run_query_write
Execute write operations like INSERT, UPDATE, DELETE, CREATE, DROP, and ALTER that require user authentication.