scp_get_intents
Retrieve shopping intents from authorized merchant domains to understand customer purchase goals and preferences for personalized e-commerce assistance.
Instructions
Get shopping intents from a merchant. Domain must be authorized first.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Merchant domain | |
| limit | No | Maximum number of intents to return | |
| status | No | Filter by status (e.g., ['active', 'in_progress']) |
Implementation Reference
- src/server.ts:912-930 (handler)Main execution handler for scp_get_intents tool. Checks authorization, fetches access token, calls SCP client to retrieve shopping intents, and returns JSON-formatted response.async function handleGetIntents(domain: string, params: any) { const { auth, accessToken } = await checkAuthorizationOrThrow(domain); const token = await accessToken; const data = await scpClient.getIntents(auth.scp_endpoint, token, { status: params.status || ['active', 'in_progress'], limit: params.limit || 10, offset: params.offset || 0 }); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2) } ] }; }
- src/server.ts:446-469 (schema)Input schema and metadata for the scp_get_intents tool, defining required 'domain' and optional 'status' and 'limit' parameters.{ name: 'scp_get_intents', description: 'Get shopping intents from a merchant. Domain must be authorized first.', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Merchant domain' }, status: { type: 'array', items: { type: 'string' }, description: 'Filter by status (e.g., [\'active\', \'in_progress\'])' }, limit: { type: 'number', description: 'Maximum number of intents to return', default: 10 } }, required: ['domain'] } },
- src/server.ts:573-575 (registration)Tool handler registration in the CallToolRequestSchema switch statement, mapping tool name to handleGetIntents function.case 'scp_get_intents': return await handleGetIntents(args.domain as string, args);
- src/server.ts:811-825 (helper)Shared authorization check helper function used by the handler to ensure the domain is authorized before accessing data.async function checkAuthorizationOrThrow(domain: string): Promise<{ auth: any; accessToken: Promise<string> }> { const auth = await getAuthorization(domain); if (!auth) { const errorMessage = `❌ Not authorized with ${domain}.\n\n` + `Please authorize first by calling:\n` + `scp_authorize with domain="${domain}", email="your@email.com", and scopes=["orders", "loyalty", "preferences", "intent:read", "intent:create"]`; throw new Error(errorMessage); } return { auth, accessToken: getValidAccessToken(domain) }; }
- src/http/client.ts:124-135 (helper)HTTP client helper that wraps the JSON-RPC call to the merchant's SCP endpoint for fetching intents.export async function getIntents( endpoint: string, accessToken: string, params?: { status?: string[]; mechanism?: string; limit?: number; offset?: number; } ): Promise<any> { return makeRPCRequest(endpoint, accessToken, 'scp.get_intents', params); }