Skip to content

fix(mcp): align tools/list namespace with aliased services#165

Closed
abhinavkale-dev wants to merge 3 commits intogoogleworkspace:mainfrom
abhinavkale-dev:fix-mcp-alias-tools-mismatch
Closed

fix(mcp): align tools/list namespace with aliased services#165
abhinavkale-dev wants to merge 3 commits intogoogleworkspace:mainfrom
abhinavkale-dev:fix-mcp-alias-tools-mismatch

Conversation

@abhinavkale-dev
Copy link

Fixes #162.

Summary

When gws mcp is started with aliased services (for example -s events), tools/list previously returned Discovery-prefixed names (for example workspaceevents_*) while tools/call validated alias prefixes (for example events_*).
This made listed tools uncallable in the same MCP session.

This PR makes tools/list use the configured service alias prefix so tools/list and tools/call share the same namespace.

What changed

  • Updated src/mcp_server.rs:
    • build_tools_list now prefixes tool names with svc_name (configured alias) instead of doc.name.
  • Added regression tests in src/mcp_server.rs:
    • build_tools_list_uses_alias_prefixes_for_aliased_services
    • handle_tools_call_rejects_discovery_prefix_when_alias_is_enabled
  • Added changeset:
    • .changeset/fix-mcp-alias-tools-mismatch.md

Checklist:

  • My code follows the AGENTS.md guidelines (no generated google-* crates).
  • I have run cargo fmt --all to format the code perfectly.
  • I have run cargo clippy -- -D warnings and resolved all warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have provided a Changeset file (e.g. via pnpx changeset) to document my changes.

@changeset-bot
Copy link

changeset-bot bot commented Mar 5, 2026

🦋 Changeset detected

Latest commit: 569af9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical inconsistency in the gws mcp command's handling of aliased services. Previously, tools/list would present tool names using their original Discovery-prefixed names, while tools/call expected the configured alias prefix, rendering listed tools uncallable. The changes ensure that both commands operate within the same namespace by making tools/list use the service alias prefix, thereby unifying the tool naming convention and enabling aliased tools to function as expected.

Highlights

  • Tool Naming Consistency: The build_tools_list function now correctly uses the configured service alias (svc_name) instead of the Discovery document's default name (doc.name) when generating tool names, ensuring consistency with tools/call.
  • Regression Tests Added: New regression tests were introduced to verify that tools/list utilizes alias prefixes for aliased services and that tools/call properly rejects Discovery prefixes when an alias is active, preventing future regressions.
  • Changelog Entry: A new changeset file (.changeset/fix-mcp-alias-tools-mismatch.md) was added to document this fix for the MCP alias tool namespace mismatch.
Changelog
  • .changeset/fix-mcp-alias-tools-mismatch.md
    • Added a new changeset entry describing the fix for the MCP alias tool namespace mismatch.
  • src/mcp_server.rs
    • Modified the build_tools_list function to use the service alias name (svc_name) for tool prefixes instead of the Discovery document's name.
    • Introduced new test cases (build_tools_list_uses_alias_prefixes_for_aliased_services and handle_tools_call_rejects_discovery_prefix_when_alias_is_enabled) to validate the correct behavior of aliased services.
Activity
  • No specific activity (comments, reviews, progress updates) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
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 correctly aligns the tool names generated by tools/list with the aliases expected by tools/call, fixing a key usability issue in MCP sessions with aliased services. The change is simple and effective. The addition of regression tests is excellent, ensuring this issue does not reappear. I've left a couple of minor suggestions in the test code to remove unnecessary unsafe blocks for better code clarity and adherence to Rust's safety principles.

@jpoehnelt jpoehnelt added area: mcp cla: yes This human has signed the Contributor License Agreement. complexity: medium Moderate change, some review needed labels Mar 5, 2026
@codecov
Copy link

codecov bot commented Mar 5, 2026

Codecov Report

❌ Patch coverage is 99.02913% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 56.24%. Comparing base (f6d74b0) to head (569af9e).
⚠️ Report is 37 commits behind head on main.

Files with missing lines Patch % Lines
src/mcp_server.rs 99.02% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #165      +/-   ##
==========================================
+ Coverage   55.19%   56.24%   +1.05%     
==========================================
  Files          38       38              
  Lines       13166    13268     +102     
==========================================
+ Hits         7267     7463     +196     
+ Misses       5899     5805      -94     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jpoehnelt
Copy link
Member

conflicts needing to be resolved

@jpoehnelt
Copy link
Member

Closing in favor of #235 — we're switching to hyphen separators which fixes both the alias mismatch (#162) and the parsing ambiguity (#170) in one go. Thanks for the contribution!

@jpoehnelt jpoehnelt closed this Mar 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: mcp cla: yes This human has signed the Contributor License Agreement. complexity: medium Moderate change, some review needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP tools/list returns uncallable tool names for aliased services (events, apps-script, admin-reports)

2 participants