Files
mcp-microsoft/tools/Azure.Mcp.Tools.Postgres
1fa503200a Mark MySQL/PostgreSQL database query as destructive and drop SQL verb blocklists (#3202)
* Fixed input validation issue in MySql and Postgres

* Added MySql validation test cases

* Fix Postgres SQL validator: tokenize string-stripped content and add regex timeout

- Tokenize withoutStrings instead of decodedForValidation to avoid false
  positives when dangerous keywords appear inside string literals
  (e.g., SELECT 'drop table' AS msg)
- Only strip U&'...' (string literals) not U&"..." (identifiers) per
  PostgreSQL spec, so obfuscated function names in identifiers are still
  caught by tokenization
- Add RegexHelper.DefaultRegexTimeout to DecodeUnicodeEscapes for
  consistency with other regex usage in the validator
- Fix whitespace formatting in SqlQueryValidatorTests.cs closing brace
- Move U&'...' test case to safe queries (string literals cannot invoke
  functions per PostgreSQL spec)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Marked MySql and Postgres query commands as destructive, not idempotent, and not read-only

* Block the uescape command in validator

* Remove SQL verb/keyword blocklists from MySQL and Postgres query validation

The MySQL and Postgres database query tools are now marked destructive, so
rejecting statements by SQL verb or dangerous-identifier blocklist is no longer
meaningful - the signed-in user's database permissions are the authority.

Validation is reduced to structural checks: empty input, max length, SQL
comments, and multiple/stacked statements. The Unicode/National-string
de-obfuscation logic (which only existed to feed the blocklists) is removed,
along with the unfinished UESCAPE check that did not compile.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Reword changelog entries to fix cspell failure

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Move MySQL/Postgres query tools to a destructive consolidated tool

The consolidated tool discovery strategy requires every mapped command's
ToolMetadata to match its consolidated tool exactly. Marking the query
commands destructive left them mismatched against the read-only
get_azure_databases_details tool, which made the server fail to start in
consolidated mode.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Test consolidated tool metadata mappings

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Vinay Gera <vigera@microsoft.com>
2026-09-11 15:27:05 -07:00
..
2026-08-14 18:11:33 -04:00