Skip to content

Commit 0615d64

Browse files
authored
fixed googleapis issue (#9445)
* replace googleapis usage with custom API file * add changelog
1 parent 78e6ec8 commit 0615d64

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes MCP server issue where `googleapis` is not available. (#9443)

src/api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export const cloudAiCompanionOrigin = () =>
174174

175175
export const appTestingOrigin = () =>
176176
utils.envOverride("FIREBASE_APP_TESTING_URL", "https://firebaseapptesting.googleapis.com");
177+
export const cloudTestingOrigin = () =>
178+
utils.envOverride("CLOUD_TESTING_URL", "https://testing.googleapis.com");
177179

178180
/** Gets scopes that have been set. */
179181
export function getScopes(): string[] {

src/gcp/apptesting.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { Client } from "../apiv2";
2+
import { cloudTestingOrigin } from "../api";
3+
4+
export const API_VERSION = "v1";
5+
6+
export const client = new Client({
7+
urlPrefix: cloudTestingOrigin(),
8+
auth: true,
9+
apiVersion: API_VERSION,
10+
});
11+
12+
type EnvironmentType =
13+
| "ENVIRONMENT_TYPE_UNSPECIFIED"
14+
| "ANDROID"
15+
| "IOS"
16+
| "NETWORK_CONFIGURATION"
17+
| "PROVIDED_SOFTWARE"
18+
| "DEVICE_IP_BLOCKS";
19+
20+
type TestEnvironmentCatalog = unknown;
21+
22+
/**
23+
* Gets the catalog of supported test environments.
24+
*/
25+
export async function testEnvironmentCatalog(
26+
projectId: string,
27+
environmentType: EnvironmentType,
28+
): Promise<unknown> {
29+
const name = `testEnvironmentCatalog/${environmentType}`;
30+
31+
const queryParams: Record<string, string> = { projectId };
32+
const res = await client.get<TestEnvironmentCatalog>(name, { queryParams });
33+
34+
return res.body;
35+
}

src/mcp/tools/apptesting/tests.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { tool } from "../../tool";
66
import { toContent } from "../../util";
77
import { toAppName } from "../../../appdistribution/options-parser-util";
88
import { AppDistributionClient } from "../../../appdistribution/client";
9-
import { google } from "googleapis";
10-
import { getAccessToken } from "../../../apiv2";
9+
import { testEnvironmentCatalog } from "../../../gcp/apptesting";
1110

1211
const TestDeviceSchema = z
1312
.object({
@@ -98,20 +97,20 @@ export const check_status = tool(
9897
title: "Check Remote Test",
9998
readOnlyHint: true,
10099
},
100+
_meta: {
101+
requiresAuth: true,
102+
requiresProject: true,
103+
},
101104
},
102-
async ({ release_test_name, getAvailableDevices }) => {
105+
async ({ release_test_name, getAvailableDevices }, { projectId }) => {
103106
let devices = undefined;
104107
let releaseTest = undefined;
105108
if (release_test_name) {
106109
const client = new AppDistributionClient();
107110
releaseTest = await client.getReleaseTest(release_test_name);
108111
}
109112
if (getAvailableDevices) {
110-
const testing = google.testing("v1");
111-
devices = await testing.testEnvironmentCatalog.get({
112-
oauth_token: await getAccessToken(),
113-
environmentType: "ANDROID",
114-
});
113+
devices = await testEnvironmentCatalog(projectId || "", "ANDROID");
115114
}
116115

117116
return toContent({

0 commit comments

Comments
 (0)