Skip to main content
The MySQL tool lets an agent query and manage MySQL databases directly.

Overview

MySQL tool allows you to query and manage MySQL databases directly from your AI agents.

Installation

Environment Variables

Quick Start

1

Simple Usage

2

With Configuration

Use the same tool with an agent — see Usage with Agent below, or pass env vars and options from the sections above.

How It Works

Usage with Agent

Available Methods

query(sql)

Execute a SQL query.

execute(sql)

Execute a SQL statement (INSERT, UPDATE, DELETE).

list_tables()

List all tables in the database.

Docker Setup

Common Errors

Best Practices

Read MYSQL_HOST, MYSQL_USER, and MYSQL_PASSWORD from the environment instead of hard-coding them in the tool call.
Agent-generated SELECTs can return huge result sets. Instruct the agent to add LIMIT so results stay within the context window.
Give the agent a read-only MySQL user for analytics tasks so generated SQL cannot modify data.

PostgreSQL

PostgreSQL database

SQLite

SQLite database

MongoDB

NoSQL database