Skip to main content

An AWS Labs Model Context Protocol (MCP) server for mysql

Project description

AWS Labs MySQL MCP Server

An AWS Labs Model Context Protocol (MCP) server for Aurora MySQL

Features

Natural language to MySQL SQL query

Converting human-readable questions and commands into structured MySQL-compatible SQL queries and executing them against the configured Aurora MySQL database.

Prerequisites

  1. Install uv from Astral or the GitHub README
  2. Install Python using uv python install 3.10
  3. This MCP server can only be run locally on the same host as your LLM client.
  4. Set up AWS credentials with access to AWS services
    • You need an AWS account with appropriate permissions
    • Configure AWS credentials with aws configure or environment variables

Installation

Configure the MCP server in your MCP client configuration (e.g., for Amazon Q Developer CLI, edit ~/.aws/amazonq/mcp.json):

{
  "mcpServers": {
    "awslabs.mysql-mcp-server": {
      "command": "uvx",
      "args": [
        "awslabs.mysql-mcp-server@latest",
        "--allow_write_query"
      ],
      "env": {
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1",
        "FASTMCP_LOG_LEVEL": "ERROR"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Windows Installation

For Windows users, the MCP server configuration format is slightly different:

{
  "mcpServers": {
    "awslabs.mysql-mcp-server": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "uv",
      "args": [
        "tool",
        "run",
        "--from",
        "awslabs.mysql-mcp-server@latest",
        "awslabs.mysql-mcp-server.exe"
      ],
      "env": {
        "FASTMCP_LOG_LEVEL": "ERROR",
        "AWS_PROFILE": "your-aws-profile",
        "AWS_REGION": "us-east-1"
      }
    }
  }
}

NOTE: the MCP config examples include --allow_write_query to illustrate how to enable write queries. If you want to disable write queries, remove the --allow_write_query option.

Support for Database Cluster Creation

You can use the following LLM prompt to create a new Aurora MySQL cluster:

Create an Aurora MySQL cluster named 'mycluster' in us-west-2 region


Connection Methods

The MCP server supports connecting to multiple database endpoints using different connection methods via LLM prompts.

Database Types

These engine values match AWS RDS API engine strings, so they can be passed through to aws rds calls without translation:

  • aurora-mysql: Amazon Aurora MySQL
  • mysql: Amazon RDS for MySQL
  • mariadb: Amazon RDS for MariaDB

Self-hosted MySQL/MariaDB endpoints don't need a database_type — connect directly via mysqlwire with the endpoint, port, and credentials.

Example Prompts

Connect using RDS Data API:

Connect to database named mydb in Aurora MySQL cluster 'my-cluster' with database_type as aurora-mysql, using rdsapi as connection method in us-west-2 region

Connect using mysqlwire (Aurora MySQL):

Connect to database named mydb with database endpoint as my-amy-instance-1.ctgfg6yyo9df.us-west-2.rds.amazonaws.com with database_type as aurora-mysql, using mysqlwire as connection method in us-west-2 region

Connect using mysqlwire (RDS MySQL):

Connect to database named mydb with database endpoint as test-rds-instance-1.ctgfg6yyo9df.us-west-2.rds.amazonaws.com with database_type as mysql, using mysqlwire as connection method in us-west-2 region

Connect using mysqlwire (RDS MariaDB):

Connect to database named mydb with database endpoint as test-mariadb-instance-1.ctgfg6yyo9df.us-west-2.rds.amazonaws.com with database_type as mariadb, using mysqlwire as connection method in us-west-2 region


Supported Connection Methods

Method Description aurora-mysql mysql mariadb
rdsapi Connect to Aurora MySQL using the RDS Data API. Requires Data API enabled on the cluster.
mysqlwire Connect directly using the MySQL wire protocol. Requires VPC connectivity.
mysqlwire_iam Wire protocol with IAM authentication. Requires IAM auth enabled on the cluster.

Prerequisites by Connection Method

mysqlwire / mysqlwire_iam

  • VPC security group must allow inbound connections from your MCP server to the database
  • For mysqlwire_iam: IAM authentication must be enabled on the Aurora MySQL cluster

rdsapi

  • RDS Data API must be enabled on the Aurora MySQL cluster
  • Appropriate IAM permissions for Data API access

AWS Authentication

The MCP server uses the AWS profile specified in the AWS_PROFILE environment variable. If not provided, it defaults to the "default" profile in your AWS configuration file.

"env": {
  "AWS_PROFILE": "your-aws-profile"
}

Make sure the AWS profile has permissions to access the RDS Data API, and the secret from AWS Secrets Manager. The MCP server creates a boto3 session using the specified profile to authenticate with AWS services. Your AWS IAM credentials remain on your local machine and are strictly used for accessing AWS services.

Development setup

This package ships the Amazon RDS global CA bundle inside the wheel so IAM authenticated connections (mysqlwire_iam) can perform strict TLS verification out of the box. The PEM itself is not checked into source control; it is fetched at build time by hatch_build.py.

Why the bundle is fetched at build time

AWS rotates the RDS global CA bundle without notice. Keeping the PEM out of source control avoids committing binary blobs to code review, and lets the build hook automatically pick up the latest bundle from https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem on every build. Runtime TLS validation against the bundled CA handles cert chain and FQDN matching in the usual way.

Running the build hook

uv build, uv sync, pip wheel, and pip install from source all invoke the hook automatically. The hook is idempotent: if the PEM is already on disk, it skips the fetch.

To run the hook standalone (for example, to populate the PEM in an editable checkout that has not yet been built):

python hatch_build.py

This writes the bundle to awslabs/mysql_mcp_server/connection/rds_global_bundle.pem.

Building offline

If the build machine cannot reach truststore.pki.rds.amazonaws.com, the hook fails with an error that includes a curl recovery command. Run that on a connected host once and rerun the build; the hook will use the placed file.

Optional: override the CA bundle at runtime

Pass --ca_bundle <path> to the server to use a PEM other than the one bundled with the package. Useful for enterprises that maintain their own trust store, or if AWS rotates the CA faster than a new wheel is published:

uvx awslabs.mysql-mcp-server@latest --ca_bundle /path/to/custom.pem

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

awslabs_mysql_mcp_server-1.0.21.tar.gz (289.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

awslabs_mysql_mcp_server-1.0.21-py3-none-any.whl (118.2 kB view details)

Uploaded Python 3

File details

Details for the file awslabs_mysql_mcp_server-1.0.21.tar.gz.

File metadata

File hashes

Hashes for awslabs_mysql_mcp_server-1.0.21.tar.gz
Algorithm Hash digest
SHA256 d6bf870e93c40b60705f78c39ec18ef8c2b88ab701b507d5ba955affe655874c
MD5 4b533da244d6ab75368cc3fdf37a8dbf
BLAKE2b-256 da295a15670ea4220d695d3cb06e9ba5e599c4815f6b00f9f865073a6e72fe0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_mysql_mcp_server-1.0.21.tar.gz:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file awslabs_mysql_mcp_server-1.0.21-py3-none-any.whl.

File metadata

File hashes

Hashes for awslabs_mysql_mcp_server-1.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 2c019136fd895c15f29fa25bd3d1c13761c6e64996a7b23c0ed4dcf831b3fea8
MD5 4cd5b87df7ec49e4d579b5466520e2f0
BLAKE2b-256 0b78977102bdfa0ece30deb60c36b27db3d172a319c232730ee9bd010f0a7c9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for awslabs_mysql_mcp_server-1.0.21-py3-none-any.whl:

Publisher: release.yml on awslabs/mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page