Skip to content

feat(mssql): add mssql-list-indexes tool#3508

Open
debabsah wants to merge 1 commit into
googleapis:mainfrom
debabsah:feat-mssql-list-indexes
Open

feat(mssql): add mssql-list-indexes tool#3508
debabsah wants to merge 1 commit into
googleapis:mainfrom
debabsah:feat-mssql-list-indexes

Conversation

@debabsah

Copy link
Copy Markdown

Description

Adds a read-only mssql-list-indexes prebuilt tool, the SQL Server counterpart to postgres-list-indexes. It is the first tool toward bringing the mssql source to parity with the Postgres read-only estate-exploration suite (agreed in #3496).

It lists user indexes, excluding system schemas and heaps, using only catalog views and sys.dm_db_index_usage_stats, and is marked read-only. It follows the existing Postgres tool and the internal/tools/mssql/ conventions (named sql.Named parameters, BaseTool). It filters by schema, table, and index name, takes an optional only-unused flag, and has a configurable row limit.

The PR adds the tool (internal/tools/mssql/mssqllistindexes/), its unit test, the registration in cmd/internal/imports.go, the docs page, and an integration test (RunMSSQLListIndexesTest) wired into TestMSSQLToolEndpoints.

A couple of small choices, both easy to change if you prefer:

  1. description is optional here (it defaults), following postgres-list-indexes, the tool this mirrors. I can make it required like mssql-list-tables if you want.
  2. The usage columns read from sys.dm_db_index_usage_stats, matching the Postgres tool. That DMV needs VIEW SERVER STATE, and the docs page calls that out.

PR Checklist

  • Make sure you reviewed CONTRIBUTING.md
  • Make sure to open an issue before writing the code (discussed and scope agreed in Required additional mssql tools #3496)
  • Ensure the tests and linter pass (gofmt, go vet, go build ./cmd/..., the unit test, and the new integration test all pass; the integration test was run against SQL Server 2022)
  • Code coverage does not decrease (adds a unit test and an integration test for the new tool)
  • Appropriate docs were updated (added docs/en/integrations/mssql/tools/mssql-list-indexes.md)
  • Make sure to add ! if this involves a breaking change (it does not)

Part of #3496

@debabsah debabsah requested a review from a team as a code owner June 23, 2026 17:44

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a new mssql-list-indexes tool to list user indexes in a SQL Server database, complete with implementation, unit and integration tests, and documentation. The feedback recommends adding a "Requirements" section to the documentation to detail the permissions needed (VIEW DATABASE STATE or VIEW SERVER STATE) to query index usage statistics, aligned with the repository's strict heading order style guide.

Comment thread docs/en/integrations/mssql/tools/mssql-list-indexes.md
@debabsah debabsah force-pushed the feat-mssql-list-indexes branch from a95aa3f to b278d58 Compare June 23, 2026 17:48
@debabsah debabsah force-pushed the feat-mssql-list-indexes branch from b278d58 to 8aff07a Compare June 23, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants