@cashtokenai/meta-mcp-server 1.0.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/LICENSE +21 -0
- package/README.md +294 -0
- package/dist/config.d.ts +39 -0
- package/dist/config.js +60 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.js +28 -0
- package/dist/context.d.ts +9 -0
- package/dist/context.js +8 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.js +120 -0
- package/dist/helpers/cache.d.ts +6 -0
- package/dist/helpers/cache.js +28 -0
- package/dist/helpers/format.d.ts +17 -0
- package/dist/helpers/format.js +28 -0
- package/dist/helpers/graph-client.d.ts +90 -0
- package/dist/helpers/graph-client.js +219 -0
- package/dist/helpers/schema.d.ts +30 -0
- package/dist/helpers/schema.js +69 -0
- package/dist/helpers/validate.d.ts +26 -0
- package/dist/helpers/validate.js +125 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +36 -0
- package/dist/logger.d.ts +3 -0
- package/dist/logger.js +18 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +34 -0
- package/dist/tools/ads/get-account.d.ts +29 -0
- package/dist/tools/ads/get-account.js +45 -0
- package/dist/tools/ads/get-creative.d.ts +29 -0
- package/dist/tools/ads/get-creative.js +37 -0
- package/dist/tools/ads/get-insights.d.ts +129 -0
- package/dist/tools/ads/get-insights.js +153 -0
- package/dist/tools/ads/list-accounts.d.ts +54 -0
- package/dist/tools/ads/list-accounts.js +59 -0
- package/dist/tools/ads/list-ads.d.ts +53 -0
- package/dist/tools/ads/list-ads.js +59 -0
- package/dist/tools/ads/list-adsets.d.ts +49 -0
- package/dist/tools/ads/list-adsets.js +54 -0
- package/dist/tools/ads/list-campaigns.d.ts +45 -0
- package/dist/tools/ads/list-campaigns.js +64 -0
- package/dist/tools/ads/list-custom-audiences.d.ts +41 -0
- package/dist/tools/ads/list-custom-audiences.js +41 -0
- package/dist/tools/business/list-assets.d.ts +37 -0
- package/dist/tools/business/list-assets.js +136 -0
- package/dist/tools/business/list-businesses.d.ts +37 -0
- package/dist/tools/business/list-businesses.js +81 -0
- package/dist/tools/business/list-system-users.d.ts +41 -0
- package/dist/tools/business/list-system-users.js +73 -0
- package/dist/tools/catalog/get-diagnostics.d.ts +29 -0
- package/dist/tools/catalog/get-diagnostics.js +26 -0
- package/dist/tools/catalog/list-products.d.ts +45 -0
- package/dist/tools/catalog/list-products.js +49 -0
- package/dist/tools/catalog/list.d.ts +54 -0
- package/dist/tools/catalog/list.js +48 -0
- package/dist/tools/instagram/get-account.d.ts +29 -0
- package/dist/tools/instagram/get-account.js +34 -0
- package/dist/tools/instagram/get-audience-demographics.d.ts +45 -0
- package/dist/tools/instagram/get-audience-demographics.js +58 -0
- package/dist/tools/instagram/get-media-insights.d.ts +29 -0
- package/dist/tools/instagram/get-media-insights.js +49 -0
- package/dist/tools/instagram/list-accounts.d.ts +33 -0
- package/dist/tools/instagram/list-accounts.js +63 -0
- package/dist/tools/instagram/list-media.d.ts +41 -0
- package/dist/tools/instagram/list-media.js +42 -0
- package/dist/tools/meta/graph-read.d.ts +33 -0
- package/dist/tools/meta/graph-read.js +71 -0
- package/dist/tools/overview/business-overview.d.ts +49 -0
- package/dist/tools/overview/business-overview.js +235 -0
- package/dist/tools/overview/content-report.d.ts +57 -0
- package/dist/tools/overview/content-report.js +344 -0
- package/dist/tools/overview/latest-posts-summary.d.ts +41 -0
- package/dist/tools/overview/latest-posts-summary.js +189 -0
- package/dist/tools/pages/get-insights.d.ts +41 -0
- package/dist/tools/pages/get-insights.js +49 -0
- package/dist/tools/pages/get-post-insights.d.ts +33 -0
- package/dist/tools/pages/get-post-insights.js +47 -0
- package/dist/tools/pages/get.d.ts +29 -0
- package/dist/tools/pages/get.js +50 -0
- package/dist/tools/pages/list-posts.d.ts +53 -0
- package/dist/tools/pages/list-posts.js +62 -0
- package/dist/tools/pages/list-reviews.d.ts +41 -0
- package/dist/tools/pages/list-reviews.js +37 -0
- package/dist/tools/pages/list-videos.d.ts +41 -0
- package/dist/tools/pages/list-videos.js +40 -0
- package/dist/tools/pages/list.d.ts +41 -0
- package/dist/tools/pages/list.js +39 -0
- package/dist/tools/pixels/get-stats.d.ts +41 -0
- package/dist/tools/pixels/get-stats.js +34 -0
- package/dist/tools/pixels/list.d.ts +41 -0
- package/dist/tools/pixels/list.js +41 -0
- package/dist/tools/register.d.ts +3 -0
- package/dist/tools/register.js +95 -0
- package/dist/tools/shared.d.ts +45 -0
- package/dist/tools/shared.js +137 -0
- package/dist/tools/token/health.d.ts +17 -0
- package/dist/tools/token/health.js +65 -0
- package/dist/tools/token/inspect.d.ts +26 -0
- package/dist/tools/token/inspect.js +88 -0
- package/dist/tools/whatsapp/get-analytics.d.ts +57 -0
- package/dist/tools/whatsapp/get-analytics.js +66 -0
- package/dist/tools/whatsapp/list-phone-numbers.d.ts +41 -0
- package/dist/tools/whatsapp/list-phone-numbers.js +35 -0
- package/dist/tools/whatsapp/list-templates.d.ts +45 -0
- package/dist/tools/whatsapp/list-templates.js +44 -0
- package/dist/tools/whatsapp/list-wabas.d.ts +54 -0
- package/dist/tools/whatsapp/list-wabas.js +48 -0
- package/dist/types/meta.d.ts +46 -0
- package/dist/types/meta.js +1 -0
- package/package.json +77 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
ad_account_id: z.ZodString;
|
|
8
|
+
adset_id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
campaign_id: z.ZodOptional<z.ZodString>;
|
|
10
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
12
|
+
}, "strict", z.ZodTypeAny, {
|
|
13
|
+
fields: string[];
|
|
14
|
+
ad_account_id: string;
|
|
15
|
+
limit: number;
|
|
16
|
+
auto_paginate: boolean;
|
|
17
|
+
campaign_id?: string | undefined;
|
|
18
|
+
adset_id?: string | undefined;
|
|
19
|
+
after?: string | undefined;
|
|
20
|
+
effective_status?: string[] | undefined;
|
|
21
|
+
}, {
|
|
22
|
+
ad_account_id: string;
|
|
23
|
+
fields?: string[] | undefined;
|
|
24
|
+
campaign_id?: string | undefined;
|
|
25
|
+
adset_id?: string | undefined;
|
|
26
|
+
limit?: number | undefined;
|
|
27
|
+
after?: string | undefined;
|
|
28
|
+
auto_paginate?: boolean | undefined;
|
|
29
|
+
effective_status?: string[] | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
32
|
+
export declare const definition: {
|
|
33
|
+
readonly name: "meta_ads_list_ads";
|
|
34
|
+
readonly title: "List ads (account-, campaign-, or adset-scoped)";
|
|
35
|
+
readonly description: "Lists ads. Narrow by adset_id (preferred) or campaign_id. Each ad references a 'creative' ID — pass that to meta_ads_get_creative to fetch body, image, and CTA.";
|
|
36
|
+
readonly inputSchema: {
|
|
37
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
38
|
+
after: z.ZodOptional<z.ZodString>;
|
|
39
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
40
|
+
ad_account_id: z.ZodString;
|
|
41
|
+
adset_id: z.ZodOptional<z.ZodString>;
|
|
42
|
+
campaign_id: z.ZodOptional<z.ZodString>;
|
|
43
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
44
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
45
|
+
};
|
|
46
|
+
readonly annotations: {
|
|
47
|
+
readonly readOnlyHint: true;
|
|
48
|
+
readonly destructiveHint: false;
|
|
49
|
+
readonly idempotentHint: true;
|
|
50
|
+
readonly openWorldHint: true;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertAllowed } from "../../config.js";
|
|
3
|
+
import { adAccountIdSchema, metaIdSchema, paginationShape } from "../../helpers/schema.js";
|
|
4
|
+
import { runList } from "../shared.js";
|
|
5
|
+
export const inputSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
ad_account_id: adAccountIdSchema,
|
|
8
|
+
adset_id: metaIdSchema
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("If set, lists ads under that ad set via /{adset_id}/ads."),
|
|
11
|
+
campaign_id: metaIdSchema
|
|
12
|
+
.optional()
|
|
13
|
+
.describe("If set (and adset_id is not), lists ads under that campaign."),
|
|
14
|
+
effective_status: z.array(z.string()).optional(),
|
|
15
|
+
fields: z
|
|
16
|
+
.array(z.string())
|
|
17
|
+
.default([
|
|
18
|
+
"id",
|
|
19
|
+
"name",
|
|
20
|
+
"adset_id",
|
|
21
|
+
"campaign_id",
|
|
22
|
+
"effective_status",
|
|
23
|
+
"status",
|
|
24
|
+
"creative",
|
|
25
|
+
"preview_shareable_link",
|
|
26
|
+
"created_time",
|
|
27
|
+
"updated_time",
|
|
28
|
+
])
|
|
29
|
+
.describe("Ad fields."),
|
|
30
|
+
...paginationShape,
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
export const definition = {
|
|
34
|
+
name: "meta_ads_list_ads",
|
|
35
|
+
title: "List ads (account-, campaign-, or adset-scoped)",
|
|
36
|
+
description: `Lists ads. Narrow by adset_id (preferred) or campaign_id. Each ad references a 'creative' ID — pass that to meta_ads_get_creative to fetch body, image, and CTA.`,
|
|
37
|
+
inputSchema: inputSchema.shape,
|
|
38
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
39
|
+
};
|
|
40
|
+
export async function handler(input, ctx) {
|
|
41
|
+
assertAllowed("ad_account", input.ad_account_id, ctx.config);
|
|
42
|
+
const params = {
|
|
43
|
+
fields: input.fields.join(","),
|
|
44
|
+
limit: input.limit,
|
|
45
|
+
after: input.after,
|
|
46
|
+
};
|
|
47
|
+
if (input.effective_status)
|
|
48
|
+
params["effective_status"] = JSON.stringify(input.effective_status);
|
|
49
|
+
const path = input.adset_id
|
|
50
|
+
? `${input.adset_id}/ads`
|
|
51
|
+
: input.campaign_id
|
|
52
|
+
? `${input.campaign_id}/ads`
|
|
53
|
+
: `${input.ad_account_id}/ads`;
|
|
54
|
+
return runList(ctx, { path, params }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, {
|
|
55
|
+
ad_account_id: input.ad_account_id,
|
|
56
|
+
campaign_id: input.campaign_id,
|
|
57
|
+
adset_id: input.adset_id,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
ad_account_id: z.ZodString;
|
|
8
|
+
campaign_id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
+
}, "strict", z.ZodTypeAny, {
|
|
12
|
+
fields: string[];
|
|
13
|
+
ad_account_id: string;
|
|
14
|
+
limit: number;
|
|
15
|
+
auto_paginate: boolean;
|
|
16
|
+
campaign_id?: string | undefined;
|
|
17
|
+
after?: string | undefined;
|
|
18
|
+
effective_status?: string[] | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
ad_account_id: string;
|
|
21
|
+
fields?: string[] | undefined;
|
|
22
|
+
campaign_id?: string | undefined;
|
|
23
|
+
limit?: number | undefined;
|
|
24
|
+
after?: string | undefined;
|
|
25
|
+
auto_paginate?: boolean | undefined;
|
|
26
|
+
effective_status?: string[] | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
29
|
+
export declare const definition: {
|
|
30
|
+
readonly name: "meta_ads_list_adsets";
|
|
31
|
+
readonly title: "List ad sets (account-wide or within a campaign)";
|
|
32
|
+
readonly description: "Lists ad sets. If campaign_id is set, restricts to that campaign. Includes budget, bid strategy, optimization goal, targeting, schedule.";
|
|
33
|
+
readonly inputSchema: {
|
|
34
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
35
|
+
after: z.ZodOptional<z.ZodString>;
|
|
36
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
37
|
+
ad_account_id: z.ZodString;
|
|
38
|
+
campaign_id: z.ZodOptional<z.ZodString>;
|
|
39
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
40
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
41
|
+
};
|
|
42
|
+
readonly annotations: {
|
|
43
|
+
readonly readOnlyHint: true;
|
|
44
|
+
readonly destructiveHint: false;
|
|
45
|
+
readonly idempotentHint: true;
|
|
46
|
+
readonly openWorldHint: true;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertAllowed } from "../../config.js";
|
|
3
|
+
import { adAccountIdSchema, metaIdSchema, paginationShape } from "../../helpers/schema.js";
|
|
4
|
+
import { runList } from "../shared.js";
|
|
5
|
+
export const inputSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
ad_account_id: adAccountIdSchema,
|
|
8
|
+
campaign_id: metaIdSchema
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("If provided, lists ad sets under a specific campaign via /{campaign_id}/adsets."),
|
|
11
|
+
effective_status: z.array(z.string()).optional().describe("Optional effective_status filter."),
|
|
12
|
+
fields: z
|
|
13
|
+
.array(z.string())
|
|
14
|
+
.default([
|
|
15
|
+
"id",
|
|
16
|
+
"name",
|
|
17
|
+
"campaign_id",
|
|
18
|
+
"effective_status",
|
|
19
|
+
"status",
|
|
20
|
+
"daily_budget",
|
|
21
|
+
"lifetime_budget",
|
|
22
|
+
"optimization_goal",
|
|
23
|
+
"billing_event",
|
|
24
|
+
"bid_strategy",
|
|
25
|
+
"bid_amount",
|
|
26
|
+
"targeting",
|
|
27
|
+
"start_time",
|
|
28
|
+
"end_time",
|
|
29
|
+
"created_time",
|
|
30
|
+
"updated_time",
|
|
31
|
+
])
|
|
32
|
+
.describe("Ad-set fields."),
|
|
33
|
+
...paginationShape,
|
|
34
|
+
})
|
|
35
|
+
.strict();
|
|
36
|
+
export const definition = {
|
|
37
|
+
name: "meta_ads_list_adsets",
|
|
38
|
+
title: "List ad sets (account-wide or within a campaign)",
|
|
39
|
+
description: `Lists ad sets. If campaign_id is set, restricts to that campaign. Includes budget, bid strategy, optimization goal, targeting, schedule.`,
|
|
40
|
+
inputSchema: inputSchema.shape,
|
|
41
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
42
|
+
};
|
|
43
|
+
export async function handler(input, ctx) {
|
|
44
|
+
assertAllowed("ad_account", input.ad_account_id, ctx.config);
|
|
45
|
+
const params = {
|
|
46
|
+
fields: input.fields.join(","),
|
|
47
|
+
limit: input.limit,
|
|
48
|
+
after: input.after,
|
|
49
|
+
};
|
|
50
|
+
if (input.effective_status)
|
|
51
|
+
params["effective_status"] = JSON.stringify(input.effective_status);
|
|
52
|
+
const path = input.campaign_id ? `${input.campaign_id}/adsets` : `${input.ad_account_id}/adsets`;
|
|
53
|
+
return runList(ctx, { path, params }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { ad_account_id: input.ad_account_id, campaign_id: input.campaign_id });
|
|
54
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
ad_account_id: z.ZodString;
|
|
8
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodEnum<["ACTIVE", "PAUSED", "DELETED", "PENDING_REVIEW", "DISAPPROVED", "PREAPPROVED", "PENDING_BILLING_INFO", "CAMPAIGN_PAUSED", "ARCHIVED", "IN_PROCESS", "WITH_ISSUES"]>, "many">>;
|
|
9
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
10
|
+
}, "strict", z.ZodTypeAny, {
|
|
11
|
+
fields: string[];
|
|
12
|
+
ad_account_id: string;
|
|
13
|
+
limit: number;
|
|
14
|
+
auto_paginate: boolean;
|
|
15
|
+
after?: string | undefined;
|
|
16
|
+
effective_status?: ("ACTIVE" | "PAUSED" | "DELETED" | "PENDING_REVIEW" | "DISAPPROVED" | "PREAPPROVED" | "PENDING_BILLING_INFO" | "CAMPAIGN_PAUSED" | "ARCHIVED" | "IN_PROCESS" | "WITH_ISSUES")[] | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
ad_account_id: string;
|
|
19
|
+
fields?: string[] | undefined;
|
|
20
|
+
limit?: number | undefined;
|
|
21
|
+
after?: string | undefined;
|
|
22
|
+
auto_paginate?: boolean | undefined;
|
|
23
|
+
effective_status?: ("ACTIVE" | "PAUSED" | "DELETED" | "PENDING_REVIEW" | "DISAPPROVED" | "PREAPPROVED" | "PENDING_BILLING_INFO" | "CAMPAIGN_PAUSED" | "ARCHIVED" | "IN_PROCESS" | "WITH_ISSUES")[] | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
26
|
+
export declare const definition: {
|
|
27
|
+
readonly name: "meta_ads_list_campaigns";
|
|
28
|
+
readonly title: "List campaigns in an ad account";
|
|
29
|
+
readonly description: "Lists campaigns with status, objective, budget, and schedule. Use effective_status to filter only ACTIVE campaigns, for example. Pair with meta_ads_get_insights at level='campaign' for performance metrics.";
|
|
30
|
+
readonly inputSchema: {
|
|
31
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
32
|
+
after: z.ZodOptional<z.ZodString>;
|
|
33
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
34
|
+
ad_account_id: z.ZodString;
|
|
35
|
+
effective_status: z.ZodOptional<z.ZodArray<z.ZodEnum<["ACTIVE", "PAUSED", "DELETED", "PENDING_REVIEW", "DISAPPROVED", "PREAPPROVED", "PENDING_BILLING_INFO", "CAMPAIGN_PAUSED", "ARCHIVED", "IN_PROCESS", "WITH_ISSUES"]>, "many">>;
|
|
36
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
37
|
+
};
|
|
38
|
+
readonly annotations: {
|
|
39
|
+
readonly readOnlyHint: true;
|
|
40
|
+
readonly destructiveHint: false;
|
|
41
|
+
readonly idempotentHint: true;
|
|
42
|
+
readonly openWorldHint: true;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertAllowed } from "../../config.js";
|
|
3
|
+
import { adAccountIdSchema, paginationShape } from "../../helpers/schema.js";
|
|
4
|
+
import { runList } from "../shared.js";
|
|
5
|
+
export const inputSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
ad_account_id: adAccountIdSchema,
|
|
8
|
+
effective_status: z
|
|
9
|
+
.array(z.enum([
|
|
10
|
+
"ACTIVE",
|
|
11
|
+
"PAUSED",
|
|
12
|
+
"DELETED",
|
|
13
|
+
"PENDING_REVIEW",
|
|
14
|
+
"DISAPPROVED",
|
|
15
|
+
"PREAPPROVED",
|
|
16
|
+
"PENDING_BILLING_INFO",
|
|
17
|
+
"CAMPAIGN_PAUSED",
|
|
18
|
+
"ARCHIVED",
|
|
19
|
+
"IN_PROCESS",
|
|
20
|
+
"WITH_ISSUES",
|
|
21
|
+
]))
|
|
22
|
+
.optional()
|
|
23
|
+
.describe("Filter by effective_status. Omit to list all."),
|
|
24
|
+
fields: z
|
|
25
|
+
.array(z.string())
|
|
26
|
+
.default([
|
|
27
|
+
"id",
|
|
28
|
+
"name",
|
|
29
|
+
"objective",
|
|
30
|
+
"effective_status",
|
|
31
|
+
"status",
|
|
32
|
+
"daily_budget",
|
|
33
|
+
"lifetime_budget",
|
|
34
|
+
"budget_remaining",
|
|
35
|
+
"buying_type",
|
|
36
|
+
"special_ad_categories",
|
|
37
|
+
"start_time",
|
|
38
|
+
"stop_time",
|
|
39
|
+
"created_time",
|
|
40
|
+
"updated_time",
|
|
41
|
+
])
|
|
42
|
+
.describe("Campaign fields."),
|
|
43
|
+
...paginationShape,
|
|
44
|
+
})
|
|
45
|
+
.strict();
|
|
46
|
+
export const definition = {
|
|
47
|
+
name: "meta_ads_list_campaigns",
|
|
48
|
+
title: "List campaigns in an ad account",
|
|
49
|
+
description: `Lists campaigns with status, objective, budget, and schedule. Use effective_status to filter only ACTIVE campaigns, for example. Pair with meta_ads_get_insights at level='campaign' for performance metrics.`,
|
|
50
|
+
inputSchema: inputSchema.shape,
|
|
51
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
52
|
+
};
|
|
53
|
+
export async function handler(input, ctx) {
|
|
54
|
+
assertAllowed("ad_account", input.ad_account_id, ctx.config);
|
|
55
|
+
const params = {
|
|
56
|
+
fields: input.fields.join(","),
|
|
57
|
+
limit: input.limit,
|
|
58
|
+
after: input.after,
|
|
59
|
+
};
|
|
60
|
+
if (input.effective_status) {
|
|
61
|
+
params["effective_status"] = JSON.stringify(input.effective_status);
|
|
62
|
+
}
|
|
63
|
+
return runList(ctx, { path: `${input.ad_account_id}/campaigns`, params }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { ad_account_id: input.ad_account_id });
|
|
64
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
ad_account_id: z.ZodString;
|
|
8
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
}, "strict", z.ZodTypeAny, {
|
|
10
|
+
fields: string[];
|
|
11
|
+
ad_account_id: string;
|
|
12
|
+
limit: number;
|
|
13
|
+
auto_paginate: boolean;
|
|
14
|
+
after?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
ad_account_id: string;
|
|
17
|
+
fields?: string[] | undefined;
|
|
18
|
+
limit?: number | undefined;
|
|
19
|
+
after?: string | undefined;
|
|
20
|
+
auto_paginate?: boolean | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
23
|
+
export declare const definition: {
|
|
24
|
+
readonly name: "meta_ads_list_custom_audiences";
|
|
25
|
+
readonly title: "List custom audiences (metadata only)";
|
|
26
|
+
readonly description: "Lists custom audiences attached to an ad account — names, subtype (CUSTOM, WEBSITE, LOOKALIKE, …), approximate size buckets, delivery status, data source. No member-level data is exposed.";
|
|
27
|
+
readonly inputSchema: {
|
|
28
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
after: z.ZodOptional<z.ZodString>;
|
|
30
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
31
|
+
ad_account_id: z.ZodString;
|
|
32
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
33
|
+
};
|
|
34
|
+
readonly annotations: {
|
|
35
|
+
readonly readOnlyHint: true;
|
|
36
|
+
readonly destructiveHint: false;
|
|
37
|
+
readonly idempotentHint: true;
|
|
38
|
+
readonly openWorldHint: true;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertAllowed } from "../../config.js";
|
|
3
|
+
import { adAccountIdSchema, paginationShape } from "../../helpers/schema.js";
|
|
4
|
+
import { runList } from "../shared.js";
|
|
5
|
+
export const inputSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
ad_account_id: adAccountIdSchema,
|
|
8
|
+
fields: z
|
|
9
|
+
.array(z.string())
|
|
10
|
+
.default([
|
|
11
|
+
"id",
|
|
12
|
+
"name",
|
|
13
|
+
"description",
|
|
14
|
+
"subtype",
|
|
15
|
+
"approximate_count_lower_bound",
|
|
16
|
+
"approximate_count_upper_bound",
|
|
17
|
+
"delivery_status",
|
|
18
|
+
"operation_status",
|
|
19
|
+
"data_source",
|
|
20
|
+
"retention_days",
|
|
21
|
+
"time_created",
|
|
22
|
+
"time_updated",
|
|
23
|
+
])
|
|
24
|
+
.describe("Metadata fields. No PII/member data is returned by this endpoint."),
|
|
25
|
+
...paginationShape,
|
|
26
|
+
})
|
|
27
|
+
.strict();
|
|
28
|
+
export const definition = {
|
|
29
|
+
name: "meta_ads_list_custom_audiences",
|
|
30
|
+
title: "List custom audiences (metadata only)",
|
|
31
|
+
description: `Lists custom audiences attached to an ad account — names, subtype (CUSTOM, WEBSITE, LOOKALIKE, …), approximate size buckets, delivery status, data source. No member-level data is exposed.`,
|
|
32
|
+
inputSchema: inputSchema.shape,
|
|
33
|
+
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
34
|
+
};
|
|
35
|
+
export async function handler(input, ctx) {
|
|
36
|
+
assertAllowed("ad_account", input.ad_account_id, ctx.config);
|
|
37
|
+
return runList(ctx, {
|
|
38
|
+
path: `${input.ad_account_id}/customaudiences`,
|
|
39
|
+
params: { fields: input.fields.join(","), limit: input.limit, after: input.after },
|
|
40
|
+
}, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { ad_account_id: input.ad_account_id });
|
|
41
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
business_id: z.ZodString;
|
|
5
|
+
kinds: z.ZodDefault<z.ZodArray<z.ZodEnum<["ad_accounts", "pages", "instagram_accounts", "pixels", "product_catalogs", "whatsapp_business_accounts"]>, "many">>;
|
|
6
|
+
include_client: z.ZodDefault<z.ZodBoolean>;
|
|
7
|
+
per_kind_limit: z.ZodDefault<z.ZodNumber>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
business_id: string;
|
|
10
|
+
kinds: ("pages" | "ad_accounts" | "instagram_accounts" | "pixels" | "product_catalogs" | "whatsapp_business_accounts")[];
|
|
11
|
+
include_client: boolean;
|
|
12
|
+
per_kind_limit: number;
|
|
13
|
+
}, {
|
|
14
|
+
business_id: string;
|
|
15
|
+
kinds?: ("pages" | "ad_accounts" | "instagram_accounts" | "pixels" | "product_catalogs" | "whatsapp_business_accounts")[] | undefined;
|
|
16
|
+
include_client?: boolean | undefined;
|
|
17
|
+
per_kind_limit?: number | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
20
|
+
export declare const definition: {
|
|
21
|
+
readonly name: "meta_business_list_assets";
|
|
22
|
+
readonly title: "List assets assigned to a Business Manager";
|
|
23
|
+
readonly description: "For a given business_id, enumerates the business assets the token can see in one call:\n- Ad accounts (owned + optionally client)\n- Facebook Pages (owned + optionally client)\n- Instagram Business accounts\n- Meta Pixels\n- Product catalogs\n- WhatsApp Business accounts (WABAs)\n\nEach section is fetched as a separate Graph call. Failures on individual sections do not abort the others — the response reports per-section success/error so the assistant can work around partial failures.\n\nUse this to discover IDs for downstream insight tools.";
|
|
24
|
+
readonly inputSchema: {
|
|
25
|
+
business_id: z.ZodString;
|
|
26
|
+
kinds: z.ZodDefault<z.ZodArray<z.ZodEnum<["ad_accounts", "pages", "instagram_accounts", "pixels", "product_catalogs", "whatsapp_business_accounts"]>, "many">>;
|
|
27
|
+
include_client: z.ZodDefault<z.ZodBoolean>;
|
|
28
|
+
per_kind_limit: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
};
|
|
30
|
+
readonly annotations: {
|
|
31
|
+
readonly readOnlyHint: true;
|
|
32
|
+
readonly destructiveHint: false;
|
|
33
|
+
readonly idempotentHint: true;
|
|
34
|
+
readonly openWorldHint: true;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { assertAllowed } from "../../config.js";
|
|
3
|
+
import { MetaError } from "../../errors.js";
|
|
4
|
+
import { jsonBlock, toolResult } from "../../helpers/format.js";
|
|
5
|
+
import { metaIdSchema } from "../../helpers/schema.js";
|
|
6
|
+
const ASSET_KINDS = [
|
|
7
|
+
"ad_accounts",
|
|
8
|
+
"pages",
|
|
9
|
+
"instagram_accounts",
|
|
10
|
+
"pixels",
|
|
11
|
+
"product_catalogs",
|
|
12
|
+
"whatsapp_business_accounts",
|
|
13
|
+
];
|
|
14
|
+
export const inputSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
business_id: metaIdSchema.describe("Business Manager ID (from meta_business_list)."),
|
|
17
|
+
kinds: z
|
|
18
|
+
.array(z.enum(ASSET_KINDS))
|
|
19
|
+
.default([...ASSET_KINDS])
|
|
20
|
+
.describe("Which asset edges to enumerate. Default: all."),
|
|
21
|
+
include_client: z
|
|
22
|
+
.boolean()
|
|
23
|
+
.default(false)
|
|
24
|
+
.describe("Also fetch client_* edges (assets the business has access to but does not own)."),
|
|
25
|
+
per_kind_limit: z
|
|
26
|
+
.number()
|
|
27
|
+
.int()
|
|
28
|
+
.min(1)
|
|
29
|
+
.max(500)
|
|
30
|
+
.default(50)
|
|
31
|
+
.describe("Page size per asset kind."),
|
|
32
|
+
})
|
|
33
|
+
.strict();
|
|
34
|
+
export const definition = {
|
|
35
|
+
name: "meta_business_list_assets",
|
|
36
|
+
title: "List assets assigned to a Business Manager",
|
|
37
|
+
description: `For a given business_id, enumerates the business assets the token can see in one call:
|
|
38
|
+
- Ad accounts (owned + optionally client)
|
|
39
|
+
- Facebook Pages (owned + optionally client)
|
|
40
|
+
- Instagram Business accounts
|
|
41
|
+
- Meta Pixels
|
|
42
|
+
- Product catalogs
|
|
43
|
+
- WhatsApp Business accounts (WABAs)
|
|
44
|
+
|
|
45
|
+
Each section is fetched as a separate Graph call. Failures on individual sections do not abort the others — the response reports per-section success/error so the assistant can work around partial failures.
|
|
46
|
+
|
|
47
|
+
Use this to discover IDs for downstream insight tools.`,
|
|
48
|
+
inputSchema: inputSchema.shape,
|
|
49
|
+
annotations: {
|
|
50
|
+
readOnlyHint: true,
|
|
51
|
+
destructiveHint: false,
|
|
52
|
+
idempotentHint: true,
|
|
53
|
+
openWorldHint: true,
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const FIELDS = {
|
|
57
|
+
ad_accounts: "id,account_id,name,currency,timezone_name,account_status",
|
|
58
|
+
pages: "id,name,category,tasks,access_token",
|
|
59
|
+
instagram_accounts: "id,username",
|
|
60
|
+
pixels: "id,name,last_fired_time,is_unavailable",
|
|
61
|
+
product_catalogs: "id,name,vertical,product_count",
|
|
62
|
+
whatsapp_business_accounts: "id,name,currency,timezone_id",
|
|
63
|
+
};
|
|
64
|
+
const EDGE_NAME = {
|
|
65
|
+
ad_accounts: { owned: "owned_ad_accounts", client: "client_ad_accounts" },
|
|
66
|
+
pages: { owned: "owned_pages", client: "client_pages" },
|
|
67
|
+
// Graph exposes `owned_instagram_accounts` on the Business node but not a
|
|
68
|
+
// `client_instagram_accounts` edge. IG accounts linked to a Page are also
|
|
69
|
+
// discoverable via `GET /{page_id}?fields=instagram_business_account`.
|
|
70
|
+
instagram_accounts: { owned: "owned_instagram_accounts", client: null },
|
|
71
|
+
pixels: { owned: "owned_pixels", client: null },
|
|
72
|
+
product_catalogs: { owned: "owned_product_catalogs", client: "client_product_catalogs" },
|
|
73
|
+
whatsapp_business_accounts: { owned: "owned_whatsapp_business_accounts", client: "client_whatsapp_business_accounts" },
|
|
74
|
+
};
|
|
75
|
+
export async function handler(input, ctx) {
|
|
76
|
+
assertAllowed("business", input.business_id, ctx.config);
|
|
77
|
+
const scopes = input.include_client ? ["owned", "client"] : ["owned"];
|
|
78
|
+
const sections = {};
|
|
79
|
+
await Promise.all(input.kinds.flatMap((kind) => scopes.map(async (scope) => {
|
|
80
|
+
const edge = EDGE_NAME[kind][scope];
|
|
81
|
+
if (!edge)
|
|
82
|
+
return;
|
|
83
|
+
const section = (sections[kind] ??= []);
|
|
84
|
+
try {
|
|
85
|
+
const page = await ctx.graph.get({
|
|
86
|
+
path: `${input.business_id}/${edge}`,
|
|
87
|
+
params: { fields: FIELDS[kind], limit: input.per_kind_limit },
|
|
88
|
+
});
|
|
89
|
+
section.push({ scope, items: Array.isArray(page.data) ? page.data : [] });
|
|
90
|
+
}
|
|
91
|
+
catch (err) {
|
|
92
|
+
const e = err instanceof MetaError ? err : new MetaError(err.message);
|
|
93
|
+
section.push({ scope, error: e.message, hint: e.hint });
|
|
94
|
+
}
|
|
95
|
+
})));
|
|
96
|
+
// Fallback IG discovery: walk the surviving Pages and look up
|
|
97
|
+
// `instagram_business_account`. Meta increasingly hides IG behind the Page
|
|
98
|
+
// link rather than the Business node.
|
|
99
|
+
if (input.kinds.includes("instagram_accounts")) {
|
|
100
|
+
const pageSection = sections.pages ?? [];
|
|
101
|
+
const pageItems = pageSection.flatMap((s) => s.items ?? []);
|
|
102
|
+
const igFromPages = [];
|
|
103
|
+
await Promise.all(pageItems.map(async (p) => {
|
|
104
|
+
try {
|
|
105
|
+
const data = await ctx.graph.get({
|
|
106
|
+
path: p.id,
|
|
107
|
+
params: { fields: "id,name,instagram_business_account{id,username,name}" },
|
|
108
|
+
});
|
|
109
|
+
if (data.instagram_business_account) {
|
|
110
|
+
igFromPages.push({
|
|
111
|
+
id: data.instagram_business_account.id,
|
|
112
|
+
name: data.instagram_business_account.name,
|
|
113
|
+
username: data.instagram_business_account.username,
|
|
114
|
+
category: `via page ${data.id} (${data.name ?? ""})`.trim(),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
/* non-fatal per-page */
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
if (igFromPages.length > 0) {
|
|
123
|
+
(sections.instagram_accounts ??= []).push({
|
|
124
|
+
scope: "via_page",
|
|
125
|
+
items: igFromPages,
|
|
126
|
+
source: "page.instagram_business_account",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const structured = {
|
|
131
|
+
business_id: input.business_id,
|
|
132
|
+
scopes,
|
|
133
|
+
assets: sections,
|
|
134
|
+
};
|
|
135
|
+
return toolResult(structured, jsonBlock(structured));
|
|
136
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { ToolContext } from "../../context.js";
|
|
3
|
+
export declare const inputSchema: z.ZodObject<{
|
|
4
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
6
|
+
after: z.ZodOptional<z.ZodString>;
|
|
7
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
8
|
+
}, "strict", z.ZodTypeAny, {
|
|
9
|
+
fields: string[];
|
|
10
|
+
limit: number;
|
|
11
|
+
auto_paginate: boolean;
|
|
12
|
+
after?: string | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
fields?: string[] | undefined;
|
|
15
|
+
limit?: number | undefined;
|
|
16
|
+
after?: string | undefined;
|
|
17
|
+
auto_paginate?: boolean | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export type Input = z.infer<typeof inputSchema>;
|
|
20
|
+
export declare const definition: {
|
|
21
|
+
readonly name: "meta_business_list";
|
|
22
|
+
readonly title: "List Meta businesses visible to the token";
|
|
23
|
+
readonly description: "Lists every Business Manager the configured access token can see — via GET /me/businesses.\n\nTypical usage: call this once at the start of a session to discover available business IDs, then pass the chosen ID to meta_business_list_assets / meta_business_list_system_users.\n\nRespects META_ALLOWED_BUSINESS_IDS: if set, filters the response to that allowlist.";
|
|
24
|
+
readonly inputSchema: {
|
|
25
|
+
fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
27
|
+
after: z.ZodOptional<z.ZodString>;
|
|
28
|
+
auto_paginate: z.ZodDefault<z.ZodBoolean>;
|
|
29
|
+
};
|
|
30
|
+
readonly annotations: {
|
|
31
|
+
readonly readOnlyHint: true;
|
|
32
|
+
readonly destructiveHint: false;
|
|
33
|
+
readonly idempotentHint: true;
|
|
34
|
+
readonly openWorldHint: true;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
|