@n8n/frontend-module-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE.md +88 -0
  2. package/README.md +51 -0
  3. package/biome.jsonc +4 -0
  4. package/eslint.config.mjs +4 -0
  5. package/package.json +72 -0
  6. package/src/SettingsMCPAgentsView.test.ts +256 -0
  7. package/src/SettingsMCPAgentsView.vue +223 -0
  8. package/src/SettingsMCPClientsView.test.ts +280 -0
  9. package/src/SettingsMCPClientsView.vue +168 -0
  10. package/src/SettingsMCPView.test.ts +832 -0
  11. package/src/SettingsMCPView.vue +496 -0
  12. package/src/SettingsMCPWorkflowsView.test.ts +274 -0
  13. package/src/SettingsMCPWorkflowsView.vue +245 -0
  14. package/src/__tests__/design-system-icons.test.ts +24 -0
  15. package/src/__tests__/setup.ts +4 -0
  16. package/src/assets/client-icons/claude.svg +1 -0
  17. package/src/assets/client-icons/codex.svg +1 -0
  18. package/src/assets/client-icons/cursor.svg +1 -0
  19. package/src/assets/client-icons/gemini.svg +1 -0
  20. package/src/assets/client-icons/mistral.svg +1 -0
  21. package/src/assets/client-icons/openai.svg +3 -0
  22. package/src/assets/client-icons/vscode.svg +1 -0
  23. package/src/clients.utils.test.ts +85 -0
  24. package/src/clients.utils.ts +124 -0
  25. package/src/components/ConnectionParameter.vue +213 -0
  26. package/src/components/MCPAgentsSelect.vue +176 -0
  27. package/src/components/MCPEmptyState.vue +75 -0
  28. package/src/components/MCPWorkflowsSelect.test.ts +384 -0
  29. package/src/components/MCPWorkflowsSelect.vue +159 -0
  30. package/src/components/McpAccessToggle.vue +77 -0
  31. package/src/components/McpAccessTokenTab.test.ts +220 -0
  32. package/src/components/McpAccessTokenTab.vue +201 -0
  33. package/src/components/McpAllowedCallbackUrlsDialog.test.ts +122 -0
  34. package/src/components/McpAllowedCallbackUrlsDialog.vue +359 -0
  35. package/src/components/McpClientLogoCards.vue +134 -0
  36. package/src/components/McpConfigSnippet.vue +92 -0
  37. package/src/components/McpConnectClientDialog.test.ts +115 -0
  38. package/src/components/McpConnectClientDialog.vue +432 -0
  39. package/src/components/McpConnectedClientRow.test.ts +86 -0
  40. package/src/components/McpConnectedClientRow.vue +152 -0
  41. package/src/components/McpEmptyStateCard.vue +83 -0
  42. package/src/components/McpStatusControl.test.ts +33 -0
  43. package/src/components/McpStatusControl.vue +96 -0
  44. package/src/components/OAuthClientDetailsModal.vue +182 -0
  45. package/src/components/RevokeOAuthClientConfirmModal.vue +60 -0
  46. package/src/components/WorkflowLocation.test.ts +329 -0
  47. package/src/components/WorkflowLocation.vue +198 -0
  48. package/src/components/tabs/AgentsTable.vue +312 -0
  49. package/src/components/tabs/OAuthClientOwnerCell.vue +71 -0
  50. package/src/components/tabs/OAuthClientsFilters.test.ts +86 -0
  51. package/src/components/tabs/OAuthClientsFilters.vue +201 -0
  52. package/src/components/tabs/OAuthClientsTable.test.ts +394 -0
  53. package/src/components/tabs/OAuthClientsTable.vue +473 -0
  54. package/src/components/tabs/WorkflowsTable.test.ts +661 -0
  55. package/src/components/tabs/WorkflowsTable.vue +398 -0
  56. package/src/composables/useMcp.test.ts +59 -0
  57. package/src/composables/useMcp.ts +61 -0
  58. package/src/composables/useOAuthClientRevoke.ts +90 -0
  59. package/src/index.ts +10 -0
  60. package/src/mcp.api.test.ts +81 -0
  61. package/src/mcp.api.ts +206 -0
  62. package/src/mcp.clients.catalog.test.ts +63 -0
  63. package/src/mcp.clients.catalog.ts +183 -0
  64. package/src/mcp.constants.ts +45 -0
  65. package/src/mcp.module.test.ts +106 -0
  66. package/src/mcp.module.ts +90 -0
  67. package/src/mcp.store.test.ts +628 -0
  68. package/src/mcp.store.ts +490 -0
  69. package/src/mcp.test.utils.ts +57 -0
  70. package/src/mcp.types.ts +20 -0
  71. package/src/modals/MCPConnectAgentsModal.test.ts +141 -0
  72. package/src/modals/MCPConnectAgentsModal.vue +122 -0
  73. package/src/modals/MCPConnectWorkflowsModal.test.ts +303 -0
  74. package/src/modals/MCPConnectWorkflowsModal.vue +101 -0
  75. package/src/redirect-uris.utils.ts +22 -0
  76. package/stylelint.config.mjs +9 -0
  77. package/vite.config.ts +52 -0
package/LICENSE.md ADDED
@@ -0,0 +1,88 @@
1
+ # License
2
+
3
+ Portions of this software are licensed as follows:
4
+
5
+ - Content of branches other than the main branch (i.e. "master") are not licensed.
6
+ - Source code files that contain ".ee." in their filename or ".ee" in their dirname are NOT licensed under
7
+ the Sustainable Use License.
8
+ To use source code files that contain ".ee." in their filename or ".ee" in their dirname you must hold a
9
+ valid n8n Enterprise License specifically allowing you access to such source code files and as defined
10
+ in "LICENSE_EE.md".
11
+ - All third party components incorporated into the n8n Software are licensed under the original license
12
+ provided by the owner of the applicable component.
13
+ - Content outside of the above mentioned files or restrictions is available under the "Sustainable Use
14
+ License" as defined below.
15
+
16
+ ## Sustainable Use License
17
+
18
+ Version 1.0
19
+
20
+ ### Acceptance
21
+
22
+ By using the software, you agree to all of the terms and conditions below.
23
+
24
+ ### Copyright License
25
+
26
+ The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license
27
+ to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject
28
+ to the limitations below.
29
+
30
+ ### Limitations
31
+
32
+ You may use or modify the software only for your own internal business purposes or for non-commercial or
33
+ personal use. You may distribute the software or provide it to others only if you do so free of charge for
34
+ non-commercial purposes. You may not alter, remove, or obscure any licensing, copyright, or other notices of
35
+ the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
36
+
37
+ ### Patents
38
+
39
+ The licensor grants you a license, under any patent claims the licensor can license, or becomes able to
40
+ license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case
41
+ subject to the limitations and conditions in this license. This license does not cover any patent claims that
42
+ you cause to be infringed by modifications or additions to the software. If you or your company make any
43
+ written claim that the software infringes or contributes to infringement of any patent, your patent license
44
+ for the software granted under these terms ends immediately. If your company makes such a claim, your patent
45
+ license ends immediately for work on behalf of your company.
46
+
47
+ ### Notices
48
+
49
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these
50
+ terms. If you modify the software, you must include in any modified copies of the software a prominent notice
51
+ stating that you have modified the software.
52
+
53
+ ### No Other Rights
54
+
55
+ These terms do not imply any licenses other than those expressly granted in these terms.
56
+
57
+ ### Termination
58
+
59
+ If you use the software in violation of these terms, such use is not licensed, and your license will
60
+ automatically terminate. If the licensor provides you with a notice of your violation, and you cease all
61
+ violation of this license no later than 30 days after you receive that notice, your license will be reinstated
62
+ retroactively. However, if you violate these terms after such reinstatement, any additional violation of these
63
+ terms will cause your license to terminate automatically and permanently.
64
+
65
+ ### No Liability
66
+
67
+ As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will
68
+ not be liable to you for any damages arising out of these terms or the use or nature of the software, under
69
+ any kind of legal claim.
70
+
71
+ ### Definitions
72
+
73
+ The “licensor” is the entity offering these terms.
74
+
75
+ The “software” is the software the licensor makes available under these terms, including any portion of it.
76
+
77
+ “You” refers to the individual or entity agreeing to these terms.
78
+
79
+ “Your company” is any legal entity, sole proprietorship, or other kind of organization that you work for, plus
80
+ all organizations that have control over, are under the control of, or are under common control with that
81
+ organization. Control means ownership of substantially all the assets of an entity, or the power to direct its
82
+ management and policies by vote, contract, or otherwise. Control can be direct or indirect.
83
+
84
+ “Your license” is the license granted to you for the software under these terms.
85
+
86
+ “Use” means anything you do with the software requiring your license.
87
+
88
+ “Trademark” means trademarks, service marks, and similar rights.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @n8n/frontend-module-mcp
2
+
3
+ Frontend feature module. Consumed from source by the editor-ui shell through
4
+ `src/app/modules.manifest.ts`; there is no build step and no `dist`.
5
+
6
+ Read the full guide at `packages/@n8n/module-cli/frontend-module-guide.md`. It gives the
7
+ descriptor contract, the registration points and the known problems. This README gives a
8
+ summary only.
9
+
10
+ ```bash
11
+ pnpm turbo typecheck --filter=@n8n/frontend-module-mcp
12
+ pnpm turbo lint --filter=@n8n/frontend-module-mcp
13
+ pnpm turbo lint:styles --filter=@n8n/frontend-module-mcp
14
+ pnpm turbo test --filter=@n8n/frontend-module-mcp
15
+ ```
16
+
17
+ Go through turbo, not `pnpm --filter <pkg> typecheck`: this package is consumed
18
+ from source, and on a cold tree its platform dependencies have not been built
19
+ yet. Turbo builds them first; the bare pnpm form does not.
20
+
21
+ ## Import rules
22
+
23
+ - Depend on L0–L2 platform packages only. The full list is in "Imports and
24
+ boundaries" in the guide. Never import another `@n8n/frontend-module-*`, and
25
+ never import `@/…` from the shell.
26
+ - `@n8n/stores`, `@n8n/composables`, `@n8n/frontend-constants` and
27
+ `@n8n/utils` are **subpath-only** — import `@n8n/stores/settings.store`, not
28
+ `@n8n/stores`.
29
+ - The no-cross-module rule is currently a convention: the shared tsconfig base
30
+ omits sibling modules from `paths`, which blocks an accidental import but not
31
+ a deliberate one (declaring the dependency makes it typecheck clean). The
32
+ CAT-3692 tracks the ESLint rule that will enforce it.
33
+
34
+ ## Adding UI
35
+
36
+ `vite.config.ts` already carries the three plugins a design-system consumer
37
+ needs, so a `.vue` file compiles in tests without further setup:
38
+
39
+ - `@vitejs/plugin-vue` — single-file components.
40
+ - `unplugin-icons` — the `~icons/lucide/*` virtual modules behind `N8nIcon`.
41
+ - `vite-svg-loader` — design-system's `custom/*.svg` icon components. Without
42
+ it an `.svg` import is a data-URI string, which Vue renders as a tag name.
43
+
44
+ `src/__tests__/design-system-icons.test.ts` renders one icon of each kind, so a
45
+ plugin dropped from `vite.config.ts` fails this package's own suite. Keep that
46
+ test while the module renders any design-system component.
47
+
48
+ SCSS goes in a scoped `<style lang="scss">` block, with tokens from
49
+ design-system — `stylelint.config.mjs` holds this package to the same rules the
50
+ shell uses. Route components must load lazily — see the note in
51
+ `src/mcp.module.ts`.
package/biome.jsonc ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "$schema": "../../../../node_modules/@biomejs/biome/configuration_schema.json",
3
+ "extends": ["../../../../biome.jsonc"]
4
+ }
@@ -0,0 +1,4 @@
1
+ import { defineConfig } from 'eslint/config';
2
+ import { frontendConfig } from '@n8n/eslint-config/frontend';
3
+
4
+ export default defineConfig(frontendConfig);
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@n8n/frontend-module-mcp",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "main": "src/index.ts",
6
+ "exports": {
7
+ ".": "./src/index.ts",
8
+ "./mcp.module": "./src/mcp.module.ts"
9
+ },
10
+ "dependencies": {
11
+ "@n8n/api-types": "1.43.0",
12
+ "@n8n/composables": "1.33.0",
13
+ "@n8n/design-system": "2.42.0",
14
+ "@n8n/frontend-constants": "0.9.0",
15
+ "@n8n/frontend-module-sdk": "0.13.0",
16
+ "@n8n/i18n": "2.43.0",
17
+ "@n8n/permissions": "0.80.0",
18
+ "@n8n/rest-api-client": "2.43.0",
19
+ "@n8n/stores": "2.43.0",
20
+ "@n8n/telemetry": "1.11.0",
21
+ "@n8n/utils": "1.50.0",
22
+ "element-plus": "2.4.3",
23
+ "lodash": "4.18.1",
24
+ "n8n-workflow": "2.43.0",
25
+ "pinia": "^2.2.4",
26
+ "reka-ui": "^2.5.0",
27
+ "vue": "^3.5.13",
28
+ "vue-i18n": "^11.4.4",
29
+ "vue-router": "^4.5.0"
30
+ },
31
+ "devDependencies": {
32
+ "@iconify/json": "^2.2.488",
33
+ "@n8n/eslint-config": "0.0.1",
34
+ "@n8n/frontend-test-utils": "0.1.0",
35
+ "@n8n/frontend-vite-config": "0.1.0",
36
+ "@n8n/playwright-janitor": "0.1.0",
37
+ "@n8n/stylelint-config": "0.0.1",
38
+ "@n8n/typescript-config": "1.12.0",
39
+ "@n8n/vitest-config": "1.24.0",
40
+ "@pinia/testing": "^0.1.6",
41
+ "@testing-library/jest-dom": "^6.6.3",
42
+ "@testing-library/user-event": "^14.6.1",
43
+ "@testing-library/vue": "^8.1.0",
44
+ "@types/lodash": "4.17.17",
45
+ "@vitejs/plugin-vue": "^6.0.8",
46
+ "@vitest/coverage-v8": "5.0.1",
47
+ "eslint": "9.29.0",
48
+ "jsdom": "23.0.1",
49
+ "stylelint": "^16.23.0",
50
+ "typescript": "6.0.2",
51
+ "unplugin-icons": "^23.0.1",
52
+ "vite": "^8.0.2",
53
+ "vite-svg-loader": "5.1.0",
54
+ "vitest": "5.0.1",
55
+ "vitest-mock-extended": "^3.1.0",
56
+ "vue-tsc": "^2.2.8"
57
+ },
58
+ "license": "LicenseRef-n8n-sustainable-use",
59
+ "scripts": {
60
+ "clean": "rimraf .turbo",
61
+ "typecheck": "vue-tsc --noEmit",
62
+ "test": "vitest run",
63
+ "test:changed": "janitor test-scoped",
64
+ "test:dev": "vitest",
65
+ "lint": "eslint src --quiet",
66
+ "lint:fix": "eslint src --fix",
67
+ "lint:styles": "stylelint \"src/**/*.{scss,sass,vue}\" --cache --allow-empty-input",
68
+ "lint:styles:fix": "stylelint \"src/**/*.{scss,sass,vue}\" --fix --cache --allow-empty-input",
69
+ "format": "biome format --write . && prettier --write . --ignore-path ../../../../.prettierignore",
70
+ "format:check": "biome ci . && prettier --check . --ignore-path ../../../../.prettierignore"
71
+ }
72
+ }
@@ -0,0 +1,256 @@
1
+ import { nextTick } from 'vue';
2
+ import { createTestingPinia } from '@pinia/testing';
3
+ import { waitFor } from '@testing-library/vue';
4
+ import userEvent from '@testing-library/user-event';
5
+ import { createComponentRenderer, mockedStore, type MockedStore } from '@n8n/frontend-test-utils';
6
+ import SettingsMCPAgentsView from './SettingsMCPAgentsView.vue';
7
+ import { useMCPStore } from './mcp.store';
8
+ import { useSettingsStore } from '@n8n/stores/settings.store';
9
+ import type { FrontendSettings } from '@n8n/api-types';
10
+ import { MCP_SETTINGS_VIEW } from './mcp.constants';
11
+ import type { McpAgent } from './mcp.types';
12
+
13
+ const { routerPush, routerReplace } = vi.hoisted(() => ({
14
+ routerPush: vi.fn(),
15
+ routerReplace: vi.fn(),
16
+ }));
17
+
18
+ vi.mock('vue-router', async (importOriginal) => ({
19
+ ...(await importOriginal()),
20
+ useRouter: () => ({ push: routerPush, replace: routerReplace }),
21
+ useRoute: vi.fn(() => ({
22
+ params: {},
23
+ })),
24
+ RouterLink: {
25
+ template: '<a><slot /></a>',
26
+ },
27
+ }));
28
+
29
+ vi.mock('@n8n/composables/useDocumentTitle', () => ({
30
+ useDocumentTitle: () => ({
31
+ set: vi.fn(),
32
+ }),
33
+ }));
34
+
35
+ let pinia: ReturnType<typeof createTestingPinia>;
36
+ let mcpStore: MockedStore<typeof useMCPStore>;
37
+ let settingsStore: MockedStore<typeof useSettingsStore>;
38
+
39
+ const createComponent = createComponentRenderer(SettingsMCPAgentsView, {
40
+ global: {
41
+ stubs: {
42
+ AgentsTable: {
43
+ inheritAttrs: true,
44
+ template:
45
+ '<div><button data-test-id="agents-table-page-2" @click="$emit(\'update:options\', { page: 1, itemsPerPage: 10, sortBy: [] })">Page 2</button><button data-test-id="agents-table-page-size-50" @click="$emit(\'update:options\', { page: 3, itemsPerPage: 50, sortBy: [] })">Page size 50</button><button data-test-id="agents-table-bulk-remove" @click="$emit(\'bulkRemoveMcpAccess\', [\'agent-1\', \'agent-2\'])">Bulk remove</button>Agents Table</div>',
46
+ },
47
+ MCPConnectAgentsModal: {
48
+ props: ['open', 'enableMcpAccess'],
49
+ template:
50
+ '<div v-if="open" data-test-id="mcp-connect-agents-dialog-stub"><button data-test-id="stub-enable-access" @click="enableMcpAccess([\'agent-1\', \'agent-2\'])">Enable</button></div>',
51
+ },
52
+ },
53
+ },
54
+ });
55
+
56
+ const createAgent = (overrides: Partial<McpAgent> = {}): McpAgent => ({
57
+ id: 'agent-1',
58
+ name: 'My Agent',
59
+ projectId: 'project-1',
60
+ ...overrides,
61
+ });
62
+
63
+ const agentPage = (data: McpAgent[] = []) => ({ data, count: data.length });
64
+
65
+ const mockAgentPages = (data: McpAgent[] = []) => {
66
+ mcpStore.fetchAgentsAvailableForMCPPage.mockImplementation(async (page: number) => ({
67
+ ...agentPage(data),
68
+ page,
69
+ }));
70
+ };
71
+
72
+ describe('SettingsMCPAgentsView', () => {
73
+ beforeEach(() => {
74
+ pinia = createTestingPinia();
75
+ mcpStore = mockedStore(useMCPStore);
76
+ settingsStore = mockedStore(useSettingsStore);
77
+
78
+ settingsStore.settings = {
79
+ enterprise: {},
80
+ } as FrontendSettings;
81
+
82
+ settingsStore.moduleSettings = {
83
+ mcp: {
84
+ mcpAccessEnabled: true,
85
+ mcpManagedByEnv: false,
86
+ autoExposeNewWorkflows: false,
87
+ },
88
+ };
89
+ settingsStore.isAgentsEnabled = true;
90
+
91
+ mockAgentPages();
92
+ });
93
+
94
+ afterEach(() => {
95
+ vi.clearAllMocks();
96
+ });
97
+
98
+ it('should redirect to the MCP settings view when MCP is disabled', async () => {
99
+ settingsStore.moduleSettings = {
100
+ mcp: {
101
+ mcpAccessEnabled: false,
102
+ mcpManagedByEnv: false,
103
+ autoExposeNewWorkflows: false,
104
+ },
105
+ };
106
+
107
+ createComponent({ pinia });
108
+ await nextTick();
109
+
110
+ expect(routerReplace).toHaveBeenCalledWith({ name: MCP_SETTINGS_VIEW });
111
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).not.toHaveBeenCalled();
112
+ });
113
+
114
+ it('should redirect to the MCP settings view when agents are disabled', async () => {
115
+ settingsStore.isAgentsEnabled = false;
116
+
117
+ createComponent({ pinia });
118
+ await nextTick();
119
+
120
+ expect(routerReplace).toHaveBeenCalledWith({ name: MCP_SETTINGS_VIEW });
121
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).not.toHaveBeenCalled();
122
+ });
123
+
124
+ describe('Agent pagination', () => {
125
+ beforeEach(() => {
126
+ mockAgentPages([createAgent({ id: '1', name: 'Agent 1' })]);
127
+ });
128
+
129
+ it('should fetch the first agent page on mount', async () => {
130
+ createComponent({ pinia });
131
+
132
+ await waitFor(() => {
133
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(1, 10);
134
+ });
135
+ });
136
+
137
+ it('should fetch the selected agent page when table options change', async () => {
138
+ const { getByTestId } = createComponent({ pinia });
139
+
140
+ await waitFor(() => {
141
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(1, 10);
142
+ });
143
+ mcpStore.fetchAgentsAvailableForMCPPage.mockClear();
144
+
145
+ await userEvent.click(getByTestId('agents-table-page-2'));
146
+
147
+ await waitFor(() => {
148
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(2, 10);
149
+ });
150
+ });
151
+
152
+ it('should reset to first page when agent table page size changes', async () => {
153
+ const { getByTestId } = createComponent({ pinia });
154
+
155
+ await waitFor(() => {
156
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(1, 10);
157
+ });
158
+ mcpStore.fetchAgentsAvailableForMCPPage.mockClear();
159
+
160
+ await userEvent.click(getByTestId('agents-table-page-size-50'));
161
+
162
+ await waitFor(() => {
163
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(1, 50);
164
+ });
165
+ });
166
+ });
167
+
168
+ describe('Connect Agents button', () => {
169
+ it('should not show the button when there are no agents', async () => {
170
+ mockAgentPages();
171
+
172
+ const { queryByTestId } = createComponent({ pinia });
173
+
174
+ await waitFor(() => {
175
+ expect(queryByTestId('mcp-connect-agents-header-button')).not.toBeInTheDocument();
176
+ });
177
+ });
178
+
179
+ it('should open the Connect Agents modal when the button is clicked', async () => {
180
+ mockAgentPages([createAgent({ id: '1', name: 'Agent 1' })]);
181
+
182
+ const { getByTestId } = createComponent({ pinia });
183
+
184
+ await waitFor(() => {
185
+ expect(getByTestId('mcp-connect-agents-header-button')).toBeVisible();
186
+ });
187
+ await userEvent.click(getByTestId('mcp-connect-agents-header-button'));
188
+
189
+ expect(getByTestId('mcp-connect-agents-dialog-stub')).toBeInTheDocument();
190
+ });
191
+ });
192
+
193
+ describe('Bulk agent actions', () => {
194
+ beforeEach(() => {
195
+ mockAgentPages([createAgent({ id: '1', name: 'Agent 1' })]);
196
+ mcpStore.toggleAgentsMcpAccess.mockResolvedValue({
197
+ updatedCount: 2,
198
+ updatedIds: ['agent-1', 'agent-2'],
199
+ unchangedIds: [],
200
+ });
201
+ });
202
+
203
+ it('should bulk-enable the agents selected in the Connect Agents modal', async () => {
204
+ const { getByTestId } = createComponent({ pinia });
205
+
206
+ await waitFor(() => {
207
+ expect(getByTestId('mcp-connect-agents-header-button')).toBeVisible();
208
+ });
209
+ await userEvent.click(getByTestId('mcp-connect-agents-header-button'));
210
+ mcpStore.fetchAgentsAvailableForMCPPage.mockClear();
211
+
212
+ await userEvent.click(getByTestId('stub-enable-access'));
213
+
214
+ await waitFor(() => {
215
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalledWith(1, 10);
216
+ });
217
+ expect(mcpStore.toggleAgentsMcpAccess).toHaveBeenCalledWith(
218
+ { agentIds: ['agent-1', 'agent-2'] },
219
+ true,
220
+ );
221
+ });
222
+
223
+ it('should disable MCP access for bulk-selected agents and refresh the table', async () => {
224
+ const { getByTestId } = createComponent({ pinia });
225
+ await nextTick();
226
+ mcpStore.fetchAgentsAvailableForMCPPage.mockClear();
227
+
228
+ await userEvent.click(getByTestId('agents-table-bulk-remove'));
229
+
230
+ await waitFor(() => {
231
+ expect(mcpStore.toggleAgentsMcpAccess).toHaveBeenCalledWith(
232
+ { agentIds: ['agent-1', 'agent-2'] },
233
+ false,
234
+ );
235
+ });
236
+ await waitFor(() => {
237
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalled();
238
+ });
239
+ });
240
+ });
241
+
242
+ describe('Refresh button', () => {
243
+ it('should refresh the agents list', async () => {
244
+ const { getByTestId } = createComponent({ pinia });
245
+ await nextTick();
246
+
247
+ mcpStore.fetchAgentsAvailableForMCPPage.mockClear();
248
+
249
+ await userEvent.click(getByTestId('mcp-agents-refresh-button'));
250
+
251
+ await waitFor(() => {
252
+ expect(mcpStore.fetchAgentsAvailableForMCPPage).toHaveBeenCalled();
253
+ });
254
+ });
255
+ });
256
+ });