Skip to content

Conversation

@GautamSharda
Copy link

@GautamSharda GautamSharda commented Dec 9, 2025

This PR introduces a new mcp tool, research_gcloud_command to the gcloud-mcp extension. This tool allows clients to retrieve help documentation for specific gcloud commands.

The aim is to enhance the agent's ability to understand and provide information about gcloud commands by offering precise information about command usage, flags, and arguments.

Changes:

  1. Add definition of new tool in research_gcloud_command.ts under packages/gcloud-mcp/src/tools/ + associated test
  2. Integration of research_gcloud_command into the MCP server in packages/gcloud-mcp/src/index.ts

To run it, you could run npm run build, launch gemini cli, and prompt it to use the tool. Or create an MCP client.

@GautamSharda GautamSharda requested a review from a team as a code owner December 9, 2025 21:25
@GautamSharda GautamSharda changed the title feat: add research_gcloud_command feat: add research_gcloud_command mcp tool Dec 9, 2025
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.40%. Comparing base (a679273) to head (fa16372).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
+ Coverage   94.23%   94.40%   +0.17%     
==========================================
  Files          50       51       +1     
  Lines        3779     3894     +115     
  Branches      498      512      +14     
==========================================
+ Hits         3561     3676     +115     
  Misses        218      218              

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 84 to 91
Please provide relevant context for the gcloud command and flags:
${args.join(' ')}.

Output of gcloud ${args.join(' ')} --document=style=markdown:
${helpStdout}

Output of gcloud help --format="markdown(global_flags)" | grep -A10 "GLOBAL FLAGS" | tail -n +2 | head -n 10:
${globalFlagsOutput}
Copy link
Member

Choose a reason for hiding this comment

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

Let's iterate a bit on the tool description, output formats, and error conditions. I'll create a tab in our doc.

…e overall orchestration design: describe arguments / command parts, update tool description to emphasize it's a pre-requisite, standardize tool output to json, handle output on error
Comment on lines +27 to +28
title: 'Research gcloud command',
inputSchema: {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
title: 'Research gcloud command',
inputSchema: {
title: 'Research gcloud command',
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
inputSchema: {

The readOnlyHint is my primary recommendation here. Unsure if the others are necessary, but I don't think they hurt. See also https://modelcontextprotocol.io/legacy/concepts/tools#available-tool-annotations

import { z } from 'zod';
import { log } from '../utility/logger.js';

export const createResearchGcloudCommand = () => ({
Copy link
Member

Choose a reason for hiding this comment

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

When testing, there are still ANSI escape codes in the content that make the output pretty noisy.

Comment on lines +97 to +100
// grep -A10 "GLOBAL FLAGS" includes the match and 10 lines after.
// tail -n +2 skips the first line (the match).
// head -n 10 takes the next 10 lines.
// So we want lines from globalFlagsIndex + 1 to globalFlagsIndex + 1 + 10 (exclusive)
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure whether this produces the best outcome -- it has the potential of truncating a global flag description in the middle, and arbitrarily removing the flags after the 10th line.

Should we simply remove them from the output if filtering is improving quality?

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