@@ -33,23 +33,45 @@ if (!command || command === "serve") {
3333 const { homedir } = await import ( "os" ) ;
3434
3535 const home = homedir ( ) ;
36- const mcpEntry = {
36+
37+ // mcpServers format (Claude Code, Cursor, Windsurf)
38+ const mcpServersEntry = {
3739 command : "npx" ,
3840 args : [ "cachebro" , "serve" ] ,
3941 } ;
4042
43+ // opencode format (mcp key, command is a single array)
44+ const opencodeMcpEntry = {
45+ type : "local" as const ,
46+ command : [ "npx" , "cachebro" , "serve" ] ,
47+ } ;
48+
49+ const xdgConfig = process . env . XDG_CONFIG_HOME || join ( home , ".config" ) ;
50+
4151 const targets = [
4252 {
4353 name : "Claude Code" ,
4454 path : join ( home , ".claude.json" ) ,
55+ key : "mcpServers" ,
56+ entry : mcpServersEntry ,
4557 } ,
4658 {
4759 name : "Cursor" ,
4860 path : join ( home , ".cursor" , "mcp.json" ) ,
61+ key : "mcpServers" ,
62+ entry : mcpServersEntry ,
4963 } ,
5064 {
5165 name : "Windsurf" ,
5266 path : join ( home , ".codeium" , "windsurf" , "mcp_config.json" ) ,
67+ key : "mcpServers" ,
68+ entry : mcpServersEntry ,
69+ } ,
70+ {
71+ name : "OpenCode" ,
72+ path : join ( xdgConfig , "opencode" , "opencode.json" ) ,
73+ key : "mcp" ,
74+ entry : opencodeMcpEntry ,
5375 } ,
5476 ] ;
5577
@@ -69,22 +91,22 @@ if (!command || command === "serve") {
6991 }
7092 }
7193
72- if ( config . mcpServers ?. cachebro ) {
94+ if ( config [ target . key ] ?. cachebro ) {
7395 console . log ( ` ${ target . name } : already configured` ) ;
7496 configured ++ ;
7597 continue ;
7698 }
7799
78- config . mcpServers = config . mcpServers ?? { } ;
79- config . mcpServers . cachebro = mcpEntry ;
100+ config [ target . key ] = config [ target . key ] ?? { } ;
101+ config [ target . key ] . cachebro = target . entry ;
80102 writeFileSync ( target . path , JSON . stringify ( config , null , 2 ) + "\n" ) ;
81103 console . log ( ` ${ target . name } : configured (${ target . path } )` ) ;
82104 configured ++ ;
83105 }
84106
85107 if ( configured === 0 ) {
86108 console . log ( "No supported tools detected. You can manually add cachebro to your MCP config:" ) ;
87- console . log ( JSON . stringify ( { mcpServers : { cachebro : mcpEntry } } , null , 2 ) ) ;
109+ console . log ( JSON . stringify ( { mcpServers : { cachebro : mcpServersEntry } } , null , 2 ) ) ;
88110 } else {
89111 console . log ( `\nDone! Restart your editor to pick up cachebro.` ) ;
90112 }
0 commit comments