@devries-cameron20 / composio Mirror · read-only / commits / 20cfa6cda
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 23:30 UTC

feat(cli): add `composio connections list` command (#3206)

## Summary - Adds `composio connections list` command that groups connected accounts by toolkit and displays aliases - New command file at `ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts` with test coverage - Registers the command under the `connections` group and in root help ## Stacked on This PR is stacked on #3202 (`cli/keyring-migration`). ## Test plan - [ ] `pnpm --filter @composio/cli test` (connections.list.cmd.test.ts) - [ ] Manual: `composio connections list` with a logged-in account shows grouped toolkit output with aliases 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Rahul Tarak committed Apr 14, 2026 at 01:10 UTC 20cfa6cdaeb90d8ebf6fefea5a741deeb4c92caa
7 files changed +213
ts/packages/cli/README.md
+1
@@ -38,6 +38,7 @@ composio [--log-level all|trace|debug|info|warning|error|fatal|none]
38 - `composio proxy <url> --toolkit <toolkit> [-X method] [-H header]... [-d data]`: Call a toolkit API directly through Composio using a connected account.
39 - `composio tools list|info`: Inspect available tools and their cached schemas.
40 - `composio triggers list <toolkit>|info`: Inspect toolkit-scoped trigger types and their schemas.
41 +- `composio connections list [--toolkit <toolkit>]`: Print toolkit connection statuses as JSON.
42 - `composio artifacts cwd`: Print the cwd-scoped CLI session artifacts directory.
43 - `composio dev <subcommand>`: Developer workflows for init, playground execution, logs, toolkits, auth configs, accounts, triggers, orgs, and projects.
44 - `composio generate [-o, --output-dir <directory>] [--toolkits <toolkit>] [--type-tools]`: Auto-detect the project language (Python or TypeScript) and generate type stubs for toolkits, tools, and triggers.
ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts new
+61
@@ -0,0 +1,61 @@
1 +import { Command, Options } from '@effect/cli';
2 +import { Effect, Option } from 'effect';
3 +import { requireAuth } from 'src/effects/require-auth';
4 +import type { ConnectedAccountItem } from 'src/models/connected-accounts';
5 +import { ComposioToolkitsRepository } from 'src/services/composio-clients';
6 +import { TerminalUI } from 'src/services/terminal-ui';
7 +
8 +const toolkit = Options.text('toolkit').pipe(
9 + Options.withDescription('Filter by toolkit slug (e.g. "gmail")'),
10 + Options.optional
11 +);
12 +
13 +const formatConnectionsJson = (items: ReadonlyArray<ConnectedAccountItem>): string => {
14 + const toolkitCounts = items.reduce<Map<string, number>>((acc, item) => {
15 + acc.set(item.toolkit.slug, (acc.get(item.toolkit.slug) ?? 0) + 1);
16 + return acc;
17 + }, new Map());
18 +
19 + const grouped = items.reduce<Record<string, Array<{ status: string; alias?: string | null }>>>(
20 + (acc, item) => {
21 + const toolkit = item.toolkit.slug;
22 + const entry = {
23 + status: item.status,
24 + ...(toolkitCounts.get(toolkit)! > 1 ? { alias: item.alias ?? null } : {}),
25 + };
26 +
27 + if (!acc[toolkit]) {
28 + acc[toolkit] = [];
29 + }
30 + acc[toolkit].push(entry);
31 + return acc;
32 + },
33 + {}
34 + );
35 +
36 + return JSON.stringify(grouped, null, 2);
37 +};
38 +
39 +export const connectionsCmd$List = Command.make('list', { toolkit }, ({ toolkit }) =>
40 + Effect.gen(function* () {
41 + if (!(yield* requireAuth)) return;
42 +
43 + const ui = yield* TerminalUI;
44 + const repo = yield* ComposioToolkitsRepository;
45 + const toolkitSlug = Option.getOrUndefined(toolkit);
46 +
47 + const result = yield* ui.withSpinner(
48 + 'Fetching connections...',
49 + repo.listConnectedAccounts({
50 + toolkit_slugs: toolkitSlug ? [toolkitSlug] : undefined,
51 + limit: 1000,
52 + })
53 + );
54 +
55 + yield* ui.output(formatConnectionsJson(result.items));
56 + })
57 +).pipe(
58 + Command.withDescription(
59 + 'List connection statuses as JSON. Includes aliases when a toolkit has multiple connections.'
60 + )
61 +);
ts/packages/cli/src/commands/connections/connections.cmd.ts new
+7
@@ -0,0 +1,7 @@
1 +import { Command } from '@effect/cli';
2 +import { connectionsCmd$List } from './commands/connections.list.cmd';
3 +
4 +export const rootConnectionsCmd = Command.make('connections').pipe(
5 + Command.withDescription('Inspect connected toolkit accounts in a script-friendly format.'),
6 + Command.withSubcommands([connectionsCmd$List])
7 +);
ts/packages/cli/src/commands/index.ts
+2
@@ -27,6 +27,7 @@ import { rootTriggersCmd } from './triggers/root-triggers.cmd';
27 import { rootConnectedAccountsCmd$Link } from './connected-accounts/commands/connected-accounts.link.cmd';
28 import { orgsCmd } from './orgs/orgs.cmd';
29 import { configCmd } from './config/config.cmd';
30 +import { rootConnectionsCmd } from './connections/connections.cmd';
31 import { renderCommandHintGraph } from 'src/services/command-hints';
32 import { resetRuntimeDebugFlags, setRuntimeDebugFlags } from 'src/services/runtime-debug-flags';
33 import { ComposioCliUserConfig } from 'src/services/cli-user-config';
@@ -64,6 +65,7 @@ const ROOT_COMMANDS: ReadonlyArray<TaggedValue<Command.Command<any, any, any, an
65 tagged(rootToolsCmd$Search),
66 tagged(rootConnectedAccountsCmd$Link),
67 tagged(rootToolsCmd$Execute),
68 + tagged(rootConnectionsCmd),
69 tagged(generateCmd),
70 tagged(orgsCmd),
71 tagged(configCmd),
ts/packages/cli/src/commands/root-help.ts
+15
@@ -143,6 +143,10 @@ const OTHER_COMMANDS: ReadonlyArray<TaggedValue<CompactCommand>> = [
143 name: 'composio triggers list <toolkit>',
144 description: 'List available trigger types in a toolkit',
145 }),
146 + tagged({
147 + name: 'composio connections list',
148 + description: 'Print toolkit connection statuses as JSON',
149 + }),
150 tagged({
151 name: 'composio artifacts cwd',
152 description: 'Print the cwd-scoped session artifact directory',
@@ -476,6 +480,17 @@ const SUBCOMMAND_HELP: Record<string, SubcommandHelp | TaggedValue<SubcommandHel
480 'composio config experimental Manage experimental features',
481 ],
482 },
483 + 'connections list': {
484 + usage: 'composio connections list [--toolkit <text>]',
485 + description:
486 + 'Print connected toolkit statuses as JSON. Adds aliases when a toolkit has multiple connections.',
487 + options: [{ name: '--toolkit <text>', description: 'Filter to a single toolkit slug' }],
488 + examples: ['composio connections list', 'composio connections list --toolkit gmail'],
489 + seeAlso: [
490 + 'composio link <toolkit> Connect a new account for a toolkit',
491 + 'composio dev connected-accounts list Inspect the full connected-account table',
492 + ],
493 + },
494 run: {
495 usage: 'composio run <code> [-- ...args] | run -f <file> [-- ...args]',
496 description:
ts/packages/cli/test/src/commands/$default.cmd.test.ts
+1
@@ -71,6 +71,7 @@ describe('CLI: composio', () => {
71 const output = lines.join('\n');
72 expect(output).toContain('Usage:');
73 expect(output).toContain('composio');
74 + expect(output).toContain('composio connections list');
75 })
76 );
77 });
ts/packages/cli/test/src/commands/connections/connections.list.cmd.test.ts new
+126
@@ -0,0 +1,126 @@
1 +import { describe, expect, layer } from '@effect/vitest';
2 +import { ConfigProvider, Effect } from 'effect';
3 +import type { ConnectedAccountItem } from 'src/models/connected-accounts';
4 +import { extendConfigProvider } from 'src/services/config';
5 +import { cli, TestLive, MockConsole } from 'test/__utils__';
6 +import type { TestLiveInput } from 'test/__utils__/services/test-layer';
7 +
8 +const parseJsonFromLines = (lines: ReadonlyArray<string>) => {
9 + for (let i = lines.length - 1; i >= 0; i -= 1) {
10 + const line = lines[i];
11 + if (!line) continue;
12 + try {
13 + return JSON.parse(line) as Record<string, Array<Record<string, string>>>;
14 + } catch {
15 + // continue
16 + }
17 + }
18 + throw new Error('Expected JSON output but none found');
19 +};
20 +
21 +const testConnections: ConnectedAccountItem[] = [
22 + {
23 + id: 'con_gmail_active',
24 + alias: null,
25 + word_id: null,
26 + status: 'ACTIVE',
27 + status_reason: null,
28 + is_disabled: false,
29 + user_id: 'default',
30 + toolkit: { slug: 'gmail' },
31 + auth_config: {
32 + id: 'ac_gmail_oauth',
33 + auth_scheme: 'OAUTH2',
34 + is_composio_managed: true,
35 + is_disabled: false,
36 + },
37 + created_at: '2026-01-01T00:00:00Z',
38 + updated_at: '2026-01-15T00:00:00Z',
39 + test_request_endpoint: '',
40 + },
41 + {
42 + id: 'con_github_work',
43 + alias: 'work',
44 + word_id: null,
45 + status: 'ACTIVE',
46 + status_reason: null,
47 + is_disabled: false,
48 + user_id: 'default',
49 + toolkit: { slug: 'github' },
50 + auth_config: {
51 + id: 'ac_github_oauth',
52 + auth_scheme: 'OAUTH2',
53 + is_composio_managed: true,
54 + is_disabled: false,
55 + },
56 + created_at: '2026-02-01T00:00:00Z',
57 + updated_at: '2026-02-10T00:00:00Z',
58 + test_request_endpoint: '',
59 + },
60 + {
61 + id: 'con_github_personal',
62 + alias: 'personal',
63 + word_id: null,
64 + status: 'FAILED',
65 + status_reason: 'Token expired',
66 + is_disabled: false,
67 + user_id: 'default',
68 + toolkit: { slug: 'github' },
69 + auth_config: {
70 + id: 'ac_github_oauth_2',
71 + auth_scheme: 'OAUTH2',
72 + is_composio_managed: true,
73 + is_disabled: false,
74 + },
75 + created_at: '2026-02-03T00:00:00Z',
76 + updated_at: '2026-02-12T00:00:00Z',
77 + test_request_endpoint: '',
78 + },
79 +];
80 +
81 +const connectedAccountsData = {
82 + items: testConnections,
83 +} satisfies TestLiveInput['connectedAccountsData'];
84 +
85 +const testConfigProvider = ConfigProvider.fromMap(
86 + new Map([['COMPOSIO_USER_API_KEY', 'test_api_key']])
87 +).pipe(extendConfigProvider);
88 +
89 +describe('CLI: composio connections list', () => {
90 + layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(it => {
91 + it.scoped('[Given] no filter [Then] prints connection JSON with aliases for duplicates', () =>
92 + Effect.gen(function* () {
93 + yield* cli(['connections', 'list']);
94 +
95 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
96 + const parsed = parseJsonFromLines(lines);
97 +
98 + expect(parsed).toEqual({
99 + gmail: [{ status: 'ACTIVE' }],
100 + github: [
101 + { status: 'ACTIVE', alias: 'work' },
102 + { status: 'FAILED', alias: 'personal' },
103 + ],
104 + });
105 + })
106 + );
107 + });
108 +
109 + layer(TestLive({ baseConfigProvider: testConfigProvider, connectedAccountsData }))(it => {
110 + it.scoped('[Given] --toolkit github [Then] filters the JSON output', () =>
111 + Effect.gen(function* () {
112 + yield* cli(['connections', 'list', '--toolkit', 'github']);
113 +
114 + const lines = yield* MockConsole.getLines({ stripAnsi: true });
115 + const parsed = parseJsonFromLines(lines);
116 +
117 + expect(parsed).toEqual({
118 + github: [
119 + { status: 'ACTIVE', alias: 'work' },
120 + { status: 'FAILED', alias: 'personal' },
121 + ],
122 + });
123 + })
124 + );
125 + });
126 +});