Skip to content
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
98d8842
Added list_table_stats tool for MySQL
sumeetdhingra-google Apr 2, 2026
f63fe80
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 2, 2026
be4c7c3
changes added to verify connected db
sumeetdhingra-google Apr 2, 2026
2f93a19
minor fixes
sumeetdhingra-google Apr 2, 2026
747fbb0
updated tool defination
sumeetdhingra-google Apr 2, 2026
5d5b35d
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 2, 2026
ea9307d
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 3, 2026
9391180
updated validation block and corrected indentation
sumeetdhingra-google Apr 3, 2026
17cd410
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 3, 2026
223a00a
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 4, 2026
260f2bf
Fixed errors and tool definition
sumeetdhingra-google Apr 6, 2026
df6adaf
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 7, 2026
578e37b
Applied Suggested changes
sumeetdhingra-google Apr 7, 2026
18c48b7
added RunMySQLListTableStatsTest to cloud-sql-mysql
sumeetdhingra-google Apr 7, 2026
4a62f20
Merge branch 'googleapis:main' into main
sumeetdhingra-google Apr 7, 2026
4503986
added annotations
sumeetdhingra-google Apr 8, 2026
0130402
Merge branch 'main' into main
Yuan325 Apr 9, 2026
31ad5b1
Update imports.go
Yuan325 Apr 9, 2026
ae3fdde
moved advance usage to about in docs file
sumeetdhingra-google Apr 9, 2026
32d2934
Merge branch 'main' into main
sumeetdhingra-google Apr 9, 2026
ffece2c
Merge branch 'main' into main
sumeetdhingra-google Apr 9, 2026
178f364
changes to merge with new repo name mcp-toolbox
sumeetdhingra-google Apr 9, 2026
688ed1a
corrected db name in Cloud SQL MySQL Integration test
sumeetdhingra-google Apr 9, 2026
abf0b3e
Merge branch 'main' into main
sumeetdhingra-google Apr 9, 2026
600dd8c
minor changes in format
sumeetdhingra-google Apr 9, 2026
31913b6
Merge branch 'main' into main
sumeetdhingra-google Apr 9, 2026
543ebca
fixed integration test
sumeetdhingra-google Apr 9, 2026
0dd4d0c
fixed indentation
sumeetdhingra-google Apr 9, 2026
4a0939e
Merge branch 'main' into main
Yuan325 Apr 9, 2026
b27a38f
Merge branch 'main' into main
Yuan325 Apr 9, 2026
429a929
Merge branch 'main' into main
Yuan325 Apr 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/internal/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1763,7 +1763,7 @@ func TestPrebuiltTools(t *testing.T) {
},
"monitor": tools.ToolsetConfig{
Name: "monitor",
ToolNames: []string{"get_query_plan", "list_active_queries", "get_query_metrics", "get_system_metrics", "list_table_fragmentation", "list_tables_missing_unique_indexes"},
ToolNames: []string{"get_query_plan", "list_active_queries", "get_query_metrics", "get_system_metrics", "list_table_fragmentation", "list_tables_missing_unique_indexes", "list_table_stats"},
},
"lifecycle": tools.ToolsetConfig{
Name: "lifecycle",
Expand Down Expand Up @@ -1847,7 +1847,7 @@ func TestPrebuiltTools(t *testing.T) {
},
"monitor": tools.ToolsetConfig{
Name: "monitor",
ToolNames: []string{"get_query_plan", "list_active_queries", "list_table_fragmentation", "list_tables_missing_unique_indexes"},
ToolNames: []string{"get_query_plan", "list_active_queries", "list_table_fragmentation", "list_tables_missing_unique_indexes", "list_table_stats"},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions cmd/internal/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import (
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqllistactivequeries"
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqllisttablefragmentation"
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqllisttables"
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqllisttablestats"
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqllisttablesmissinguniqueindexes"
_ "github.com/googleapis/mcp-toolbox/internal/tools/mysql/mysqlsql"
_ "github.com/googleapis/mcp-toolbox/internal/tools/neo4j/neo4jcypher"
Expand Down
1 change: 1 addition & 0 deletions docs/CLOUDSQLMYSQL_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The Cloud SQL for MySQL MCP server provides the following tools:
| `list_tables` | Lists detailed schema information for user-created tables. |
| `list_tables_missing_unique_indexes` | Find tables that do not have primary or unique key constraint. |
| `list_table_fragmentation` | List table fragmentation in MySQL. |
| `list_table_stats` | List table statistics in MySQL. |

## Custom MCP Server Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ description: "Details of the Cloud SQL for MySQL prebuilt configuration."
* `list_tables_missing_unique_indexes`: Looks for tables that do not have
primary or unique key contraint.
* `list_table_fragmentation`: Displays table fragmentation in MySQL.
* `list_table_stats`: Displays table statistics in MySQL.
1 change: 1 addition & 0 deletions docs/en/integrations/mysql/prebuilt-configs/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ description: "Details of the MySQL prebuilt configuration."
* `list_tables_missing_unique_indexes`: Looks for tables that do not have
primary or unique key contraint.
* `list_table_fragmentation`: Displays table fragmentation in MySQL.
* `list_table_stats`: Displays table statistics in MySQL.
80 changes: 80 additions & 0 deletions docs/en/integrations/mysql/tools/mysql-list-table-stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: "mysql-list-table-stats"
type: docs
weight: 1
description: >
A "mysql-list-table-stats" tool report table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table.
---

## About

A `mysql-list-table-stats` tool generates table-level performance and resource consumption statistics to facilitate bottleneck identification and workload analysis.

`mysql-list-table-stats` outputs detailed table-level resource consumption including estimated row counts, table size, a complete breakdown of CRUD activity (rows fetched, inserted, updated, and deleted), and IO statistics such as total, read, write and miscellaneous latency. The output is a JSON formatted array of the top 10 MySQL tables ranked by total latency.

## Compatible Sources

{{< compatible-sources others="integrations/cloud-sql-mysql">}}

## Requirements

- `performance_schema` should be turned ON for this tool to work.

## Parameters

Comment thread
shuzhou-gc marked this conversation as resolved.
This tool takes 4 optional input parameters:

- `table_schema` (optional): The database where table stats check is to be
executed. Check all tables visible to the current database if not specified.
- `table_name` (optional): Name of the table to be checked. Check all tables
visible to the current user if not specified.
- `sort_by` (optional): The column to sort by. Valid values are `row_count`, `rows_fetched`, `rows_inserted`, `rows_updated`, `rows_deleted`, `total_latency_secs` (defaults to `total_latency_secs`)
Comment thread
shuzhou-gc marked this conversation as resolved.
- `limit` (optional): Max rows to return, default 10.

## Example

```yaml
kind: tools
name: list_table_stats
type: mysql-list-table-stats
source: my-mysql-instance
description: Display table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table. Specifying a database name or table name filters the output to that specific db or table. Results are limited to 10 by default.
```

## Output Format

The response is a json array with the following fields:
```json
[
{
"table_schema": "The schema/database this table belongs to",
"table_name": "Name of this table",
"size_MB": "Size of the table data in MB",
"row_count": "Number of rows in the table",
"total_latency_secs": "total latency in secs",
"rows_fetched": "total number of rows fetched",
"rows_inserted": "total number of rows inserted",
"rows_updated": "total number of rows updated",
"rows_deleted": "total number of rows deleted",
"io_reads": "total number of io read requests",
"io_read_latency": "io read latency in seconds",
"io_write_latency": "io write latency in seconds",
"io_misc_latency": "io misc latency in seconds",
}
]
```

## Reference

| **field** | **type** | **required** | **description** |
|-------------|:--------:|:------------:|----------------------------------------------------|
| type | string | true | Must be "mysql-list-table-stats". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | true | Description of the tool that is passed to the LLM. |


## Advance Usage
Comment thread
sumeetdhingra-google marked this conversation as resolved.
Outdated

- **Finding hottest tables**: Identify tables with highest total latency, read or writes based on the `sort_by` column.
- **Finding tables with most reads**: Identify tables with highest reads by sorting on `rows_fetched`.
- **Monitoring growth**: Track `row_count` and `size_MB` of table over time to estimate growth."
5 changes: 5 additions & 0 deletions internal/prebuiltconfigs/tools/cloud-sql-mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ tools:
kind: mysql-list-tables
source: cloud-sql-mysql-source
description: "Lists detailed schema information (object type, columns, constraints, indexes, triggers, comment) as JSON for user-created tables (ordinary or partitioned). Filters by a comma-separated list of names. If names are omitted, lists all tables in user schemas."
list_table_stats:
kind: mysql-list-table-stats
source: cloud-sql-mysql-source
description: "Display table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table. Specifying a database name or table name filters the output to that specific db or table. Results are limited to 10 by default."
list_tables_missing_unique_indexes:
kind: mysql-list-tables-missing-unique-indexes
source: cloud-sql-mysql-source
Expand Down Expand Up @@ -148,6 +152,7 @@ toolsets:
- get_query_metrics
- get_system_metrics
- list_table_fragmentation
- list_table_stats
Comment thread
shuzhou-gc marked this conversation as resolved.
- list_tables_missing_unique_indexes
lifecycle:
- create_backup
Expand Down
5 changes: 5 additions & 0 deletions internal/prebuiltconfigs/tools/mysql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ tools:
kind: mysql-list-tables
source: mysql-source
description: "Lists detailed schema information (object type, columns, constraints, indexes, triggers, comment) as JSON for user-created tables (ordinary or partitioned). Filters by a comma-separated list of names. If names are omitted, lists all tables in user schemas."
list_table_stats:
kind: mysql-list-table-stats
source: mysql-source
description: "Display table statistics including table size, total latency, rows read, rows written, read and write latency for entire instance, a specified database, or a specified table. Specifying a database name or table name filters the output to that specific db or table. Results are limited to 10 by default."
list_tables_missing_unique_indexes:
kind: mysql-list-tables-missing-unique-indexes
source: mysql-source
Expand All @@ -61,4 +65,5 @@ toolsets:
- get_query_plan
- list_active_queries
- list_table_fragmentation
- list_table_stats
- list_tables_missing_unique_indexes
4 changes: 4 additions & 0 deletions internal/sources/cloudsqlmysql/cloud_sql_mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ func (s *Source) MySQLPool() *sql.DB {
return s.Pool
}

func (s *Source) MySQLDatabase() string {
return s.Database
}

func (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {
results, err := s.MySQLPool().QueryContext(ctx, statement, params...)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions internal/sources/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func (s *Source) MySQLPool() *sql.DB {
return s.Pool
}

func (s *Source) MySQLDatabase() string {
return s.Database
}

func (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {
results, err := s.MySQLPool().QueryContext(ctx, statement, params...)
if err != nil {
Expand Down
Loading
Loading