pylon_search_accounts
Search customer accounts in Pylon using filters for domains, tags, names, or external IDs to find specific records and manage support data.
Instructions
Search accounts with filters
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | Yes | Filter object with fields like domains, tags, name. Supports operators: equals, contains, in, not_in, is_set, is_unset | |
| limit | No | Results limit | |
| cursor | No | Pagination cursor |
Implementation Reference
- src/index.ts:135-159 (registration)Registration of the 'pylon_search_accounts' MCP tool, including input schema (Zod object for filter with domains/tags/name/external_ids passthrough, optional limit 1-1000, cursor) and handler function that invokes PylonClient.searchAccounts and returns formatted JSON response.
server.tool( 'pylon_search_accounts', 'Search accounts with filters', { filter: z .object({ domains: z.object({}).optional(), tags: z.object({}).optional(), name: z.object({}).optional(), external_ids: z.object({}).optional(), }) .passthrough() .describe( 'Filter object with fields like domains, tags, name. Supports operators: equals, contains, in, not_in, is_set, is_unset', ), limit: z.number().min(1).max(1000).optional().describe('Results limit'), cursor: z.string().optional().describe('Pagination cursor'), }, async ({ filter, limit, cursor }) => { const result = await client.searchAccounts(filter, { limit, cursor }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; }, ); - src/pylon-client.ts:198-211 (helper)Implementation of searchAccounts method in PylonClient class, which sends a POST request to the Pylon API /accounts/search endpoint with the filter and pagination parameters, returning a paginated list of accounts.
async searchAccounts( filter: object, params?: PaginationParams, ): Promise<PaginatedResponse<Account>> { return this.request<PaginatedResponse<Account>>( 'POST', '/accounts/search', { filter, limit: params?.limit, cursor: params?.cursor, }, ); } - src/pylon-client.ts:121-147 (helper)Private request method in PylonClient used by searchAccounts to perform authenticated HTTP requests to the Pylon API.
private async request<T>( method: string, path: string, body?: object, ): Promise<T> { const url = `${PYLON_API_BASE}${path}`; const headers: Record<string, string> = { Authorization: `Bearer ${this.apiToken}`, 'Content-Type': 'application/json', Accept: 'application/json', }; const response = await fetch(url, { method, headers, body: body ? JSON.stringify(body) : undefined, }); if (!response.ok) { const errorText = await response.text(); throw new Error( `Pylon API error: ${response.status} ${response.statusText} - ${errorText}`, ); } return response.json() as Promise<T>; }