Skip to content

test(source/cloud-sql-mysql): create MCP integration tests#2922

Draft
dishaprakash wants to merge 10 commits intoanubhav-feat-native-mcp-alloydbfrom
mcp-cloud-sql-mysql-tests
Draft

test(source/cloud-sql-mysql): create MCP integration tests#2922
dishaprakash wants to merge 10 commits intoanubhav-feat-native-mcp-alloydbfrom
mcp-cloud-sql-mysql-tests

Conversation

@dishaprakash
Copy link
Copy Markdown
Contributor

@dishaprakash dishaprakash commented Apr 1, 2026

Description

This PR migrates the Cloud SQL MySQL integration tests to use the /mcp endpoint on the MCP Toolbox Server.

Key Changes

  • tests/mcp_tool.go:

    • Added modular builder functions (Base, ExecuteSQL, TemplateParams) to dynamically generate expected MCP manifests.
    • Added concatenation of individual MCP text blocks into a fully formatted JSON array whenever the test expects one, preserving compatibility with previous test assertions.
  • cloud_sql_mysql_mcp_test.go: Migrated legacy /api tests to /mcp. Added negative parameter validation.

  • cloud_sql_mysql_create_instance_mcp_test.go: Migrated create-instance tests to validate MCP JSON-RPC handling.

  • tests/source.go: Added a WithMCP() option to RunSourceConnectionTest to verify database connections natively during MCP server init.

  • tests/tool.go: Introduced ToolExecOption and the WithMCPExec() functional option to the prebuilt tool test harnesses. This enables the reuse of complex test cases, data structs, and assertions across both legacy /api and new /mcp endpoints by toggling the request routing and response parsing logic.

PR Checklist

Thank you for opening a Pull Request! Before submitting your PR, there are a
few things you can do to make sure it goes smoothly:

  • Make sure you reviewed
    CONTRIBUTING.md
  • Make sure to open an issue as a
    bug/issue
    before writing your code! That way we can discuss the change, evaluate
    designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involve a breaking change

🛠️ Fixes #<issue_number_goes_here>

@dishaprakash dishaprakash changed the base branch from main to anubhav-feat-native-mcp-alloydb April 1, 2026 16:59
Copy link
Copy Markdown
Contributor

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

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 introduces comprehensive integration tests for the Model Context Protocol (MCP) across various data sources, including AlloyDB, Cloud SQL MySQL, and HTTP. It also adds modular helper functions in tests/mcp_tool.go to facilitate standardized MCP tool testing. Several issues were identified in the review: a critical flaw in the Cloud SQL MySQL instance creation test where mocking http.DefaultClient fails to affect the separate toolbox process, and multiple violations of the repository style guide regarding tool naming conventions (snake_case and product name exclusion). Additionally, the use of time.Sleep in MySQL tests was flagged as a potential source of flakiness, and some error assertions were noted as being too weak.

@dishaprakash dishaprakash force-pushed the mcp-cloud-sql-mysql-tests branch from db1827c to 7c651a9 Compare April 1, 2026 17:00
@anubhav756 anubhav756 force-pushed the anubhav-feat-native-mcp-alloydb branch from 69bb59b to d81edf8 Compare April 1, 2026 17:03
@dishaprakash dishaprakash changed the title Mcp cloud sql mysql tests test(source/cloud-sql-mysql): create MCP integration tests Apr 1, 2026
@dishaprakash dishaprakash force-pushed the mcp-cloud-sql-mysql-tests branch from 94d7fce to e3fa5a6 Compare April 1, 2026 21:32
@anubhav756 anubhav756 force-pushed the anubhav-feat-native-mcp-alloydb branch from d81edf8 to 4c21e3f Compare April 2, 2026 10:00
@dishaprakash dishaprakash force-pushed the mcp-cloud-sql-mysql-tests branch from 0019b41 to 0a48e1c Compare April 2, 2026 12:38
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.

1 participant