scp_get_offers
Retrieve active personalized offers from authorized merchants using the Shopper Context Protocol to access customer e-commerce data with OAuth 2.0 authentication.
Instructions
Get active personalized offers from a merchant. Domain must be authorized first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| active_only | No | Only return active offers | |
| domain | Yes | Merchant domain |
Implementation Reference
- src/server.ts:870-888 (handler)Main execution handler for scp_get_offers tool: validates authorization, retrieves access token, calls HTTP client to fetch offers via JSON-RPC, formats and returns response.* Tool handler: scp_get_offers */ async function handleGetOffers(domain: string, params: any) { const { auth, accessToken } = await checkAuthorizationOrThrow(domain); const token = await accessToken; const data = await scpClient.getOffers(auth.scp_endpoint, token, { active_only: params.active_only !== false }); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2) } ] }; }
- src/server.ts:414-430 (schema)Input schema definition for scp_get_offers tool, defining parameters like domain and active_only.name: 'scp_get_offers', description: 'Get active personalized offers from a merchant. Domain must be authorized first.', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Merchant domain' }, active_only: { type: 'boolean', description: 'Only return active offers', default: true } }, required: ['domain'] }
- src/server.ts:413-430 (registration)Registration of scp_get_offers tool in the ListTools response, advertised to MCP clients.{ name: 'scp_get_offers', description: 'Get active personalized offers from a merchant. Domain must be authorized first.', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Merchant domain' }, active_only: { type: 'boolean', description: 'Only return active offers', default: true } }, required: ['domain'] }
- src/server.ts:567-568 (handler)Dispatch case in CallToolRequest handler that routes to the specific tool handler.case 'scp_get_offers': return await handleGetOffers(args.domain as string, args);
- src/http/client.ts:109-115 (helper)Helper function in HTTP client that wraps the generic JSON-RPC request specifically for scp.get_offers method.export async function getOffers( endpoint: string, accessToken: string, params?: { active_only?: boolean } ): Promise<any> { return makeRPCRequest(endpoint, accessToken, 'scp.get_offers', params); }