pylon_list_accounts
Retrieve a paginated compact list of accounts, showing essential fields. Use the detail tool for full account information.
Instructions
List accounts. Returns compact table. Use pylon_get_account for details.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of accounts to return (1-100, default 50) | |
| cursor | No | Pagination cursor for next page |
Implementation Reference
- src/index.ts:199-233 (handler)The tool registration and handler for 'pylon_list_accounts' on the McpServer. Calls client.listAccounts() with optional limit/cursor, transforms results to minimal format via toAccountMinimal(), formats as a markdown table via formatAccountsAsTable(), and appends pagination info.
server.tool( 'pylon_list_accounts', 'List accounts. Returns compact table. Use pylon_get_account for details.', { limit: z .number() .min(1) .max(MAX_LIST_LIMIT) .optional() .describe( `Number of accounts to return (1-${MAX_LIST_LIMIT}, default ${DEFAULT_LIST_LIMIT})`, ), cursor: z.string().optional().describe('Pagination cursor for next page'), }, async ({ limit, cursor }) => { const result = await client.listAccounts({ limit: limit ?? DEFAULT_LIST_LIMIT, cursor, }); // Transform to minimal format to reduce context size const accounts = result.data.map((raw) => toAccountMinimal(raw as unknown as Record<string, unknown>), ); const table = formatAccountsAsTable(accounts); const pagination = result.pagination.has_next_page ? `\n\nMore results available. Use cursor: "${result.pagination.cursor}"` : ''; return { content: [{ type: 'text', text: table + pagination }], }; }, ); - src/schemas.ts:74-80 (schema)Zod schema for AccountMinimal, defining the shape returned by the tool: id, name, primary_domain, owner_id, tags.
export const AccountMinimalSchema = z.object({ id: z.string(), name: z.string(), primary_domain: z.string().nullable().optional(), owner_id: z.string().nullable().optional(), tags: z.array(z.string()).nullable().optional(), }); - src/schemas.ts:82-89 (schema)AccountStandardSchema extends AccountMinimalSchema with additional fields (domains, created_at, type).
export const AccountStandardSchema = AccountMinimalSchema.extend({ domains: z.array(z.string()).nullable().optional(), created_at: z.string().optional(), type: z.string().optional(), }); export type AccountMinimal = z.infer<typeof AccountMinimalSchema>; export type AccountStandard = z.infer<typeof AccountStandardSchema>; - src/index.ts:78-96 (helper)Helper function formatAccountsAsTable that formats AccountMinimal[] into a markdown table with columns ID, Name, Domain, Tags.
function formatAccountsAsTable(accounts: AccountMinimal[]): string { if (accounts.length === 0) { return 'No accounts found.'; } const headers = ['ID', 'Name', 'Domain', 'Tags']; const rows = accounts.map((account) => [ escapeCell(account.id), escapeCell(truncate(account.name, MAX_NAME_LENGTH)), escapeCell(account.primary_domain || '-'), escapeCell((account.tags || []).slice(0, 3).join(', ') || '-'), ]); const headerRow = `| ${headers.join(' | ')} |`; const separatorRow = `|${headers.map(() => '---').join('|')}|`; const dataRows = rows.map((row) => `| ${row.join(' | ')} |`).join('\n'); return `${headerRow}\n${separatorRow}\n${dataRows}`; } - src/schemas.ts:271-280 (helper)Helper function toAccountMinimal that transforms a raw API response object into an AccountMinimal object.
export function toAccountMinimal(raw: Record<string, unknown>): AccountMinimal { const owner = raw['owner'] as { id?: string } | null | undefined; return { id: raw['id'] as string, name: raw['name'] as string, primary_domain: raw['primary_domain'] as string | null | undefined, owner_id: owner?.id ?? (raw['owner_id'] as string | null | undefined), tags: raw['tags'] as string[] | null | undefined, }; }