li_list_ad_accounts
List your accessible LinkedIn ad accounts with IDs, names, statuses, currency, and type. Start here to obtain the ad_account_id needed by other tools. Optionally filter by status.
Instructions
List all LinkedIn ad accounts the authenticated user has access to. Returns account ID, name, status, currency, type (BUSINESS/ENTERPRISE), and reference organization URN. Use this first to discover the ad_account_id needed by other tools. Filter by status (ACTIVE/CANCELED/DRAFT/PENDING_DELETION/REMOVED) or omit to see all accounts.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | No | Filter by ad account status. Omit to return accounts in all statuses. | |
| page_size | No | Number of results per page (max 100). |
Implementation Reference
- src/index.ts:58-63 (registration)Registration of the 'li_list_ad_accounts' tool with the MCP server, binding the schema and handler.
server.tool( "li_list_ad_accounts", "List all LinkedIn ad accounts the authenticated user has access to. Returns account ID, name, status, currency, type (BUSINESS/ENTERPRISE), and reference organization URN. Use this first to discover the ad_account_id needed by other tools. Filter by status (ACTIVE/CANCELED/DRAFT/PENDING_DELETION/REMOVED) or omit to see all accounts.", listAdAccountsSchema, async (args) => { try { return ok(await listAdAccounts(args)); } catch (e) { return err(e); } } ); - src/tools/accounts.ts:6-18 (schema)Zod schema defining input parameters for li_list_ad_accounts: optional status enum filter and page_size (default 50, max 100).
export const listAdAccountsSchema = { status: z .enum(["ACTIVE", "CANCELED", "DRAFT", "PENDING_DELETION", "REMOVED"]) .optional() .describe("Filter by ad account status. Omit to return accounts in all statuses."), page_size: z .number() .int() .min(1) .max(100) .default(50) .describe("Number of results per page (max 100)."), }; - src/tools/accounts.ts:20-32 (handler)The async handler function that calls LinkedIn API GET /adAccounts with optional status filter and page size.
export async function listAdAccounts(args: { status?: string; page_size?: number; }) { const params: Record<string, string | number> = { q: "search", pageSize: args.page_size ?? 50, }; if (args.status) { params["search"] = `(status:(values:List(${args.status})))`; } return liGet("/adAccounts", params); } - src/tools/accounts.ts:2-3 (helper)Import of the helper function liGet used to make the LinkedIn API GET request.
import { liGet, resolveAdAccount, unwrapURN, urn } from "../client.js";