Visitar URL original
test(source/cassandra): add MCP integration tests by arijitbakshi15-stack · Pull Request #4194 · googleapis/mcp-toolbox · GitHub
Skip to content

test(source/cassandra): add MCP integration tests - #4194

Open
arijitbakshi15-stack wants to merge 2 commits into
googleapis:mainfrom
arijitbakshi15-stack:chore/cassandra-mcp-migration
Open

arijitbakshi15-stack wants to merge 2 commits into
googleapis:mainfrom
arijitbakshi15-stack:chore/cassandra-mcp-migration

Conversation

@arijitbakshi15-stack

Copy link
Copy Markdown

Description

Adds Cassandra integration tests for the /mcp endpoint in a new file, following the convention in #2922. Part of #3706.

  • tests/cassandra/cassandra_mcp_test.go adds TestCassandraMCPListTools and TestCassandraMCPCallTool. Both start the Toolbox server without --enable-api.
  • TestCassandraMCPListTools verifies the complete tools/list manifest, built from GetBaseMCPExpectedTools() and GetTemplateParamMCPExpectedTools() (15 tools). Cassandra registers no execute-sql tool, so unlike the other sources in this series its manifest does not include GetExecuteSQLMCPExpectedTools().
  • TestCassandraMCPCallTool reuses the existing helpers with the options method, so the same cases run over both endpoints: RunToolInvokeTest with WithMCP(), RunToolInvokeWithTemplateParameters with WithMCPTemplate(), and RunMCPToolCallMethod, which already ran over /mcp.
  • Both tests share a setupCassandraMCPServer helper that opens the session, creates the three test tables and starts the server, reusing the existing package-local helpers (initCassandraSession, initTable, dropTable, createParamToolInfo, getCassandraAuthToolInfo, getCassandraTmplToolInfo, getCassandraWants, getCassandraTmplWants).

The legacy /api test file is unchanged, so tests/cassandra/cassandra_integration_test.go keeps --enable-api until the cleanup phase of #3706.

Cassandra specifics carried over

All of the legacy option overrides are carried over verbatim rather than normalized:

  • DisableSelect1Test(), DisableSelect1AuthTest() and DisableMcpSelect1AuthTest(), since CQL has no SELECT 1. RunToolInvokeTest is therefore called with an empty select1Want.
  • DisableOptionalNullParamTest(), and the row expectations WithMyToolId3NameAliceWant, WithMyToolById4Want (Cassandra returns an empty string rather than NULL) and WithMyArrayToolWant.
  • On the template parameter tests: DisableSelectFilterTest(), DisableDdlTest(), DisableInsertTest(), plus WithSelectAllWant, WithTmplSelectId1Want and WithTmplSelectNameWant. The DDL and insert tools are still registered by AddTemplateParamConfig, so they remain part of the asserted manifest even though they are not invoked.

Teardown

The review findings from earlier PRs in this series are applied from the start:

Cleanups run LIFO, so the effective order is: stop the server, drop the three tables, then close the session.

Review guidelines from #4046

  1. New file for the /mcp tests, per test(source/cloud-sql-mysql): create MCP integration tests #2922 — the legacy file is untouched.
  2. Test<>ListTools and Test<>CallTool — matching the rest of the series.
  3. Options method, so no case is exercised on one endpoint only — every helper the legacy file runs is re-run here with its MCP option. The only one not repeated is RunToolGetTest, which targets the /api-only tool-get endpoint. Cassandra has no source-specific invoke helpers, so tests/ is unchanged by this PR.
  4. Shared expected-tool helpers — used for the whole manifest.

Validation

  • cassandra-cql builds its manifest through the shared parameters.ProcessParameters, so the tools/list entries match the shared expected-tool helpers.
  • The manifest count excludes my-secure-tool, which tools/list filters out under the protocol version the harness negotiates.
  • gofmt, go vet ./tests/cassandra/ and golangci-lint run ./tests/cassandra/... are clean.
  • No .ci/integration.cloudbuild.yaml change is needed: the cassandra shard runs the compiled package binary, so the new file is picked up automatically.

Not yet verified

The Cassandra source connects to the cluster at startup and I have no Cassandra cluster locally, so the new tests have not run. The auth cases additionally need a Google ID token. They need a maintainer CI run.

PR Checklist

  • Make sure to open an issue as a bug/issue before writing your code!
  • Ensure you have manually reviewed the entire diff before requesting a review
  • Ensure the tests and linter pass (linter passes; integration tests need CI)
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)
  • Make sure to add ! if this involves a breaking change

Part of #3706 🦕

@arijitbakshi15-stack
arijitbakshi15-stack requested a review from a team as a code owner September 30, 2026 15:40
@google-cla

google-cla Bot commented Sep 30, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@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 introduces integration tests for Cassandra MCP tools in tests/cassandra/cassandra_mcp_test.go, covering tool listing and invocation. Feedback on the changes highlights that the generated table name tableNameTemplateParam exceeds Cassandra's 48-character limit due to its long prefix and UUID, and suggests shortening the prefix to avoid table creation failures.

Comment thread tests/cassandra/cassandra_mcp_test.go Outdated

paramTableName := "param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
tableNameAuth := "auth_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
tableNameTemplateParam := "template_param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")

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.

high

In Cassandra, table names have a maximum length limit of 48 characters. The current table name tableNameTemplateParam is constructed as "template_param_table_" (21 chars) plus a 32-character UUID, resulting in a 53-character string. This will cause table creation to fail on a real Cassandra instance.

Consider shortening the prefix to "tmpl_param_" (11 characters) to keep the total length at 43 characters, which is safely within the 48-character limit.

Suggested change
tableNameTemplateParam := "template_param_table_" + strings.ReplaceAll(uuid.New().String(), "-", "")
tableNameTemplateParam := "tmpl_param_" + strings.ReplaceAll(uuid.New().String(), "-", "")

@AlexTalreja

Copy link
Copy Markdown
Contributor

/gcbrun

Add Cassandra integration tests for the /mcp endpoint in a new file,
following the convention in googleapis#2922.

- tests/cassandra/cassandra_mcp_test.go adds TestCassandraMCPListTools
  and TestCassandraMCPCallTool, which start the server without
  --enable-api.
- List tools verifies the full tools/list manifest using
  GetBaseMCPExpectedTools and GetTemplateParamMCPExpectedTools.
  Cassandra registers no execute-sql tool, so the execute-sql entries
  are not part of its manifest.
- Call tool reuses the existing helpers with WithMCP() and
  WithMCPTemplate(), so the same cases run over both endpoints. The
  Cassandra-specific options are carried over unchanged, including the
  disabled select-1 cases, since CQL has no SELECT 1.
- Teardown is registered with t.Cleanup so nothing leaks when setup
  fails partway through, and the session is closed last.

The legacy /api test file is unchanged.

Part of googleapis#3706
@anubhav756
anubhav756 force-pushed the chore/cassandra-mcp-migration branch from d9a7b9b to 4672f4f Compare October 4, 2026 10:00
@anubhav756

Copy link
Copy Markdown
Contributor

/gcbrun

Cassandra limits table names to 48 characters. The legacy prefix
"template_param_table_" (21 chars) plus a 32-character UUID is 53
characters, so use a shorter prefix for the template parameter table.

The cassandra shard passed with the longer name, so this is defensive
rather than a fix for an observed failure.

Part of googleapis#3706

This branch has not been deployed

No deployments
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.

4 participants