@praise25/meta-mcp-server 0.1.7 → 0.1.8
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/dist/constants.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const CHARACTER_LIMIT = 25000;
|
|
|
4
4
|
export declare const DEFAULT_PAGE_LIMIT = 25;
|
|
5
5
|
export declare const MAX_PAGE_LIMIT = 500;
|
|
6
6
|
export declare const SERVER_NAME = "meta-business-manager-mcp-server";
|
|
7
|
-
export declare const SERVER_VERSION = "0.1.
|
|
7
|
+
export declare const SERVER_VERSION = "0.1.8";
|
|
8
8
|
export declare const META_ERROR_CODES: {
|
|
9
9
|
readonly UNKNOWN: 1;
|
|
10
10
|
readonly SERVICE_TEMPORARILY_UNAVAILABLE: 2;
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,7 @@ export const CHARACTER_LIMIT = 25_000;
|
|
|
4
4
|
export const DEFAULT_PAGE_LIMIT = 25;
|
|
5
5
|
export const MAX_PAGE_LIMIT = 500;
|
|
6
6
|
export const SERVER_NAME = "meta-business-manager-mcp-server";
|
|
7
|
-
export const SERVER_VERSION = "0.1.
|
|
7
|
+
export const SERVER_VERSION = "0.1.8";
|
|
8
8
|
export const META_ERROR_CODES = {
|
|
9
9
|
UNKNOWN: 1,
|
|
10
10
|
SERVICE_TEMPORARILY_UNAVAILABLE: 2,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { ToolContext } from "../../context.js";
|
|
3
3
|
export declare const inputSchema: z.ZodObject<{
|
|
4
|
-
business_id: z.ZodString
|
|
4
|
+
business_id: z.ZodOptional<z.ZodString>;
|
|
5
5
|
date_preset: z.ZodDefault<z.ZodEnum<["today", "yesterday", "this_month", "last_month", "this_quarter", "maximum", "last_3d", "last_7d", "last_14d", "last_28d", "last_30d", "last_90d", "last_week_mon_sun", "last_week_sun_sat", "last_quarter", "last_year", "this_week_mon_today", "this_week_sun_today", "this_year"]>>;
|
|
6
6
|
include_pixels: z.ZodDefault<z.ZodBoolean>;
|
|
7
7
|
include_catalogs: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -9,15 +9,15 @@ export declare const inputSchema: z.ZodObject<{
|
|
|
9
9
|
max_ad_accounts: z.ZodDefault<z.ZodNumber>;
|
|
10
10
|
max_pages: z.ZodDefault<z.ZodNumber>;
|
|
11
11
|
}, "strict", z.ZodTypeAny, {
|
|
12
|
-
business_id: string;
|
|
13
12
|
date_preset: "today" | "yesterday" | "this_month" | "last_month" | "this_quarter" | "maximum" | "last_3d" | "last_7d" | "last_14d" | "last_28d" | "last_30d" | "last_90d" | "last_week_mon_sun" | "last_week_sun_sat" | "last_quarter" | "last_year" | "this_week_mon_today" | "this_week_sun_today" | "this_year";
|
|
14
13
|
include_pixels: boolean;
|
|
15
14
|
include_catalogs: boolean;
|
|
16
15
|
include_whatsapp: boolean;
|
|
17
16
|
max_ad_accounts: number;
|
|
18
17
|
max_pages: number;
|
|
18
|
+
business_id?: string | undefined;
|
|
19
19
|
}, {
|
|
20
|
-
business_id
|
|
20
|
+
business_id?: string | undefined;
|
|
21
21
|
date_preset?: "today" | "yesterday" | "this_month" | "last_month" | "this_quarter" | "maximum" | "last_3d" | "last_7d" | "last_14d" | "last_28d" | "last_30d" | "last_90d" | "last_week_mon_sun" | "last_week_sun_sat" | "last_quarter" | "last_year" | "this_week_mon_today" | "this_week_sun_today" | "this_year" | undefined;
|
|
22
22
|
include_pixels?: boolean | undefined;
|
|
23
23
|
include_catalogs?: boolean | undefined;
|
|
@@ -31,7 +31,7 @@ export declare const definition: {
|
|
|
31
31
|
readonly title: "Eagle's-eye snapshot of a business";
|
|
32
32
|
readonly description: "One-call consolidated read across the whole Meta surface for a business:\n\n- Identity (system user + token app)\n- Assigned Pages + each Page's high-level insights (impressions, engagement, fans) for the requested window\n- Instagram Business accounts linked to those Pages (followers, media_count)\n- Owned + client ad accounts with balance, spend cap, amount spent, and last-window insights (spend, impressions, clicks, CTR, CPC, reach)\n- Pixels with last_fired_time (if include_pixels)\n- Catalogs with product counts (if include_catalogs)\n- WhatsApp Business Accounts + phone numbers (if include_whatsapp)\n\nEach section has its own error isolation — one failing asset does not kill the report. Ideal as the opening call for any AI-driven marketing insights conversation.";
|
|
33
33
|
readonly inputSchema: {
|
|
34
|
-
business_id: z.ZodString
|
|
34
|
+
business_id: z.ZodOptional<z.ZodString>;
|
|
35
35
|
date_preset: z.ZodDefault<z.ZodEnum<["today", "yesterday", "this_month", "last_month", "this_quarter", "maximum", "last_3d", "last_7d", "last_14d", "last_28d", "last_30d", "last_90d", "last_week_mon_sun", "last_week_sun_sat", "last_quarter", "last_year", "this_week_mon_today", "this_week_sun_today", "this_year"]>>;
|
|
36
36
|
include_pixels: z.ZodDefault<z.ZodBoolean>;
|
|
37
37
|
include_catalogs: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -5,7 +5,9 @@ import { jsonBlock, toolResult } from "../../helpers/format.js";
|
|
|
5
5
|
import { datePresetSchema, metaIdSchema } from "../../helpers/schema.js";
|
|
6
6
|
export const inputSchema = z
|
|
7
7
|
.object({
|
|
8
|
-
business_id: metaIdSchema
|
|
8
|
+
business_id: metaIdSchema
|
|
9
|
+
.optional()
|
|
10
|
+
.describe("Business Manager ID. **Optional** — if omitted, the server auto-discovers via `META_ALLOWED_BUSINESS_IDS[0]` (if configured) or the first business returned by `/me/businesses`. Always prefer omitting this if you don't have the exact ID — do not guess a placeholder integer."),
|
|
9
11
|
date_preset: datePresetSchema
|
|
10
12
|
.default("last_30d")
|
|
11
13
|
.describe("Date window used for ad account and page insights snapshots."),
|
|
@@ -41,8 +43,43 @@ function fail(err) {
|
|
|
41
43
|
return { ok: false, error: e.message, hint: e.hint };
|
|
42
44
|
}
|
|
43
45
|
export async function handler(input, ctx) {
|
|
44
|
-
assertAllowed("business", input.business_id, ctx.config);
|
|
45
46
|
const started = Date.now();
|
|
47
|
+
// Auto-discover business_id if not provided. Prefer the configured allowlist
|
|
48
|
+
// (deployment intent), fall back to /me/businesses. This makes the tool
|
|
49
|
+
// safe to call with no args — defeats AI-hallucinated-id failure modes.
|
|
50
|
+
let businessId = input.business_id;
|
|
51
|
+
let businessIdSource = "input";
|
|
52
|
+
if (!businessId) {
|
|
53
|
+
const allowed = ctx.config.allowedBusinessIds;
|
|
54
|
+
if (allowed && allowed.size > 0) {
|
|
55
|
+
businessId = allowed.values().next().value;
|
|
56
|
+
businessIdSource = "allowlist";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
try {
|
|
60
|
+
const list = await ctx.graph.get({
|
|
61
|
+
path: "me/businesses",
|
|
62
|
+
params: { fields: "id,name", limit: 1 },
|
|
63
|
+
});
|
|
64
|
+
const first = list.data?.[0];
|
|
65
|
+
if (first?.id) {
|
|
66
|
+
businessId = first.id;
|
|
67
|
+
businessIdSource = "discovered";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
/* fall through — businessId remains undefined and structured response will surface the gap */
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (!businessId) {
|
|
76
|
+
return toolResult({
|
|
77
|
+
error: "no_business_id",
|
|
78
|
+
hint: "Could not determine business_id. Configure META_ALLOWED_BUSINESS_IDS in the server's environment, or pass business_id explicitly. /me/businesses returned no results for the configured token (this is normal for system-user tokens — they don't list businesses via that edge).",
|
|
79
|
+
suggestion: "Pass business_id directly. To discover it, an operator should run `meta_business_list_assets business_id=<known>` once with a known ID, or look up the business in Business Settings → Business Info.",
|
|
80
|
+
}, "{}");
|
|
81
|
+
}
|
|
82
|
+
assertAllowed("business", businessId, ctx.config);
|
|
46
83
|
const token = ctx.graph.get({
|
|
47
84
|
path: "debug_token",
|
|
48
85
|
params: { input_token: ctx.config.accessToken },
|
|
@@ -60,14 +97,14 @@ export async function handler(input, ctx) {
|
|
|
60
97
|
.catch(fail);
|
|
61
98
|
const ownedAds = ctx.graph
|
|
62
99
|
.get({
|
|
63
|
-
path: `${
|
|
100
|
+
path: `${businessId}/owned_ad_accounts`,
|
|
64
101
|
params: { fields: "id,account_id,name,currency,account_status,amount_spent,balance,spend_cap", limit: input.max_ad_accounts },
|
|
65
102
|
})
|
|
66
103
|
.then(ok)
|
|
67
104
|
.catch(fail);
|
|
68
105
|
const clientAds = ctx.graph
|
|
69
106
|
.get({
|
|
70
|
-
path: `${
|
|
107
|
+
path: `${businessId}/client_ad_accounts`,
|
|
71
108
|
params: { fields: "id,account_id,name,currency,account_status", limit: input.max_ad_accounts },
|
|
72
109
|
})
|
|
73
110
|
.then(ok)
|
|
@@ -75,7 +112,7 @@ export async function handler(input, ctx) {
|
|
|
75
112
|
const pixels = input.include_pixels
|
|
76
113
|
? ctx.graph
|
|
77
114
|
.get({
|
|
78
|
-
path: `${
|
|
115
|
+
path: `${businessId}/owned_pixels`,
|
|
79
116
|
params: { fields: "id,name,last_fired_time,is_unavailable", limit: 25 },
|
|
80
117
|
})
|
|
81
118
|
.then(ok)
|
|
@@ -84,7 +121,7 @@ export async function handler(input, ctx) {
|
|
|
84
121
|
const catalogs = input.include_catalogs
|
|
85
122
|
? ctx.graph
|
|
86
123
|
.get({
|
|
87
|
-
path: `${
|
|
124
|
+
path: `${businessId}/owned_product_catalogs`,
|
|
88
125
|
params: { fields: "id,name,vertical,product_count", limit: 25 },
|
|
89
126
|
})
|
|
90
127
|
.then(ok)
|
|
@@ -93,7 +130,7 @@ export async function handler(input, ctx) {
|
|
|
93
130
|
const wabas = input.include_whatsapp
|
|
94
131
|
? ctx.graph
|
|
95
132
|
.get({
|
|
96
|
-
path: `${
|
|
133
|
+
path: `${businessId}/owned_whatsapp_business_accounts`,
|
|
97
134
|
params: { fields: "id,name,currency,status,business_verification_status", limit: 25 },
|
|
98
135
|
})
|
|
99
136
|
.then(ok)
|
|
@@ -180,7 +217,8 @@ export async function handler(input, ctx) {
|
|
|
180
217
|
};
|
|
181
218
|
}));
|
|
182
219
|
const structured = {
|
|
183
|
-
business_id:
|
|
220
|
+
business_id: businessId,
|
|
221
|
+
business_id_source: businessIdSource,
|
|
184
222
|
date_preset: input.date_preset,
|
|
185
223
|
generated_at: new Date().toISOString(),
|
|
186
224
|
latency_ms: Date.now() - started,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@praise25/meta-mcp-server",
|
|
3
3
|
"description": "Read-only Model Context Protocol server for Meta Business Manager — Pages, Instagram, Ads insights, Pixels, Catalog, WhatsApp.",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"author": "Stephen A.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/feladeveloper/meta-mcp-server#readme",
|