Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ import (
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslistactivequeries"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslistavailableextensions"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslistinstalledextensions"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslistschemas"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslisttables"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgreslistviews"
_ "github.com/googleapis/genai-toolbox/internal/tools/postgres/postgressql"
Expand Down
6 changes: 3 additions & 3 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,7 @@ func TestPrebuiltTools(t *testing.T) {
wantToolset: server.ToolsetConfigs{
"alloydb_postgres_database_tools": tools.ToolsetConfig{
Name: "alloydb_postgres_database_tools",
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views"},
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views", "list_schemas"},
},
},
},
Expand Down Expand Up @@ -1434,7 +1434,7 @@ func TestPrebuiltTools(t *testing.T) {
wantToolset: server.ToolsetConfigs{
"cloud_sql_postgres_database_tools": tools.ToolsetConfig{
Name: "cloud_sql_postgres_database_tools",
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views"},
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views", "list_schemas"},
},
},
},
Expand Down Expand Up @@ -1534,7 +1534,7 @@ func TestPrebuiltTools(t *testing.T) {
wantToolset: server.ToolsetConfigs{
"postgres_database_tools": tools.ToolsetConfig{
Name: "postgres_database_tools",
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views"},
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views", "list_schemas"},
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions docs/en/reference/prebuilt-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ details on how to connect your AI tools (IDEs) to databases via Toolbox and MCP.
* `get_query_plan`: Generate the execution plan of a statement.
* `list_views`: Lists views in the database from pg_views with a default
limit of 50 rows. Returns schemaname, viewname and the ownername.
* `list_schemas`: Lists schemas in the database.

## AlloyDB Postgres Admin

Expand Down Expand Up @@ -214,6 +215,7 @@ details on how to connect your AI tools (IDEs) to databases via Toolbox and MCP.
* `get_query_plan`: Generate the execution plan of a statement.
* `list_views`: Lists views in the database from pg_views with a default
limit of 50 rows. Returns schemaname, viewname and the ownername.
* `list_schemas`: Lists schemas in the database.

## Cloud SQL for PostgreSQL Observability

Expand Down Expand Up @@ -509,6 +511,7 @@ details on how to connect your AI tools (IDEs) to databases via Toolbox and MCP.
* `get_query_plan`: Generate the execution plan of a statement.
* `list_views`: Lists views in the database from pg_views with a default
limit of 50 rows. Returns schemaname, viewname and the ownername.
* `list_schemas`: Lists schemas in the database.

## Google Cloud Serverless for Apache Spark

Expand Down
3 changes: 3 additions & 0 deletions docs/en/resources/sources/alloydb-pg.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ cluster][alloydb-free-trial].
- [`postgres-list-views`](../tools/postgres/postgres-list-views.md)
List views in an AlloyDB for PostgreSQL database.

- [`postgres-list-schemas`](../tools/postgres/postgres-list-schemas.md)
List schemas in an AlloyDB for PostgreSQL database.

### Pre-built Configurations

- [AlloyDB using MCP](https://googleapis.github.io/genai-toolbox/how-to/connect-ide/alloydb_pg_mcp/)
Expand Down
3 changes: 3 additions & 0 deletions docs/en/resources/sources/cloud-sql-pg.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ to a database by following these instructions][csql-pg-quickstart].
- [`postgres-list-views`](../tools/postgres/postgres-list-views.md)
List views in a PostgreSQL database.

- [`postgres-list-schemas`](../tools/postgres/postgres-list-schemas.md)
List schemas in a PostgreSQL database.

### Pre-built Configurations

- [Cloud SQL for Postgres using
Expand Down
3 changes: 3 additions & 0 deletions docs/en/resources/sources/postgres.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ reputation for reliability, feature robustness, and performance.
- [`postgres-list-views`](../tools/postgres/postgres-list-views.md)
List views in a PostgreSQL database.

- [`postgres-list-schemas`](../tools/postgres/postgres-list-views.md)
List schemas in a PostgreSQL database.

### Pre-built Configurations

- [PostgreSQL using MCP](https://googleapis.github.io/genai-toolbox/how-to/connect-ide/postgres_mcp/)
Expand Down
55 changes: 55 additions & 0 deletions docs/en/resources/tools/postgres/postgres-list-schemas.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
title: "postgres-list-schemas"
type: docs
weight: 1
description: >
The "postgres-list-schemas" tool lists user-defined schemas in a database.
aliases:
- /resources/tools/postgres-list-schemas
---

## About

The `postgres-list-schemas` tool retrieves information about schemas in a database excluding system
and temporary schemas. It's compatible with any of the following sources:

- [alloydb-postgres](../../sources/alloydb-pg.md)
- [cloud-sql-postgres](../../sources/cloud-sql-pg.md)
- [postgres](../../sources/postgres.md)

`postgres-list-schemas` lists detailed information as JSON for each schema. The tool takes the following
input parameters:

- `schema_name` (optional): A pattern to filter schema names using SQL LIKE operator.
If omitted, all user-defined schemas are returned.

## Example

```yaml
tools:
list_schemas:
kind: postgres-list-schemas
source: postgres-source
description: "Lists all schemas in the database ordered by schema name and excluding system and temporary schemas. It returns the schema name, schema owner, grants, number of functions, number of tables and number of views within each schema."
```

The response is a json array with the following elements:

```json
{
"schema_name": "name of the schema.",
"owner": "role that owns the schema",
"grants": "A JSON object detailing the privileges (e.g., USAGE, CREATE) granted to different roles or PUBLIC on the schema.",
"tables": "The total count of tables within the schema",
"views": "The total count of views within the schema",
"functions": "The total count of functions",
}
```

## Reference

| **field** | **type** | **required** | **description** |
|-------------|:--------:|:------------:|----------------------------------------------------|
| kind | string | true | Must be "postgres-list-schemas". |
| source | string | true | Name of the source the SQL should execute on. |
| description | string | false | Description of the tool that is passed to the LLM. |
6 changes: 6 additions & 0 deletions internal/prebuiltconfigs/tools/alloydb-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ tools:
list_views:
kind: postgres-list-views
source: alloydb-pg-source

list_schemas:
kind: postgres-list-schemas
source: alloydb-pg-source
Comment thread
srividyareddy786 marked this conversation as resolved.

toolsets:
alloydb_postgres_database_tools:
- execute_sql
Expand All @@ -173,3 +178,4 @@ toolsets:
- list_invalid_indexes
- get_query_plan
- list_views
- list_schemas
5 changes: 5 additions & 0 deletions internal/prebuiltconfigs/tools/cloud-sql-postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ tools:
kind: postgres-list-views
source: cloudsql-pg-source

list_schemas:
kind: postgres-list-schemas
source: cloudsql-pg-source

toolsets:
cloud_sql_postgres_database_tools:
- execute_sql
Expand All @@ -173,3 +177,4 @@ toolsets:
- list_invalid_indexes
- get_query_plan
- list_views
- list_schemas
5 changes: 5 additions & 0 deletions internal/prebuiltconfigs/tools/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ tools:
kind: postgres-list-views
source: postgresql-source

list_schemas:
kind: postgres-list-schemas
source: postgresql-source

toolsets:
postgres_database_tools:
- execute_sql
Expand All @@ -172,3 +176,4 @@ toolsets:
- list_invalid_indexes
- get_query_plan
- list_views
- list_schemas
Loading
Loading