diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29bb2d..3452cdeae0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1 @@ +- Fixes MCP server issue where `googleapis` is not available. (#9443) diff --git a/src/api.ts b/src/api.ts index c7118000dde..85e594cbdd6 100755 --- a/src/api.ts +++ b/src/api.ts @@ -174,6 +174,8 @@ export const cloudAiCompanionOrigin = () => export const appTestingOrigin = () => utils.envOverride("FIREBASE_APP_TESTING_URL", "https://firebaseapptesting.googleapis.com"); +export const cloudTestingOrigin = () => + utils.envOverride("CLOUD_TESTING_URL", "https://testing.googleapis.com"); /** Gets scopes that have been set. */ export function getScopes(): string[] { diff --git a/src/gcp/apptesting.ts b/src/gcp/apptesting.ts new file mode 100644 index 00000000000..212ad452f0b --- /dev/null +++ b/src/gcp/apptesting.ts @@ -0,0 +1,35 @@ +import { Client } from "../apiv2"; +import { cloudTestingOrigin } from "../api"; + +export const API_VERSION = "v1"; + +export const client = new Client({ + urlPrefix: cloudTestingOrigin(), + auth: true, + apiVersion: API_VERSION, +}); + +type EnvironmentType = + | "ENVIRONMENT_TYPE_UNSPECIFIED" + | "ANDROID" + | "IOS" + | "NETWORK_CONFIGURATION" + | "PROVIDED_SOFTWARE" + | "DEVICE_IP_BLOCKS"; + +type TestEnvironmentCatalog = unknown; + +/** + * Gets the catalog of supported test environments. + */ +export async function testEnvironmentCatalog( + projectId: string, + environmentType: EnvironmentType, +): Promise { + const name = `testEnvironmentCatalog/${environmentType}`; + + const queryParams: Record = { projectId }; + const res = await client.get(name, { queryParams }); + + return res.body; +} diff --git a/src/mcp/tools/apptesting/tests.ts b/src/mcp/tools/apptesting/tests.ts index 57548b2a0e7..a7269725763 100644 --- a/src/mcp/tools/apptesting/tests.ts +++ b/src/mcp/tools/apptesting/tests.ts @@ -6,8 +6,7 @@ import { tool } from "../../tool"; import { toContent } from "../../util"; import { toAppName } from "../../../appdistribution/options-parser-util"; import { AppDistributionClient } from "../../../appdistribution/client"; -import { google } from "googleapis"; -import { getAccessToken } from "../../../apiv2"; +import { testEnvironmentCatalog } from "../../../gcp/apptesting"; const TestDeviceSchema = z .object({ @@ -98,8 +97,12 @@ export const check_status = tool( title: "Check Remote Test", readOnlyHint: true, }, + _meta: { + requiresAuth: true, + requiresProject: true, + }, }, - async ({ release_test_name, getAvailableDevices }) => { + async ({ release_test_name, getAvailableDevices }, { projectId }) => { let devices = undefined; let releaseTest = undefined; if (release_test_name) { @@ -107,11 +110,7 @@ export const check_status = tool( releaseTest = await client.getReleaseTest(release_test_name); } if (getAvailableDevices) { - const testing = google.testing("v1"); - devices = await testing.testEnvironmentCatalog.get({ - oauth_token: await getAccessToken(), - environmentType: "ANDROID", - }); + devices = await testEnvironmentCatalog(projectId || "", "ANDROID"); } return toContent({