MySQL
MySQL
Connect agents to a MySQL database so they can answer questions from your data with SQL.
Explore your data
- Look up records, join tables, and summarize results.
- Inspect tables and columns to find the data a question needs.
- Read JSON columns as structured data.
Make changes when you allow it
With Write access, agents can also insert, update, and delete rows or change the schema. With Read access, every statement runs in a read-only session and only reading statements are accepted, so data, schema and server settings cannot change. Your database user's privileges always apply.
Setup instructions
Setup instructions
Connect MySQL
-
Create a MySQL user for Houston with only the privileges agents need. For read-only access, for example:
CREATE USER 'houston'@'%' IDENTIFIED BY 'choose-a-strong-password' REQUIRE SSL; GRANT SELECT ON app.* TO 'houston'@'%';With Read access, Houston accepts only reading statements, such as SELECT and SHOW, in a read-only session. An account with only read privileges keeps that true for any stored function a query calls.
-
Make the server reachable from the internet over TLS. Houston always verifies that the server certificate is issued by a public certificate authority for the host name you enter, and never connects without TLS.
-
In Houston, choose the access level, then enter the host, port, database, username, and password, and select Add connection.
Files
Files
connector.luau
-- MySQL over Houston's verified-TLS connection. Credentials stay on Houston. type Params = {string | number | boolean} type Result = { columns: {string}, rows: {{[string]: any}}, truncated: boolean, affectedRows: number?, lastInsertId: number?, } local MAX_ROWS = 10000 local help = { text = "mysql: SQL on one MySQL database. Each call is one statement on its own connection; your database grants still apply.", functions = {} :: {[string]: any}, } local exports: {[string]: any} = {help = help} local parameterSchema = {type = "array", items = {type = {"string", "number", "boolean"}}} help.functions.query = { description = [[Runs one SELECT, WITH, SHOW, DESCRIBE, EXPLAIN, TABLE or VALUES statement in a read-only session. Bind values with ? in sql and pass them in order as params (strings, numbers, booleans). rows are objects keyed by column name, in columns order; NULL columns are absent. Integer, floating-point and JSON columns become Lua values; integers beyond 2^53, DECIMAL, dates, times and text keep MySQL's text form, such as '2026-01-31 09:30:00' for DATETIME. Binary columns become '\x'-prefixed hex, such as '\x00ff'. At most 10,000 rows or 4 MiB are returned; truncated tells when more exist, so add LIMIT, filters or aggregation. Give duplicate column names an alias.]], args = {"sql", "params"}, inputSchema = { type = "object", properties = {sql = {type = "string", minLength = 1}, params = parameterSchema}, required = {"sql"}, additionalProperties = false, examples = {{sql = "SELECT id FROM users WHERE team = ?", params = {"core"}}}, }, annotations = {readOnlyHint = true, openWorldHint = true}, } function exports.query(sql: string, params: Params?): Result return await(db.query({sql = sql, params = params, maxRows = MAX_ROWS, readOnly = true})) end if houston.allows("data:write") then help.functions.execute = { description = [[Runs one statement that may change data, with the same parameters as query. affectedRows counts changed rows; lastInsertId is the AUTO_INCREMENT value an INSERT generated. A failed or interrupted call may already have applied its change, so check before running it again.]], args = {"sql", "params"}, inputSchema = { type = "object", properties = {sql = {type = "string", minLength = 1}, params = parameterSchema}, required = {"sql"}, additionalProperties = false, examples = {{sql = "INSERT INTO tasks (title) VALUES (?)", params = {"Ship it"}}}, }, annotations = {readOnlyHint = false, openWorldHint = true}, } function exports.execute(sql: string, params: Params?): Result return await(db.query({sql = sql, params = params, readOnly = false})) end end return exportshouston.json
{ "schema_version": 2, "name": "MySQL", "files": [ "connector.luau" ], "icon": "icon.svg", "access": [ { "name": "data", "label": "Access", "levels": [ { "value": "read", "label": "Read" }, { "value": "write", "label": "Write" } ], "default": "read" } ], "config": { "host": { "label": "Host", "order": 2, "required": true, "type": "string" }, "port": { "default": 3306, "label": "Port", "maximum": 65535, "minimum": 1, "order": 3, "type": "integer" }, "database": { "label": "Database", "order": 4, "required": true, "type": "string" }, "username": { "label": "Username", "order": 5, "required": true, "type": "string" }, "password": { "label": "Password", "order": 6, "required": true, "type": "secret" } }, "proxy": [ { "match": { "protocol": "mysql" }, "action": { "connection": { "host": "{{config.host}}", "port": "{{config.port}}", "database": "{{config.database}}", "user": "{{config.username}}", "password": "{{config.password}}", "tls": { "mode": "verify-full" } } } } ] }icon.svg
README.md
--- description: Give agents SQL access to a MySQL database, read-only unless you allow changes. --- # MySQL Connect agents to a MySQL database so they can answer questions from your data with SQL. ## Explore your data - Look up records, join tables, and summarize results. - Inspect tables and columns to find the data a question needs. - Read JSON columns as structured data. ## Make changes when you allow it With **Write** access, agents can also insert, update, and delete rows or change the schema. With **Read** access, every statement runs in a read-only session and only reading statements are accepted, so data, schema and server settings cannot change. Your database user's privileges always apply.SETUP.md
# Connect MySQL 1. Create a MySQL user for Houston with only the privileges agents need. For read-only access, for example: ```sql CREATE USER 'houston'@'%' IDENTIFIED BY 'choose-a-strong-password' REQUIRE SSL; GRANT SELECT ON app.* TO 'houston'@'%'; ``` With **Read** access, Houston accepts only reading statements, such as SELECT and SHOW, in a read-only session. An account with only read privileges keeps that true for any stored function a query calls. 2. Make the server reachable from the internet over TLS. Houston always verifies that the server certificate is issued by a public certificate authority for the host name you enter, and never connects without TLS. 3. In Houston, choose the access level, then enter the host, port, database, username, and password, and select **Add connection**.tests
authentication.luau
return { contract = function(m) m.authentication({ { auth = {}, config = { database = "sample", host = "database.example.com", password = "synthetic-root-secret", username = "reader", }, method = "", native = true, publisher = {}, }, }) end, }read_only.luau
-- Read access exposes query alone, and it always asks for a read-only statement. return { scenario = {publisher = {}, auth_method = "", auth_config = {}, config = {host = "db.example.com", database = "app", username = "reader", password = "fixture-password"}}, access = {data = "read"}, configure = function() requests = {} db = {query = function(request) table.insert(requests, request) return fixture.operation({columns = {"id"}, rows = {{id = 7}}, truncated = false}) end} end, run = function(exports) assert(exports.execute == nil, "read access must not expose execute") local result = fixture.example("query") assert(result.rows[1].id == 7 and result.truncated == false) local request = requests[1] assert(request.sql == "SELECT id FROM users WHERE team = ?" and request.params[1] == "core") assert(request.readOnly == true and request.maxRows == 10000) end, }read_write.luau
-- Write access adds execute, which sends a statement allowed to write. return { scenario = {publisher = {}, auth_method = "", auth_config = {}, config = {host = "db.example.com", database = "app", username = "writer", password = "fixture-password"}}, access = {data = "write"}, configure = function() requests = {} db = {query = function(request) table.insert(requests, request) return fixture.operation({columns = json.decode("[]"), rows = json.decode("[]"), truncated = false, affectedRows = 1, lastInsertId = 12}) end} end, run = function(exports) local result = fixture.example("execute") assert(result.affectedRows == 1 and result.lastInsertId == 12) assert(requests[1].readOnly == false and requests[1].params[1] == "Ship it") end, }