@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.
Files changed (109) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +294 -0
  3. package/dist/config.d.ts +39 -0
  4. package/dist/config.js +60 -0
  5. package/dist/constants.d.ts +21 -0
  6. package/dist/constants.js +28 -0
  7. package/dist/context.d.ts +9 -0
  8. package/dist/context.js +8 -0
  9. package/dist/errors.d.ts +41 -0
  10. package/dist/errors.js +120 -0
  11. package/dist/helpers/cache.d.ts +6 -0
  12. package/dist/helpers/cache.js +28 -0
  13. package/dist/helpers/format.d.ts +17 -0
  14. package/dist/helpers/format.js +28 -0
  15. package/dist/helpers/graph-client.d.ts +90 -0
  16. package/dist/helpers/graph-client.js +219 -0
  17. package/dist/helpers/schema.d.ts +30 -0
  18. package/dist/helpers/schema.js +69 -0
  19. package/dist/helpers/validate.d.ts +26 -0
  20. package/dist/helpers/validate.js +125 -0
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.js +36 -0
  23. package/dist/logger.d.ts +3 -0
  24. package/dist/logger.js +18 -0
  25. package/dist/server.d.ts +7 -0
  26. package/dist/server.js +34 -0
  27. package/dist/tools/ads/get-account.d.ts +29 -0
  28. package/dist/tools/ads/get-account.js +45 -0
  29. package/dist/tools/ads/get-creative.d.ts +29 -0
  30. package/dist/tools/ads/get-creative.js +37 -0
  31. package/dist/tools/ads/get-insights.d.ts +129 -0
  32. package/dist/tools/ads/get-insights.js +153 -0
  33. package/dist/tools/ads/list-accounts.d.ts +54 -0
  34. package/dist/tools/ads/list-accounts.js +59 -0
  35. package/dist/tools/ads/list-ads.d.ts +53 -0
  36. package/dist/tools/ads/list-ads.js +59 -0
  37. package/dist/tools/ads/list-adsets.d.ts +49 -0
  38. package/dist/tools/ads/list-adsets.js +54 -0
  39. package/dist/tools/ads/list-campaigns.d.ts +45 -0
  40. package/dist/tools/ads/list-campaigns.js +64 -0
  41. package/dist/tools/ads/list-custom-audiences.d.ts +41 -0
  42. package/dist/tools/ads/list-custom-audiences.js +41 -0
  43. package/dist/tools/business/list-assets.d.ts +37 -0
  44. package/dist/tools/business/list-assets.js +136 -0
  45. package/dist/tools/business/list-businesses.d.ts +37 -0
  46. package/dist/tools/business/list-businesses.js +81 -0
  47. package/dist/tools/business/list-system-users.d.ts +41 -0
  48. package/dist/tools/business/list-system-users.js +73 -0
  49. package/dist/tools/catalog/get-diagnostics.d.ts +29 -0
  50. package/dist/tools/catalog/get-diagnostics.js +26 -0
  51. package/dist/tools/catalog/list-products.d.ts +45 -0
  52. package/dist/tools/catalog/list-products.js +49 -0
  53. package/dist/tools/catalog/list.d.ts +54 -0
  54. package/dist/tools/catalog/list.js +48 -0
  55. package/dist/tools/instagram/get-account.d.ts +29 -0
  56. package/dist/tools/instagram/get-account.js +34 -0
  57. package/dist/tools/instagram/get-audience-demographics.d.ts +45 -0
  58. package/dist/tools/instagram/get-audience-demographics.js +58 -0
  59. package/dist/tools/instagram/get-media-insights.d.ts +29 -0
  60. package/dist/tools/instagram/get-media-insights.js +49 -0
  61. package/dist/tools/instagram/list-accounts.d.ts +33 -0
  62. package/dist/tools/instagram/list-accounts.js +63 -0
  63. package/dist/tools/instagram/list-media.d.ts +41 -0
  64. package/dist/tools/instagram/list-media.js +42 -0
  65. package/dist/tools/meta/graph-read.d.ts +33 -0
  66. package/dist/tools/meta/graph-read.js +71 -0
  67. package/dist/tools/overview/business-overview.d.ts +49 -0
  68. package/dist/tools/overview/business-overview.js +235 -0
  69. package/dist/tools/overview/content-report.d.ts +57 -0
  70. package/dist/tools/overview/content-report.js +344 -0
  71. package/dist/tools/overview/latest-posts-summary.d.ts +41 -0
  72. package/dist/tools/overview/latest-posts-summary.js +189 -0
  73. package/dist/tools/pages/get-insights.d.ts +41 -0
  74. package/dist/tools/pages/get-insights.js +49 -0
  75. package/dist/tools/pages/get-post-insights.d.ts +33 -0
  76. package/dist/tools/pages/get-post-insights.js +47 -0
  77. package/dist/tools/pages/get.d.ts +29 -0
  78. package/dist/tools/pages/get.js +50 -0
  79. package/dist/tools/pages/list-posts.d.ts +53 -0
  80. package/dist/tools/pages/list-posts.js +62 -0
  81. package/dist/tools/pages/list-reviews.d.ts +41 -0
  82. package/dist/tools/pages/list-reviews.js +37 -0
  83. package/dist/tools/pages/list-videos.d.ts +41 -0
  84. package/dist/tools/pages/list-videos.js +40 -0
  85. package/dist/tools/pages/list.d.ts +41 -0
  86. package/dist/tools/pages/list.js +39 -0
  87. package/dist/tools/pixels/get-stats.d.ts +41 -0
  88. package/dist/tools/pixels/get-stats.js +34 -0
  89. package/dist/tools/pixels/list.d.ts +41 -0
  90. package/dist/tools/pixels/list.js +41 -0
  91. package/dist/tools/register.d.ts +3 -0
  92. package/dist/tools/register.js +95 -0
  93. package/dist/tools/shared.d.ts +45 -0
  94. package/dist/tools/shared.js +137 -0
  95. package/dist/tools/token/health.d.ts +17 -0
  96. package/dist/tools/token/health.js +65 -0
  97. package/dist/tools/token/inspect.d.ts +26 -0
  98. package/dist/tools/token/inspect.js +88 -0
  99. package/dist/tools/whatsapp/get-analytics.d.ts +57 -0
  100. package/dist/tools/whatsapp/get-analytics.js +66 -0
  101. package/dist/tools/whatsapp/list-phone-numbers.d.ts +41 -0
  102. package/dist/tools/whatsapp/list-phone-numbers.js +35 -0
  103. package/dist/tools/whatsapp/list-templates.d.ts +45 -0
  104. package/dist/tools/whatsapp/list-templates.js +44 -0
  105. package/dist/tools/whatsapp/list-wabas.d.ts +54 -0
  106. package/dist/tools/whatsapp/list-wabas.js +48 -0
  107. package/dist/types/meta.d.ts +46 -0
  108. package/dist/types/meta.js +1 -0
  109. package/package.json +77 -0
@@ -0,0 +1,49 @@
1
+ import { z } from "zod";
2
+ import { assertAllowed } from "../../config.js";
3
+ import { metaIdSchema } from "../../helpers/schema.js";
4
+ import { runGetAsPageViaInsightsApp } from "../shared.js";
5
+ const PERIOD = z.enum(["day", "week", "days_28", "lifetime", "total_over_range"]);
6
+ export const inputSchema = z
7
+ .object({
8
+ page_id: metaIdSchema,
9
+ metrics: z
10
+ .array(z.string())
11
+ .default([
12
+ // Metrics that Meta still supports as of v23 (2026).
13
+ // Several 2023/2024 deprecations removed: page_consumptions, page_fan_removes,
14
+ // page_actions_post_reactions_total, page_impressions_organic (use unique/paid combo instead).
15
+ "page_impressions",
16
+ "page_impressions_unique",
17
+ "page_impressions_paid",
18
+ "page_post_engagements",
19
+ "page_fans",
20
+ "page_fan_adds",
21
+ "page_views_total",
22
+ "page_video_views",
23
+ "page_video_views_paid",
24
+ ])
25
+ .describe("Page insight metrics. Not every metric supports every period — see https://developers.facebook.com/docs/graph-api/reference/v23.0/insights. Requires 'read_insights' scope."),
26
+ period: PERIOD.default("day"),
27
+ since: z.string().optional().describe("ISO date or Unix timestamp."),
28
+ until: z.string().optional().describe("ISO date or Unix timestamp."),
29
+ })
30
+ .strict();
31
+ export const definition = {
32
+ name: "meta_page_get_insights",
33
+ title: "Get Page-level insights",
34
+ description: `Reads Page-level metrics: impressions, reach, engagements, fan growth, page views, video views. Requires 'read_insights' scope. Pick the right period per metric — many accept only 'day' or 'days_28'.`,
35
+ inputSchema: inputSchema.shape,
36
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
37
+ };
38
+ export async function handler(input, ctx) {
39
+ assertAllowed("page", input.page_id, ctx.config);
40
+ return runGetAsPageViaInsightsApp(ctx, input.page_id, {
41
+ path: `${input.page_id}/insights`,
42
+ params: {
43
+ metric: input.metrics.join(","),
44
+ period: input.period,
45
+ since: input.since,
46
+ until: input.until,
47
+ },
48
+ });
49
+ }
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import type { ToolContext } from "../../context.js";
3
+ export declare const inputSchema: z.ZodObject<{
4
+ post_id: z.ZodString;
5
+ page_id: z.ZodOptional<z.ZodString>;
6
+ metrics: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
7
+ }, "strict", z.ZodTypeAny, {
8
+ post_id: string;
9
+ metrics: string[];
10
+ page_id?: string | undefined;
11
+ }, {
12
+ post_id: string;
13
+ page_id?: string | undefined;
14
+ metrics?: string[] | undefined;
15
+ }>;
16
+ export type Input = z.infer<typeof inputSchema>;
17
+ export declare const definition: {
18
+ readonly name: "meta_page_get_post_insights";
19
+ readonly title: "Get insights for a single Page post";
20
+ readonly description: "Reads impressions, unique reach, paid vs. organic split, engaged users, click counts, reactions-by-type, and video view metrics for a single post.\n\nUses the parent Page's access token (auto-resolved from the '{page_id}_{post_id}' prefix; pass page_id explicitly if your post_id isn't in that form). Requires the system user to be assigned to the Page with 'View performance' or 'Analyze Page' tasks, plus 'read_insights' scope on the token.";
21
+ readonly inputSchema: {
22
+ post_id: z.ZodString;
23
+ page_id: z.ZodOptional<z.ZodString>;
24
+ metrics: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
25
+ };
26
+ readonly annotations: {
27
+ readonly readOnlyHint: true;
28
+ readonly destructiveHint: false;
29
+ readonly idempotentHint: true;
30
+ readonly openWorldHint: true;
31
+ };
32
+ };
33
+ export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
@@ -0,0 +1,47 @@
1
+ import { z } from "zod";
2
+ import { metaIdSchema } from "../../helpers/schema.js";
3
+ import { errorResult, runGetAsPageViaInsightsApp } from "../shared.js";
4
+ export const inputSchema = z
5
+ .object({
6
+ post_id: metaIdSchema.describe("Post ID. Meta uses the '{page_id}_{post_id}' format — pass it in full so the server can resolve the parent Page's access token automatically."),
7
+ page_id: metaIdSchema
8
+ .optional()
9
+ .describe("Optional explicit Page ID. Use when the post_id is not in the '{page_id}_{post_id}' form (rare)."),
10
+ metrics: z
11
+ .array(z.string())
12
+ .default([
13
+ "post_impressions",
14
+ "post_impressions_unique",
15
+ "post_impressions_paid",
16
+ "post_impressions_organic",
17
+ "post_engaged_users",
18
+ "post_clicks",
19
+ "post_reactions_by_type_total",
20
+ "post_video_views",
21
+ "post_video_views_unique",
22
+ "post_video_avg_time_watched",
23
+ ])
24
+ .describe("Post-level insight metrics. See https://developers.facebook.com/docs/graph-api/reference/v23.0/insights. Requires 'read_insights' scope. Note: Meta will reject the call if any single metric is invalid for the post type — narrow the list if you see (#100)."),
25
+ })
26
+ .strict();
27
+ export const definition = {
28
+ name: "meta_page_get_post_insights",
29
+ title: "Get insights for a single Page post",
30
+ description: `Reads impressions, unique reach, paid vs. organic split, engaged users, click counts, reactions-by-type, and video view metrics for a single post.
31
+
32
+ Uses the parent Page's access token (auto-resolved from the '{page_id}_{post_id}' prefix; pass page_id explicitly if your post_id isn't in that form). Requires the system user to be assigned to the Page with 'View performance' or 'Analyze Page' tasks, plus 'read_insights' scope on the token.`,
33
+ inputSchema: inputSchema.shape,
34
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
35
+ };
36
+ export async function handler(input, ctx) {
37
+ // Resolve the parent Page id either from an explicit input or from the
38
+ // '{page_id}_{post_id}' prefix of the post_id.
39
+ const parentPageId = input.page_id ?? input.post_id.split("_")[0];
40
+ if (!/^\d+$/.test(parentPageId)) {
41
+ return errorResult(new Error(`Could not infer parent Page ID from post_id '${input.post_id}'. Pass page_id explicitly.`));
42
+ }
43
+ return runGetAsPageViaInsightsApp(ctx, parentPageId, {
44
+ path: `${input.post_id}/insights`,
45
+ params: { metric: input.metrics.join(",") },
46
+ });
47
+ }
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ import type { ToolContext } from "../../context.js";
3
+ export declare const inputSchema: z.ZodObject<{
4
+ page_id: z.ZodString;
5
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
6
+ }, "strict", z.ZodTypeAny, {
7
+ fields: string[];
8
+ page_id: string;
9
+ }, {
10
+ page_id: string;
11
+ fields?: string[] | undefined;
12
+ }>;
13
+ export type Input = z.infer<typeof inputSchema>;
14
+ export declare const definition: {
15
+ readonly name: "meta_page_get";
16
+ readonly title: "Get Page details";
17
+ readonly description: "Full page profile snapshot: category, about, fan count, rating, engagement, linked IG Business account, cover/picture. Use as the 'know-your-page' call before fetching posts or insights.";
18
+ readonly inputSchema: {
19
+ page_id: z.ZodString;
20
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
21
+ };
22
+ readonly annotations: {
23
+ readonly readOnlyHint: true;
24
+ readonly destructiveHint: false;
25
+ readonly idempotentHint: true;
26
+ readonly openWorldHint: true;
27
+ };
28
+ };
29
+ export declare function handler(input: Input, ctx: ToolContext): Promise<import("../../helpers/format.js").ToolTextResult>;
@@ -0,0 +1,50 @@
1
+ import { z } from "zod";
2
+ import { assertAllowed } from "../../config.js";
3
+ import { metaIdSchema } from "../../helpers/schema.js";
4
+ import { runGet } from "../shared.js";
5
+ export const inputSchema = z
6
+ .object({
7
+ page_id: metaIdSchema,
8
+ fields: z
9
+ .array(z.string())
10
+ .default([
11
+ "id",
12
+ "name",
13
+ "username",
14
+ "category",
15
+ "category_list",
16
+ "about",
17
+ "description",
18
+ "fan_count",
19
+ "followers_count",
20
+ "verification_status",
21
+ "rating_count",
22
+ "overall_star_rating",
23
+ "link",
24
+ "website",
25
+ "phone",
26
+ "emails",
27
+ "location",
28
+ "single_line_address",
29
+ "engagement",
30
+ "talking_about_count",
31
+ "were_here_count",
32
+ "checkins",
33
+ "cover",
34
+ "picture.type(large)",
35
+ "instagram_business_account{id,username,name}",
36
+ ])
37
+ .describe("Page fields. Includes linked Instagram Business account when present."),
38
+ })
39
+ .strict();
40
+ export const definition = {
41
+ name: "meta_page_get",
42
+ title: "Get Page details",
43
+ description: `Full page profile snapshot: category, about, fan count, rating, engagement, linked IG Business account, cover/picture. Use as the 'know-your-page' call before fetching posts or insights.`,
44
+ inputSchema: inputSchema.shape,
45
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
46
+ };
47
+ export async function handler(input, ctx) {
48
+ assertAllowed("page", input.page_id, ctx.config);
49
+ return runGet(ctx, { path: input.page_id, params: { fields: input.fields.join(",") } });
50
+ }
@@ -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
+ page_id: z.ZodString;
8
+ edge: z.ZodDefault<z.ZodEnum<["posts", "published_posts", "feed"]>>;
9
+ since: z.ZodOptional<z.ZodString>;
10
+ until: z.ZodOptional<z.ZodString>;
11
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
12
+ }, "strict", z.ZodTypeAny, {
13
+ fields: string[];
14
+ page_id: string;
15
+ limit: number;
16
+ auto_paginate: boolean;
17
+ edge: "posts" | "published_posts" | "feed";
18
+ since?: string | undefined;
19
+ until?: string | undefined;
20
+ after?: string | undefined;
21
+ }, {
22
+ page_id: string;
23
+ fields?: string[] | undefined;
24
+ since?: string | undefined;
25
+ until?: string | undefined;
26
+ limit?: number | undefined;
27
+ after?: string | undefined;
28
+ auto_paginate?: boolean | undefined;
29
+ edge?: "posts" | "published_posts" | "feed" | undefined;
30
+ }>;
31
+ export type Input = z.infer<typeof inputSchema>;
32
+ export declare const definition: {
33
+ readonly name: "meta_page_list_posts";
34
+ readonly title: "List Page posts";
35
+ readonly description: "Lists raw Facebook Page posts for ONE page, with reaction/comment/share counts. Supports since/until for a date window and returns post IDs for meta_page_get_post_insights.\n\nUSE FOR: drilling into a single specific Page's post list, or when you already have the page_id. For a cross-account content report (\"how many posts this week across all my accounts, by type, with comparison\") prefer meta_content_report — it walks every Page + Instagram account and classifies/aggregates automatically, no page_id needed.";
36
+ readonly inputSchema: {
37
+ limit: z.ZodDefault<z.ZodNumber>;
38
+ after: z.ZodOptional<z.ZodString>;
39
+ auto_paginate: z.ZodDefault<z.ZodBoolean>;
40
+ page_id: z.ZodString;
41
+ edge: z.ZodDefault<z.ZodEnum<["posts", "published_posts", "feed"]>>;
42
+ since: z.ZodOptional<z.ZodString>;
43
+ until: z.ZodOptional<z.ZodString>;
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,62 @@
1
+ import { z } from "zod";
2
+ import { assertAllowed } from "../../config.js";
3
+ import { metaIdSchema, paginationShape } from "../../helpers/schema.js";
4
+ import { runListAsPage } from "../shared.js";
5
+ export const inputSchema = z
6
+ .object({
7
+ page_id: metaIdSchema,
8
+ edge: z
9
+ .enum(["posts", "published_posts", "feed"])
10
+ .default("published_posts")
11
+ .describe("'published_posts' is the standard edge. 'feed' includes user-posted items too."),
12
+ since: z.string().optional().describe("Unix timestamp or ISO date lower bound."),
13
+ until: z.string().optional().describe("Unix timestamp or ISO date upper bound."),
14
+ fields: z
15
+ .array(z.string())
16
+ .default([
17
+ // Note: 'subattachments' is deprecated as of Graph API v3.3+ for
18
+ // aggregate field expansion (#12 deprecate_post_aggregated_fields_for_attachement).
19
+ // Removed from default. Likewise 'is_published' and 'type' are
20
+ // deprecated for some post kinds — kept out of the default to keep
21
+ // the call shape valid across all post types. Re-add via the fields
22
+ // input if you need them and have verified the call still passes.
23
+ "id",
24
+ "message",
25
+ "created_time",
26
+ "updated_time",
27
+ "permalink_url",
28
+ "status_type",
29
+ "from",
30
+ "attachments{media_type,title,url}",
31
+ "reactions.summary(true).limit(0)",
32
+ "shares",
33
+ "comments.summary(true).limit(0)",
34
+ ])
35
+ .describe("Post fields. Default includes reaction + comment counts via summary. 'subattachments', 'is_published' and 'type' are excluded by default — Meta deprecated them on certain post types and including them rejects the whole call."),
36
+ ...paginationShape,
37
+ })
38
+ .strict();
39
+ export const definition = {
40
+ name: "meta_page_list_posts",
41
+ title: "List Page posts",
42
+ description: `Lists raw Facebook Page posts for ONE page, with reaction/comment/share counts. Supports since/until for a date window and returns post IDs for meta_page_get_post_insights.
43
+
44
+ USE FOR: drilling into a single specific Page's post list, or when you already have the page_id. For a cross-account content report ("how many posts this week across all my accounts, by type, with comparison") prefer meta_content_report — it walks every Page + Instagram account and classifies/aggregates automatically, no page_id needed.`,
45
+ inputSchema: inputSchema.shape,
46
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
47
+ };
48
+ export async function handler(input, ctx) {
49
+ assertAllowed("page", input.page_id, ctx.config);
50
+ // Page-level edges (/posts, /published_posts, /feed) require a Page access
51
+ // token, not the system-user token. runListAsPage resolves it first.
52
+ return runListAsPage(ctx, input.page_id, {
53
+ path: `${input.page_id}/${input.edge}`,
54
+ params: {
55
+ fields: input.fields.join(","),
56
+ limit: input.limit,
57
+ after: input.after,
58
+ since: input.since,
59
+ until: input.until,
60
+ },
61
+ }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { page_id: input.page_id, edge: input.edge });
62
+ }
@@ -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
+ page_id: z.ZodString;
8
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
9
+ }, "strict", z.ZodTypeAny, {
10
+ fields: string[];
11
+ page_id: string;
12
+ limit: number;
13
+ auto_paginate: boolean;
14
+ after?: string | undefined;
15
+ }, {
16
+ page_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_page_list_reviews";
25
+ readonly title: "List Page ratings / reviews";
26
+ readonly description: "Lists ratings and reviews (where the Page supports recommendations). Requires 'pages_read_user_content' scope. Useful for sentiment analysis and customer-experience reporting.";
27
+ readonly inputSchema: {
28
+ limit: z.ZodDefault<z.ZodNumber>;
29
+ after: z.ZodOptional<z.ZodString>;
30
+ auto_paginate: z.ZodDefault<z.ZodBoolean>;
31
+ page_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,37 @@
1
+ import { z } from "zod";
2
+ import { assertAllowed } from "../../config.js";
3
+ import { metaIdSchema, paginationShape } from "../../helpers/schema.js";
4
+ import { runListAsPage } from "../shared.js";
5
+ export const inputSchema = z
6
+ .object({
7
+ page_id: metaIdSchema,
8
+ fields: z
9
+ .array(z.string())
10
+ .default([
11
+ "created_time",
12
+ "reviewer",
13
+ "rating",
14
+ "recommendation_type",
15
+ "review_text",
16
+ "has_rating",
17
+ "has_review",
18
+ "open_graph_story",
19
+ ])
20
+ .describe("Review fields."),
21
+ ...paginationShape,
22
+ })
23
+ .strict();
24
+ export const definition = {
25
+ name: "meta_page_list_reviews",
26
+ title: "List Page ratings / reviews",
27
+ description: `Lists ratings and reviews (where the Page supports recommendations). Requires 'pages_read_user_content' scope. Useful for sentiment analysis and customer-experience reporting.`,
28
+ inputSchema: inputSchema.shape,
29
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
30
+ };
31
+ export async function handler(input, ctx) {
32
+ assertAllowed("page", input.page_id, ctx.config);
33
+ return runListAsPage(ctx, input.page_id, {
34
+ path: `${input.page_id}/ratings`,
35
+ params: { fields: input.fields.join(","), limit: input.limit, after: input.after },
36
+ }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { page_id: input.page_id });
37
+ }
@@ -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
+ page_id: z.ZodString;
8
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
9
+ }, "strict", z.ZodTypeAny, {
10
+ fields: string[];
11
+ page_id: string;
12
+ limit: number;
13
+ auto_paginate: boolean;
14
+ after?: string | undefined;
15
+ }, {
16
+ page_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_page_list_videos";
25
+ readonly title: "List Page videos";
26
+ readonly description: "Lists videos uploaded to a Page (including live broadcasts). Pair with meta_page_get_post_insights on the owning post for video-view analytics, or drill into individual video IDs for per-video metrics.";
27
+ readonly inputSchema: {
28
+ limit: z.ZodDefault<z.ZodNumber>;
29
+ after: z.ZodOptional<z.ZodString>;
30
+ auto_paginate: z.ZodDefault<z.ZodBoolean>;
31
+ page_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,40 @@
1
+ import { z } from "zod";
2
+ import { assertAllowed } from "../../config.js";
3
+ import { metaIdSchema, paginationShape } from "../../helpers/schema.js";
4
+ import { runListAsPage } from "../shared.js";
5
+ export const inputSchema = z
6
+ .object({
7
+ page_id: metaIdSchema,
8
+ fields: z
9
+ .array(z.string())
10
+ .default([
11
+ "id",
12
+ "title",
13
+ "description",
14
+ "created_time",
15
+ "updated_time",
16
+ "length",
17
+ "permalink_url",
18
+ "source",
19
+ "status",
20
+ "views",
21
+ "live_status",
22
+ ])
23
+ .describe("Video fields."),
24
+ ...paginationShape,
25
+ })
26
+ .strict();
27
+ export const definition = {
28
+ name: "meta_page_list_videos",
29
+ title: "List Page videos",
30
+ description: `Lists videos uploaded to a Page (including live broadcasts). Pair with meta_page_get_post_insights on the owning post for video-view analytics, or drill into individual video IDs for per-video metrics.`,
31
+ inputSchema: inputSchema.shape,
32
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
33
+ };
34
+ export async function handler(input, ctx) {
35
+ assertAllowed("page", input.page_id, ctx.config);
36
+ return runListAsPage(ctx, input.page_id, {
37
+ path: `${input.page_id}/videos`,
38
+ params: { fields: input.fields.join(","), limit: input.limit, after: input.after },
39
+ }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { page_id: input.page_id });
40
+ }
@@ -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
+ source: z.ZodDefault<z.ZodEnum<["assigned", "accounts"]>>;
8
+ fields: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
9
+ }, "strict", z.ZodTypeAny, {
10
+ fields: string[];
11
+ limit: number;
12
+ auto_paginate: boolean;
13
+ source: "assigned" | "accounts";
14
+ after?: string | undefined;
15
+ }, {
16
+ fields?: string[] | undefined;
17
+ limit?: number | undefined;
18
+ after?: string | undefined;
19
+ auto_paginate?: boolean | undefined;
20
+ source?: "assigned" | "accounts" | undefined;
21
+ }>;
22
+ export type Input = z.infer<typeof inputSchema>;
23
+ export declare const definition: {
24
+ readonly name: "meta_page_list";
25
+ readonly title: "List Pages visible to the token";
26
+ readonly description: "Lists Facebook Pages this token/system-user can read. 'assigned' is the modern path for system users; 'accounts' is the classic /me/accounts edge (works for regular users).";
27
+ readonly inputSchema: {
28
+ limit: z.ZodDefault<z.ZodNumber>;
29
+ after: z.ZodOptional<z.ZodString>;
30
+ auto_paginate: z.ZodDefault<z.ZodBoolean>;
31
+ source: z.ZodDefault<z.ZodEnum<["assigned", "accounts"]>>;
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,39 @@
1
+ import { z } from "zod";
2
+ import { paginationShape } from "../../helpers/schema.js";
3
+ import { runList } from "../shared.js";
4
+ export const inputSchema = z
5
+ .object({
6
+ source: z
7
+ .enum(["assigned", "accounts"])
8
+ .default("assigned")
9
+ .describe("'assigned' → /me/assigned_pages (system-user-specific). 'accounts' → /me/accounts (classic Pages edge)."),
10
+ fields: z
11
+ .array(z.string())
12
+ .default([
13
+ "id",
14
+ "name",
15
+ "category",
16
+ "category_list",
17
+ "about",
18
+ "fan_count",
19
+ "followers_count",
20
+ "verification_status",
21
+ "link",
22
+ "website",
23
+ "tasks",
24
+ ])
25
+ .describe("Page fields."),
26
+ ...paginationShape,
27
+ })
28
+ .strict();
29
+ export const definition = {
30
+ name: "meta_page_list",
31
+ title: "List Pages visible to the token",
32
+ description: `Lists Facebook Pages this token/system-user can read. 'assigned' is the modern path for system users; 'accounts' is the classic /me/accounts edge (works for regular users).`,
33
+ inputSchema: inputSchema.shape,
34
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
35
+ };
36
+ export async function handler(input, ctx) {
37
+ const path = input.source === "assigned" ? "me/assigned_pages" : "me/accounts";
38
+ return runList(ctx, { path, params: { fields: input.fields.join(","), limit: input.limit, after: input.after } }, { auto_paginate: input.auto_paginate, after: input.after, limit: input.limit }, { source: input.source });
39
+ }
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ import type { ToolContext } from "../../context.js";
3
+ export declare const inputSchema: z.ZodObject<{
4
+ pixel_id: z.ZodString;
5
+ aggregation: z.ZodDefault<z.ZodEnum<["event", "browser_type", "device_os", "event_source", "url"]>>;
6
+ start_time: z.ZodOptional<z.ZodString>;
7
+ end_time: z.ZodOptional<z.ZodString>;
8
+ event: z.ZodOptional<z.ZodString>;
9
+ }, "strict", z.ZodTypeAny, {
10
+ pixel_id: string;
11
+ aggregation: "url" | "event" | "browser_type" | "device_os" | "event_source";
12
+ start_time?: string | undefined;
13
+ end_time?: string | undefined;
14
+ event?: string | undefined;
15
+ }, {
16
+ pixel_id: string;
17
+ start_time?: string | undefined;
18
+ end_time?: string | undefined;
19
+ event?: string | undefined;
20
+ aggregation?: "url" | "event" | "browser_type" | "device_os" | "event_source" | undefined;
21
+ }>;
22
+ export type Input = z.infer<typeof inputSchema>;
23
+ export declare const definition: {
24
+ readonly name: "meta_pixel_get_stats";
25
+ readonly title: "Get pixel event stats";
26
+ readonly description: "Reads aggregated pixel event counts via /{pixel_id}/stats. Use aggregation='event' to see which events are firing, 'device_os' or 'browser_type' to profile traffic, 'url' to see top-firing pages. Useful for spotting CAPI drop-off versus browser events.";
27
+ readonly inputSchema: {
28
+ pixel_id: z.ZodString;
29
+ aggregation: z.ZodDefault<z.ZodEnum<["event", "browser_type", "device_os", "event_source", "url"]>>;
30
+ start_time: z.ZodOptional<z.ZodString>;
31
+ end_time: z.ZodOptional<z.ZodString>;
32
+ event: z.ZodOptional<z.ZodString>;
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,34 @@
1
+ import { z } from "zod";
2
+ import { metaIdSchema } from "../../helpers/schema.js";
3
+ import { runGet } from "../shared.js";
4
+ const AGGREGATION = z.enum(["event", "browser_type", "device_os", "event_source", "url"]);
5
+ export const inputSchema = z
6
+ .object({
7
+ pixel_id: metaIdSchema,
8
+ aggregation: AGGREGATION.default("event").describe("How to slice the stats."),
9
+ start_time: z.string().optional().describe("ISO date / Unix timestamp — start of window."),
10
+ end_time: z.string().optional().describe("ISO date / Unix timestamp — end of window."),
11
+ event: z
12
+ .string()
13
+ .optional()
14
+ .describe("Filter to one event name, e.g. 'Purchase', 'AddToCart'."),
15
+ })
16
+ .strict();
17
+ export const definition = {
18
+ name: "meta_pixel_get_stats",
19
+ title: "Get pixel event stats",
20
+ description: `Reads aggregated pixel event counts via /{pixel_id}/stats. Use aggregation='event' to see which events are firing, 'device_os' or 'browser_type' to profile traffic, 'url' to see top-firing pages. Useful for spotting CAPI drop-off versus browser events.`,
21
+ inputSchema: inputSchema.shape,
22
+ annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true },
23
+ };
24
+ export async function handler(input, ctx) {
25
+ return runGet(ctx, {
26
+ path: `${input.pixel_id}/stats`,
27
+ params: {
28
+ aggregation: input.aggregation,
29
+ start_time: input.start_time,
30
+ end_time: input.end_time,
31
+ event: input.event,
32
+ },
33
+ });
34
+ }