List Organizations
keychain_list_organizationsLists organizations accessible to your Bitwarden account, providing organization IDs needed for org-scoped operations.
Instructions
List organizations available to the current Bitwarden user so you can discover the organizationId required for org-scoped tools.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| search | No | Optional text filter; empty means no text filter. | |
| limit | No | Maximum returned rows (1-500). |
Implementation Reference
- src/tools/registerTools.ts:1055-1082 (registration)Tool registration for 'list_organizations' using the tool prefix. Registers the MCP tool with input schema (search, limit) and a read-only annotation.
registerTool( `${deps.toolPrefix}.list_organizations`, { title: 'List Organizations', description: 'List organizations available to the current Bitwarden user so you can discover the organizationId required for org-scoped tools.', annotations: { readOnlyHint: true }, inputSchema: { search: searchSchema, limit: limitSchema, }, _meta: toolMeta, }, async (input, extra) => { const sdk = await deps.getSdk(extra.authInfo); const orgs = await sdk.listOrganizations(input); const results = orgs .filter((x) => x && typeof x === 'object') .map((x) => { const rec = x as Record<string, unknown>; return { id: rec.id, name: rec.name }; }); return { structuredContent: { results }, content: [{ type: 'text', text: formatResultsText('org(s)', results) }], }; }, ); - src/tools/registerTools.ts:1068-1081 (handler)Handler function for the list_organizations tool. Calls sdk.listOrganizations(input), maps results to id/name summaries, and returns them with 'org(s)' result text.
async (input, extra) => { const sdk = await deps.getSdk(extra.authInfo); const orgs = await sdk.listOrganizations(input); const results = orgs .filter((x) => x && typeof x === 'object') .map((x) => { const rec = x as Record<string, unknown>; return { id: rec.id, name: rec.name }; }); return { structuredContent: { results }, content: [{ type: 'text', text: formatResultsText('org(s)', results) }], }; }, - src/sdk/keychainSdk.ts:186-189 (schema)Input type definition for listOrganizations, with optional search and limit fields.
export interface ListOrganizationsInput { search?: string; limit?: number; } - src/sdk/keychainSdk.ts:1121-1134 (helper)SDK implementation of listOrganizations. Executes `bw list organizations` via the Bitwarden CLI session, with optional --search filter, applies limit, and returns parsed JSON array.
async listOrganizations( input: ListOrganizationsInput = {}, ): Promise<unknown[]> { const { limit } = input; const orgs = await this.bw.withSession(async (session) => { const args: string[] = ['list', 'organizations']; if (input.search) args.push('--search', input.search); const { stdout } = await this.bw.runForSession(session, args, { timeoutMs: 60_000, }); return this.parseBwJson<unknown[]>(stdout); }); return typeof limit === 'number' ? orgs.slice(0, limit) : orgs; }