Skip to main content
Glama

scp_get_orders

Retrieve order history from authorized merchants to access purchase records, filter by status, and manage order data for customer service and analytics.

Instructions

Get order history from a merchant. Domain must be authorized first.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
domainYesMerchant domain
limitNoMaximum number of orders to return
offsetNoNumber of orders to skip
statusNoFilter by order status (e.g., ['delivered', 'shipped'])

Implementation Reference

  • The MCP tool handler for scp_get_orders. Checks authorization, retrieves valid access token, calls SCP client to fetch orders, and returns JSON-formatted response.
    * Tool handler: scp_get_orders */ async function handleGetOrders(domain: string, params: any) { const { auth, accessToken } = await checkAuthorizationOrThrow(domain); const token = await accessToken; const data = await scpClient.getOrders(auth.scp_endpoint, token, { limit: params.limit || 10, offset: params.offset || 0, status: params.status }); return { content: [ { type: 'text', text: JSON.stringify(data, null, 2) } ] }; }
  • Input schema and description for the scp_get_orders tool, defining parameters domain (required), limit, offset, status.
    name: 'scp_get_orders', description: 'Get order history from a merchant. Domain must be authorized first.', inputSchema: { type: 'object', properties: { domain: { type: 'string', description: 'Merchant domain' }, limit: { type: 'number', description: 'Maximum number of orders to return', default: 10 }, offset: { type: 'number', description: 'Number of orders to skip', default: 0 }, status: { type: 'array', items: { type: 'string' }, description: 'Filter by order status (e.g., [\'delivered\', \'shipped\'])' } }, required: ['domain'] }
  • src/server.ts:561-562 (registration)
    Tool handler registration in the CallToolRequestSchema switch statement dispatching to handleGetOrders.
    case 'scp_get_orders': return await handleGetOrders(args.domain as string, args);
  • Helper function that checks if authorized for the domain and returns auth info and access token promise, or throws detailed error.
    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) }; }
  • HTTP client helper that wraps the generic JSON-RPC request specifically for the 'scp.get_orders' method.
    export async function getOrders( endpoint: string, accessToken: string, params?: { limit?: number; offset?: number; status?: string[] } ): Promise<any> { return makeRPCRequest(endpoint, accessToken, 'scp.get_orders', params); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shopper-context-protocol/scp-mcp-wrapper'

If you have feedback or need assistance with the MCP directory API, please join our Discord server