get_business
Retrieve details of a specific business using its ID. Specify fields to return for targeted data.
Instructions
Get details of a specific business by ID.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| business_id | Yes | Business ID | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/business.ts:29-47 (handler)The get_business tool handler function registered via server.tool(). It takes a business_id (required) and fields (optional) as input, calls client.get(`/${business_id}`) to fetch business details from the Meta Graph API, and returns the result as JSON text with rate limit info.
// ─── get_business ───────────────────────────────────────────── server.tool( "get_business", "Get details of a specific business by ID.", { business_id: z.string().describe("Business ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ business_id, fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`/${business_id}`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/tools/business.ts:33-36 (schema)Input schema for get_business: business_id (required string) and fields (optional string).
{ business_id: z.string().describe("Business ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/tools/business.ts:29-47 (registration)Registration of get_business via server.tool() call inside registerBusinessTools(), which is called from src/index.ts line 90.
// ─── get_business ───────────────────────────────────────────── server.tool( "get_business", "Get details of a specific business by ID.", { business_id: z.string().describe("Business ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ business_id, fields }) => { try { const params: Record<string, unknown> = {}; if (fields) params.fields = fields; const { data, rateLimit } = await client.get(`/${business_id}`, params); return { content: [{ type: "text" as const, text: JSON.stringify({ ...data as object, _rateLimit: rateLimit }, null, 2) }] }; } catch (error) { return { content: [{ type: "text" as const, text: `Failed: ${error instanceof Error ? error.message : String(error)}` }], isError: true }; } } ); - src/services/ads-client.ts:180-185 (helper)The AdsClient.get() method used by the handler to make GET requests to the Meta Graph API.
async get( path: string, params?: Record<string, unknown> ): Promise<ClientResponse> { return this.request("GET", path, params); }