-
Notifications
You must be signed in to change notification settings - Fork 51
feat: add research_gcloud_command mcp tool #322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
| 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} |
There was a problem hiding this comment.
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
| title: 'Research gcloud command', | ||
| inputSchema: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 = () => ({ |
There was a problem hiding this comment.
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.
| // 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) |
There was a problem hiding this comment.
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?
This PR introduces a new mcp tool,
research_gcloud_commandto 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:
research_gcloud_command.tsunderpackages/gcloud-mcp/src/tools/+ associated testresearch_gcloud_commandinto the MCP server inpackages/gcloud-mcp/src/index.tsTo run it, you could run
npm run build, launch gemini cli, and prompt it to use the tool. Or create an MCP client.