get_product
Retrieve details of a specific product by its ID. Specify fields to return only needed information.
Instructions
Get details of a specific product.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_id | Yes | Product ID | |
| fields | No | Comma-separated fields to return |
Implementation Reference
- src/tools/catalogs.ts:177-192 (registration)Registration of the 'get_product' tool via server.tool(), including its schema (product_id required, fields optional) and handler function.
server.tool( "get_product", "Get details of a specific product.", { product_id: z.string().describe("Product ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, async ({ product_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${product_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/catalogs.ts:184-192 (handler)Handler function that makes a GET request to `/${product_id}` via the AdsClient and returns the data as JSON.
async ({ product_id, ...params }) => { try { const { data, rateLimit } = await client.get(`/${product_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/catalogs.ts:180-183 (schema)Zod schema defining the input parameters: product_id (required string) and fields (optional string).
{ product_id: z.string().describe("Product ID"), fields: z.string().optional().describe("Comma-separated fields to return"), }, - src/tools/catalogs.ts:5-6 (helper)The registration helper function that registers all catalog tools including 'get_product'.
export function registerCatalogTools(server: McpServer, client: AdsClient): void { // ─── list_catalogs ─────────────────────────────────────────