@google-cloud/cloud-run-mcp 1.3.0 → 1.6.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.
Files changed (44) hide show
  1. package/.c8rc.json +9 -0
  2. package/.github/images/deploy_from_apps.gif +0 -0
  3. package/.github/images/deploy_from_ide.gif +0 -0
  4. package/.github/images/deploycli.gif +0 -0
  5. package/.github/workflows/lint-checker.yml +17 -0
  6. package/.github/workflows/local-tests.yml +1 -1
  7. package/.kokoro/kokoro_build.sh +22 -0
  8. package/.kokoro/presubmit.cfg +21 -0
  9. package/.kokoro/run_tests.sh +31 -0
  10. package/CONTRIBUTING.md +29 -8
  11. package/README.md +65 -19
  12. package/REVIEWING.md +20 -0
  13. package/gemini-extension/GEMINI.md +3 -3
  14. package/lib/cloud-api/build.js +200 -0
  15. package/lib/{gcp-api-helpers.js → cloud-api/helpers.js} +12 -8
  16. package/lib/{gcp-projects.js → cloud-api/projects.js} +58 -28
  17. package/lib/cloud-api/registry.js +98 -0
  18. package/lib/{cloud-run-services.js → cloud-api/run.js} +103 -21
  19. package/lib/cloud-api/storage.js +123 -0
  20. package/lib/deployment/deployer.js +474 -0
  21. package/lib/util/archive.js +95 -0
  22. package/lib/util/helpers.js +42 -0
  23. package/mcp-server.js +29 -11
  24. package/package.json +9 -6
  25. package/test/local/cloud-api/build.test.js +436 -0
  26. package/test/local/cloud-api/projects.test.js +18 -0
  27. package/test/local/mcp-server-streamable-http.test.js +57 -0
  28. package/test/local/mcp-server.test.js +0 -1
  29. package/test/local/notifications.test.js +48 -0
  30. package/test/local/tools.test.js +143 -124
  31. package/test/need-gcp/cloud-run-services.test.js +57 -77
  32. package/test/need-gcp/deployer.test.js +71 -0
  33. package/test/need-gcp/gcp-auth-check.test.js +1 -1
  34. package/test/need-gcp/gcp-projects.test.js +6 -60
  35. package/test/need-gcp/test-helpers.js +175 -0
  36. package/test/need-gcp/workflows/deployment-workflows.test.js +100 -0
  37. package/tools/register-tools.js +612 -0
  38. package/tools/tools.js +48 -0
  39. package/lib/cloud-run-deploy.js +0 -917
  40. package/test/need-gcp/cloud-run-deploy.test.js +0 -158
  41. package/tools.js +0 -969
  42. /package/lib/{gcp-auth-check.js → cloud-api/auth.js} +0 -0
  43. /package/lib/{gcp-billing-accounts.js → cloud-api/billing.js} +0 -0
  44. /package/lib/{gcp-metadata.js → cloud-api/metadata.js} +0 -0
@@ -1,158 +0,0 @@
1
- /*
2
- Copyright 2025 Google LLC
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- https://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- import { deploy, deployImage } from '../../lib/cloud-run-deploy.js';
18
- import readline from 'readline/promises';
19
- import { stdin as input, stdout as output } from 'process';
20
- import fs from 'fs/promises';
21
- import path from 'path';
22
-
23
- /**
24
- * Gets the project ID from command line arguments or prompts the user.
25
- * If "new" is provided, it returns undefined to trigger new project creation.
26
- * @returns {Promise<string|undefined>} The Google Cloud project ID or undefined.
27
- */
28
- async function getProjectId() {
29
- let projectIdInput = process.argv[2]; // Get the third element (index 2) which is the first argument
30
-
31
- if (!projectIdInput) {
32
- const rl = readline.createInterface({ input, output });
33
- projectIdInput = await rl.question(
34
- 'Please enter your Google Cloud project ID: '
35
- );
36
- rl.close();
37
- }
38
-
39
- if (!projectIdInput || projectIdInput.trim() === '') {
40
- console.error('No project ID provided. Exiting.');
41
- process.exit(1);
42
- }
43
- if (projectIdInput.toLowerCase() === 'new') {
44
- console.error(
45
- 'Project creation ("new") is now handled by test-create-project.js. Please provide an existing project ID. Exiting.'
46
- );
47
- process.exit(1);
48
- }
49
- console.log(`Using Project ID: ${projectIdInput}`);
50
- return projectIdInput;
51
- }
52
-
53
- const projectIdToUse = await getProjectId();
54
-
55
- // Configuration for Go deployment with Dockerfile
56
- const configGoWithDockerfile = {
57
- projectId: projectIdToUse, // Use the obtained project ID
58
- serviceName: 'example-go-app-docker', // Name of the Cloud Run service
59
- region: 'europe-west1', // Google Cloud region
60
- files: [
61
- 'example-sources-to-deploy/main.go',
62
- 'example-sources-to-deploy/go.mod',
63
- 'example-sources-to-deploy/Dockerfile',
64
- ],
65
- };
66
-
67
- // Configuration for Go deployment without Dockerfile (using buildpacks)
68
- const configGoWithoutDockerfile = {
69
- projectId: projectIdToUse,
70
- serviceName: 'example-go-app-buildpack',
71
- region: 'europe-west1',
72
- files: [
73
- 'example-sources-to-deploy/main.go',
74
- 'example-sources-to-deploy/go.mod',
75
- // Dockerfile is intentionally omitted here
76
- ],
77
- };
78
-
79
- // Configuration for Go deployment with file content (using buildpacks)
80
- const configGoWithContent = {
81
- projectId: projectIdToUse,
82
- serviceName: 'example-go-app-content',
83
- region: 'europe-west1',
84
- files: [], // To be populated with file content
85
- };
86
-
87
- // Configuration for a deployment that is expected to fail
88
- const configFailingBuild = {
89
- projectId: projectIdToUse,
90
- serviceName: 'example-failing-app',
91
- region: 'europe-west1',
92
- files: [
93
- {
94
- filename: 'main.txt',
95
- content:
96
- 'This is not a valid application source file and should cause a build failure.',
97
- },
98
- ],
99
- };
100
-
101
- // Configuration for deploying a container image
102
- const configImageDeploy = {
103
- projectId: projectIdToUse,
104
- serviceName: 'hello-from-image',
105
- region: 'europe-west1',
106
- imageUrl: 'gcr.io/cloudrun/hello',
107
- };
108
-
109
- try {
110
- console.log('\n--- Testing container image deployment ---');
111
- await deployImage(configImageDeploy);
112
- console.log('--- Container image deployment test completed ---');
113
-
114
- console.log('\n--- Testing intentionally failing build ---');
115
- try {
116
- await deploy(configFailingBuild);
117
- // If deploy doesn't throw an error, then the test has failed because it was expected to fail.
118
- console.error(
119
- 'Deployment test failed: The build with invalid files succeeded when it was expected to fail.'
120
- );
121
- process.exit(1);
122
- } catch (error) {
123
- console.log('Intentionally failing build test completed as expected.');
124
- }
125
-
126
- console.log('--- Testing Go deployment with Dockerfile ---');
127
- await deploy(configGoWithDockerfile);
128
- console.log('--- Go deployment with Dockerfile test completed ---');
129
-
130
- console.log(
131
- '\n--- Testing Go deployment without Dockerfile (Buildpacks) ---'
132
- );
133
- await deploy(configGoWithoutDockerfile);
134
- console.log(
135
- '--- Go deployment without Dockerfile (Buildpacks) test completed ---'
136
- );
137
-
138
- console.log('\n--- Testing Go deployment with file content (Buildpacks) ---');
139
- const mainGoContent = await fs.readFile(
140
- path.resolve('example-sources-to-deploy/main.go'),
141
- 'utf-8'
142
- );
143
- const goModContent = await fs.readFile(
144
- path.resolve('example-sources-to-deploy/go.mod'),
145
- 'utf-8'
146
- );
147
- configGoWithContent.files = [
148
- { filename: 'main.go', content: mainGoContent },
149
- { filename: 'go.mod', content: goModContent },
150
- ];
151
- await deploy(configGoWithContent);
152
- console.log(
153
- '--- Go deployment with file content (Buildpacks) test completed ---'
154
- );
155
- } catch (error) {
156
- console.error('An unexpected error occurred in the test script:', error);
157
- process.exit(1);
158
- }