Skip to content

Commit cc06821

Browse files
committed
fix 1
1 parent bca398a commit cc06821

File tree

3 files changed

+19
-28
lines changed

3 files changed

+19
-28
lines changed

src/mcp/tools/messaging/get_delivery_data.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ import { z } from "zod";
22
import { tool } from "../../tool";
33
import { mcpError, toContent } from "../../util";
44
import { getAndroidDeliveryData } from "../../../messaging/getDeliveryData";
5-
import { FirebaseError } from "../../../error";
6-
import { logger } from "../../../logger";
75

86
export const get_fcm_delivery_data = tool(
7+
"messaging",
98
{
109
name: "get_fcm_delivery_data",
1110
description:
@@ -33,9 +32,11 @@ export const get_fcm_delivery_data = tool(
3332
},
3433
async ({ appId, pageSize, pageToken }, { projectId }) => {
3534
if (!appId.includes(":android:")) {
36-
throw new FirebaseError(`Invalid app id provided: ${appId}. Currently fcm delivery data is only available for android apps.`)
35+
return mcpError(`Invalid app id provided: ${appId}. Currently fcm delivery data is only available for android apps.`)
3736
}
3837

39-
return toContent(await getAndroidDeliveryData(projectId, appId, { pageSize, pageToken }))
38+
return toContent(
39+
await getAndroidDeliveryData(projectId, appId, { pageSize, pageToken }),
40+
);
4041
},
4142
);

src/messaging/getDeliveryData.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { messagingDataApiOrigin } from "../api";
22
import { Client } from "../apiv2";
33
import { logger } from "../logger";
44
import { FirebaseError } from "../error";
5-
import { ListAndroidDeliveryDataResponse, ListAndroidDeliveryDataRequest } from "./interfaces";
5+
import { ListAndroidDeliveryDataResponse } from "./interfaces";
66

77
const TIMEOUT = 10000;
88

@@ -24,9 +24,9 @@ export async function getAndroidDeliveryData(
2424
// API docs for fetching Android delivery data are here:
2525
// https://firebase.google.com/docs/reference/fcmdata/rest/v1beta1/projects.androidApps.deliveryData/list#http-request
2626

27-
const customHeaders = {
28-
"Content-Type": "application/json",
29-
"x-goog-user-project": projectId,
27+
const customHeaders ={
28+
"Content-Type": "application/json",
29+
"x-goog-user-project": projectId,
3030
};
3131

3232
// set up query params
@@ -38,17 +38,20 @@ export async function getAndroidDeliveryData(
3838
params.set("pageToken", options.pageToken);
3939
}
4040

41+
logger.debug(`requesting android delivery data for ${projectId}, ${androidAppId}`)
42+
4143
const res = await apiClient.request<null, ListAndroidDeliveryDataResponse>({
4244
method: "GET",
4345
path: `/projects/${projectId}/androidApps/${androidAppId}/deliveryData`,
46+
queryParams: params,
4447
headers: customHeaders,
4548
timeout: TIMEOUT,
4649
});
47-
50+
4851
logger.debug(`${res.status}, ${res.response}, ${res.body}`);
4952
return res.body;
5053
} catch (err: any) {
5154
logger.debug(err.message);
52-
throw new FirebaseError(`Failed to fetch delivery data for project ${projectId} and ${androidAppId}, ${err}.`, { original: err });
55+
throw new FirebaseError(`Failed to fetch delivery data for project ${projectId} and ${androidAppId}, ${err}.`, {original: err});
5356
}
5457
}

src/messaging/interfaces.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,17 @@ export interface AndroidDeliveryData {
132132
/** The app ID to which the messages were sent. */
133133
appId: string;
134134
/** The date represented by this entry. */
135-
// TODO: where to get the date type from
136-
// date: string;
135+
date: {
136+
year: number;
137+
month: number;
138+
day: number;
139+
};
137140
/** The analytics label associated with the messages sent. */
138141
analyticsLabel: string;
139142
/** The data for the specified combination. */
140143
data: Data;
141144
}
142145

143-
/**
144-
* Request message for ListAndroidDeliveryData.
145-
*/
146-
export interface ListAndroidDeliveryDataRequest {
147-
/**
148-
* The maximum number of entries to return.
149-
* If unspecified, at most 1,000 entries will be returned.
150-
*/
151-
pageSize?: number;
152-
/**
153-
* A page token, received from a previous `ListAndroidDeliveryDataRequest` call.
154-
* Provide this to retrieve the subsequent page.
155-
*/
156-
pageToken?: string;
157-
}
158-
159146
/**
160147
* Response message for ListAndroidDeliveryData.
161148
*/

0 commit comments

Comments
 (0)