@@ -21,27 +21,29 @@ beforeEach(() => {
2121
2222describe ( 'claude disconnectMcpServer' , ( ) => {
2323 async function loadDisconnect ( ) {
24- const mod = await import ( '@integrations/claude/mcp.js' ) ;
24+ const mod = await import ( '@integrations/claude/mcp/index .js' ) ;
2525 return mod . disconnectMcpServer ;
2626 }
2727
28- it ( 'calls claude mcp remove with the server name' , async ( ) => {
29- const sut = await loadDisconnect ( ) ;
28+ it . each ( [ 'local' , 'project' , 'user' ] as const ) (
29+ 'calls claude mcp remove with %s scope' ,
30+ async ( scope ) => {
31+ const sut = await loadDisconnect ( ) ;
3032
31- await sut ( { serverName : 'confidence-flags' , projectDir : '/project' } ) ;
33+ await sut ( { serverName : 'confidence-flags' , projectDir : '/project' } ) ;
3234
33- expect ( execFile ) . toHaveBeenCalledWith (
34- 'claude' ,
35- [ 'mcp' , 'remove' , '--scope' , 'project' , 'confidence-flags' ] ,
36- { cwd : '/project' } ,
37- ) ;
38- } ) ;
35+ expect ( execFile ) . toHaveBeenCalledWith (
36+ 'claude' ,
37+ [ 'mcp' , 'remove' , '--scope' , scope , 'confidence-flags' ] ,
38+ { cwd : '/project' } ,
39+ ) ;
40+ } ,
41+ ) ;
3942
4043 it ( 'removes the tool permission from settings.local.json' , async ( ) => {
4144 using project = createProjectDir ( 'empty' ) ;
4245 writeClaudeSettings ( project . path , {
4346 permissions : { allow : [ 'mcp__confidence-flags__*' , 'mcp__other__*' ] } ,
44- enabledMcpjsonServers : [ 'confidence-flags' , 'other-server' ] ,
4547 } ) ;
4648 const sut = await loadDisconnect ( ) ;
4749
@@ -51,7 +53,6 @@ describe('claude disconnectMcpServer', () => {
5153 readFileSync ( join ( project . path , '.claude' , 'settings.local.json' ) , 'utf-8' ) ,
5254 ) ;
5355 expect ( settings . permissions . allow ) . toEqual ( [ 'mcp__other__*' ] ) ;
54- expect ( settings . enabledMcpjsonServers ) . toEqual ( [ 'other-server' ] ) ;
5556 } ) ;
5657
5758 it ( 'does not fail when settings.local.json does not exist' , async ( ) => {
@@ -67,32 +68,30 @@ describe('claude disconnectMcpServer', () => {
6768 using project = createProjectDir ( 'empty' ) ;
6869 writeClaudeSettings ( project . path , {
6970 permissions : { allow : [ 'mcp__confidence-flags__*' ] } ,
70- enabledMcpjsonServers : [ 'confidence-flags' ] ,
7171 } ) ;
72- execFile . mockRejectedValueOnce ( new Error ( 'claude not found' ) ) ;
72+ execFile . mockRejectedValue ( new Error ( 'claude not found' ) ) ;
7373 const sut = await loadDisconnect ( ) ;
7474
75- await expect ( sut ( { serverName : 'confidence-flags' , projectDir : project . path } ) ) . rejects . toThrow (
76- 'claude not found' ,
77- ) ;
75+ await sut ( { serverName : 'confidence-flags' , projectDir : project . path } ) ;
7876
7977 const settings = JSON . parse (
8078 readFileSync ( join ( project . path , '.claude' , 'settings.local.json' ) , 'utf-8' ) ,
8179 ) ;
8280 expect ( settings . permissions . allow ) . toEqual ( [ ] ) ;
83- expect ( settings . enabledMcpjsonServers ) . toEqual ( [ ] ) ;
8481 } ) ;
8582} ) ;
8683
8784describe ( 'cursor disconnectMcpServer' , ( ) => {
8885 async function loadDisconnect ( ) {
89- const mod = await import ( '@integrations/cursor/mcp.js' ) ;
86+ const mod = await import ( '@integrations/cursor/mcp/index .js' ) ;
9087 return mod . disconnectMcpServer ;
9188 }
9289
93- it ( 'removes the server entry from project config and CLI permissions' , async ( ) => {
90+ it ( 'removes the server from global config and CLI permissions' , async ( ) => {
9491 using project = createProjectDir ( 'empty' ) ;
95- writeCursorMcpConfig ( project . path , {
92+ using home = createProjectDir ( 'empty' ) ;
93+ vi . stubEnv ( 'HOME' , home . path ) ;
94+ writeCursorMcpConfig ( home . path , {
9695 mcpServers : {
9796 'confidence-flags' : { type : 'http' , url : 'https://example.com' } ,
9897 'other-server' : { type : 'http' , url : 'https://other.com' } ,
@@ -106,33 +105,14 @@ describe('cursor disconnectMcpServer', () => {
106105
107106 await sut ( { serverName : 'confidence-flags' , projectDir : project . path } ) ;
108107
109- const updatedMcp = JSON . parse ( readFileSync ( join ( project . path , '.cursor' , 'mcp.json' ) , 'utf-8' ) ) ;
110- expect ( updatedMcp . mcpServers ) . not . toHaveProperty ( 'confidence-flags' ) ;
111- expect ( updatedMcp . mcpServers ) . toHaveProperty ( 'other-server' ) ;
108+ const globalMcp = JSON . parse ( readFileSync ( join ( home . path , '.cursor' , 'mcp.json' ) , 'utf-8' ) ) ;
109+ expect ( globalMcp . mcpServers ) . not . toHaveProperty ( 'confidence-flags' ) ;
110+ expect ( globalMcp . mcpServers ) . toHaveProperty ( 'other-server' ) ;
112111
113112 const updatedCli = JSON . parse ( readFileSync ( join ( project . path , '.cursor' , 'cli.json' ) , 'utf-8' ) ) ;
114113 expect ( updatedCli . permissions . allow ) . toEqual ( [ 'Mcp(other:*)' ] ) ;
115114 } ) ;
116115
117- it ( 'does not remove the server from global config' , async ( ) => {
118- using project = createProjectDir ( 'empty' ) ;
119- using home = createProjectDir ( 'empty' ) ;
120- vi . stubEnv ( 'HOME' , home . path ) ;
121- writeCursorMcpConfig ( project . path , {
122- mcpServers : { 'confidence-flags' : { type : 'http' , url : 'https://example.com' } } ,
123- } ) ;
124- writeCursorMcpConfig ( home . path , {
125- mcpServers : { 'confidence-flags' : { type : 'http' , url : 'https://example.com' } } ,
126- } ) ;
127-
128- const sut = await loadDisconnect ( ) ;
129-
130- await sut ( { serverName : 'confidence-flags' , projectDir : project . path } ) ;
131-
132- const globalMcp = JSON . parse ( readFileSync ( join ( home . path , '.cursor' , 'mcp.json' ) , 'utf-8' ) ) ;
133- expect ( globalMcp . mcpServers ) . toHaveProperty ( 'confidence-flags' ) ;
134- } ) ;
135-
136116 it ( 'does not fail when config files do not exist' , async ( ) => {
137117 using project = createProjectDir ( 'empty' ) ;
138118 const sut = await loadDisconnect ( ) ;
@@ -145,7 +125,7 @@ describe('cursor disconnectMcpServer', () => {
145125
146126describe ( 'codex disconnectMcpServer' , ( ) => {
147127 async function loadDisconnect ( ) {
148- const mod = await import ( '@integrations/codex/mcp.js' ) ;
128+ const mod = await import ( '@integrations/codex/mcp/index .js' ) ;
149129 return mod . disconnectMcpServer ;
150130 }
151131
0 commit comments