gcloud-mcp 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gcloud-mcp-1.1.0.tgz +0 -0
- package/index.js +50 -0
- package/package.json +30 -0
- package/test.js +138 -0
|
Binary file
|
package/index.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { exec } = require('child_process');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Launch the system calculator based on the operating system
|
|
8
|
+
*/
|
|
9
|
+
function launchCalculator() {
|
|
10
|
+
const platform = os.platform();
|
|
11
|
+
let command;
|
|
12
|
+
|
|
13
|
+
switch (platform) {
|
|
14
|
+
case 'win32': // Windows
|
|
15
|
+
command = 'calc.exe';
|
|
16
|
+
break;
|
|
17
|
+
|
|
18
|
+
case 'darwin': // macOS
|
|
19
|
+
command = 'open -a Calculator';
|
|
20
|
+
break;
|
|
21
|
+
|
|
22
|
+
case 'linux': // Linux
|
|
23
|
+
// Try common calculator applications in order of preference
|
|
24
|
+
command = 'gnome-calculator || kcalc || xcalc || galculator';
|
|
25
|
+
break;
|
|
26
|
+
|
|
27
|
+
default:
|
|
28
|
+
console.error(`❌ Unsupported operating system: ${platform}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log(`🧮 Launching calculator on ${platform}...`);
|
|
33
|
+
|
|
34
|
+
exec(command, (error, stdout, stderr) => {
|
|
35
|
+
if (error) {
|
|
36
|
+
console.error(`❌ Error launching calculator: ${error.message}`);
|
|
37
|
+
console.error('Make sure a calculator application is installed on your system.');
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (stderr) {
|
|
42
|
+
console.error(`⚠️ Warning: ${stderr}`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log('✅ Calculator launched successfully!');
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Run the function
|
|
50
|
+
launchCalculator();
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "gcloud-mcp",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Launch system calculator on Windows, Linux, and macOS",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"calculator-launcher": "./index.js",
|
|
8
|
+
"calc-launch": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "node index.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"calculator",
|
|
15
|
+
"launcher",
|
|
16
|
+
"cross-platform",
|
|
17
|
+
"system",
|
|
18
|
+
"calc"
|
|
19
|
+
],
|
|
20
|
+
"author": "Your Name",
|
|
21
|
+
"license": "MIT",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=12.0.0"
|
|
24
|
+
},
|
|
25
|
+
"os": [
|
|
26
|
+
"win32",
|
|
27
|
+
"darwin",
|
|
28
|
+
"linux"
|
|
29
|
+
]
|
|
30
|
+
}
|
package/test.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Standalone Script to Initialize Gemini CLI Extension
|
|
5
|
+
* Replicates the observability-mcp initialization logic
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { mkdir, writeFile } = require('fs').promises;
|
|
9
|
+
const { join } = require('path');
|
|
10
|
+
const os = require('os');
|
|
11
|
+
|
|
12
|
+
const geminiMd = `
|
|
13
|
+
# Cloud Observability MCP Extension for Gemini CLI
|
|
14
|
+
|
|
15
|
+
You are a GCP agent that helps Google Cloud users find, manage, troubleshoot and optimize their Google Cloud resources.
|
|
16
|
+
|
|
17
|
+
Cloud Observability MCP provides a set of tools to list Google Cloud Observability resources. You can use these commands to perform many common platform tasks.
|
|
18
|
+
|
|
19
|
+
For example, you can use the Cloud Observability APIs to obtain following:
|
|
20
|
+
|
|
21
|
+
- Log Entries for a given project via Cloud Logging
|
|
22
|
+
- Alert Policies via Cloud Monitoring
|
|
23
|
+
- Metrics via Cloud Monitoring
|
|
24
|
+
- Traces via Cloud Trace
|
|
25
|
+
- Error Reporting Groups via Cloud Error Reporting
|
|
26
|
+
|
|
27
|
+
## Guiding Principles
|
|
28
|
+
|
|
29
|
+
- **Prefer Specific, Native Tools**: Always prefer to use the most specific tool available. This ensures better-structured data and more reliable execution.
|
|
30
|
+
- **Prefer Native Tools:** Prefer to use the dedicated tools provided by this extension instead of a generic tool for the same functionality.
|
|
31
|
+
- **Clarify Ambiguity:** Do not guess or assume values for required parameters like cluster names or locations. If the user's request is ambiguous, ask clarifying questions to confirm the exact resource they intend to interact with.
|
|
32
|
+
- **Use Defaults:** If a \`project_id\` is not specified by the user, you can use the default value configured in the environment if present.
|
|
33
|
+
|
|
34
|
+
## Cloud Observability Reference Documentation
|
|
35
|
+
|
|
36
|
+
If additional context or information is needed on a Cloud Observability API, reference documentation can be found at https://cloud.google.com/docs/observability.
|
|
37
|
+
|
|
38
|
+
- Logging: https://cloud.google.com/logging/docs/reference/v2/rest
|
|
39
|
+
- For example, documentation on \`list_log_entries\` can be found at https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
|
|
40
|
+
- Monitoring: https://cloud.google.com/monitoring/api/v3
|
|
41
|
+
- For example, documentation on \`list_time_series\` can be found at https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list
|
|
42
|
+
- Trace: https://cloud.google.com/trace/docs/reference/v1/rest
|
|
43
|
+
- For example, documentation on \`list_traces\` can be found at https://cloud.google.com/trace/docs/reference/v1/rest/v1/projects.traces/list
|
|
44
|
+
- Error Reporting: https://cloud.google.com/error-reporting/reference/rest
|
|
45
|
+
- For example, documentation on \`list_group_stats\` can be found at https://cloud.google.com/error-reporting/reference/rest/v1beta1/projects.groupStats/list
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Initialize Gemini CLI Extension
|
|
50
|
+
* @param {boolean} local - If true, uses 'observability-mcp', if false uses '@google-cloud/observability-mcp'
|
|
51
|
+
*/
|
|
52
|
+
async function initializeGeminiCLI(local = false) {
|
|
53
|
+
try {
|
|
54
|
+
// Create directory
|
|
55
|
+
const extensionDir = join(os.homedir(), '.gemini', 'extensions', 'observability-mcp');
|
|
56
|
+
await mkdir(extensionDir, { recursive: true });
|
|
57
|
+
|
|
58
|
+
// Create gemini-extension.json
|
|
59
|
+
const extensionFile = join(extensionDir, 'gemini-extension.json');
|
|
60
|
+
const extensionJson = {
|
|
61
|
+
name: 'observability-mcp' + (local ? '-local' : ''),
|
|
62
|
+
version: '1.0.0', // Hardcoded version since we don't have package.json
|
|
63
|
+
description: 'Enable MCP-compatible AI agents to interact with Google Cloud Observability.',
|
|
64
|
+
contextFileName: 'GEMINI.md',
|
|
65
|
+
mcpServers: {
|
|
66
|
+
observability: {
|
|
67
|
+
command: 'npx',
|
|
68
|
+
args: local ? ['-y', 'observability-mcp'] : ['-y', '@google-cloud/observability-mcp'],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
await writeFile(extensionFile, JSON.stringify(extensionJson, null, 2));
|
|
74
|
+
console.log(`Created: ${extensionFile}`);
|
|
75
|
+
|
|
76
|
+
// Create GEMINI.md
|
|
77
|
+
const geminiMdDestPath = join(extensionDir, 'GEMINI.md');
|
|
78
|
+
await writeFile(geminiMdDestPath, geminiMd);
|
|
79
|
+
console.log(`Created: ${geminiMdDestPath}`);
|
|
80
|
+
|
|
81
|
+
console.log(`🌱 observability-mcp Gemini CLI extension initialized.`);
|
|
82
|
+
console.log(`\nConfiguration:`);
|
|
83
|
+
console.log(` Mode: ${local ? 'LOCAL' : 'PRODUCTION'}`);
|
|
84
|
+
console.log(` Package: ${local ? 'observability-mcp' : '@google-cloud/observability-mcp'}`);
|
|
85
|
+
console.log(` Extension directory: ${extensionDir}`);
|
|
86
|
+
} catch (err) {
|
|
87
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
88
|
+
console.error('❌ observability-mcp Gemini CLI extension initialization failed.', error);
|
|
89
|
+
process.exit(1);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Parse command line arguments
|
|
94
|
+
function parseArgs() {
|
|
95
|
+
const args = process.argv.slice(2);
|
|
96
|
+
|
|
97
|
+
// Check for help flag
|
|
98
|
+
if (args.includes('--help') || args.includes('-h')) {
|
|
99
|
+
console.log(`
|
|
100
|
+
Gemini CLI Extension Initializer
|
|
101
|
+
|
|
102
|
+
Usage:
|
|
103
|
+
node init-gemini-extension.js [options]
|
|
104
|
+
|
|
105
|
+
Options:
|
|
106
|
+
--local, -l Use local package 'observability-mcp' (default: false)
|
|
107
|
+
--production, -p Use production package '@google-cloud/observability-mcp' (default)
|
|
108
|
+
--help, -h Show this help message
|
|
109
|
+
|
|
110
|
+
Examples:
|
|
111
|
+
# Initialize with production package
|
|
112
|
+
node init-gemini-extension.js
|
|
113
|
+
|
|
114
|
+
# Initialize with local package
|
|
115
|
+
node init-gemini-extension.js --local
|
|
116
|
+
|
|
117
|
+
Description:
|
|
118
|
+
This script creates a Gemini CLI extension configuration in:
|
|
119
|
+
~/.gemini/extensions/observability-mcp/
|
|
120
|
+
|
|
121
|
+
It generates:
|
|
122
|
+
- gemini-extension.json: Extension configuration
|
|
123
|
+
- GEMINI.md: Extension documentation
|
|
124
|
+
`);
|
|
125
|
+
process.exit(0);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Determine if local mode
|
|
129
|
+
const local = args.includes('--local') || args.includes('-l');
|
|
130
|
+
|
|
131
|
+
return { local };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Main execution
|
|
135
|
+
(async () => {
|
|
136
|
+
const { local } = parseArgs();
|
|
137
|
+
await initializeGeminiCLI(local);
|
|
138
|
+
})();
|