@@ -2,6 +2,7 @@ import type { Plugin, ViteDevServer } from 'vite'
2
2
import type { ViteMcpOptions } from './types'
3
3
import { existsSync } from 'node:fs'
4
4
import fs from 'node:fs/promises'
5
+ import { homedir } from 'node:os'
5
6
import c from 'ansis'
6
7
import { join } from 'pathe'
7
8
import { searchForWorkspaceRoot } from 'vite'
@@ -14,6 +15,7 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
14
15
mcpPath = '/__mcp' ,
15
16
updateCursorMcpJson = true ,
16
17
updateVSCodeMcpJson = true ,
18
+ updateWindsurfMcpJson = true ,
17
19
printUrl = true ,
18
20
mcpServer = ( vite : ViteDevServer ) => import ( './server' ) . then ( m => m . createMcpServerDefault ( options , vite ) ) ,
19
21
} = options
@@ -26,6 +28,10 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
26
28
? { enabled : updateVSCodeMcpJson }
27
29
: updateVSCodeMcpJson
28
30
31
+ const windsurfMcpOptions = typeof updateWindsurfMcpJson === 'boolean'
32
+ ? { enabled : updateWindsurfMcpJson }
33
+ : updateWindsurfMcpJson
34
+
29
35
return {
30
36
name : 'vite-plugin-mcp' ,
31
37
async configureServer ( vite ) {
@@ -65,6 +71,25 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
65
71
}
66
72
}
67
73
74
+ if ( windsurfMcpOptions . enabled ) {
75
+ const windsurfDir = join ( homedir ( ) , '.codeium' , 'windsurf' )
76
+ const windsurfConfigPath = join ( windsurfDir , 'mcp_config.json' )
77
+ try {
78
+ if ( ! existsSync ( windsurfDir ) ) {
79
+ await fs . mkdir ( windsurfDir , { recursive : true } )
80
+ }
81
+ const config = existsSync ( windsurfConfigPath )
82
+ ? JSON . parse ( await fs . readFile ( windsurfConfigPath , 'utf-8' ) . catch ( ( ) => '{}' ) || '{}' )
83
+ : { }
84
+ config . mcpServers ||= { }
85
+ config . mcpServers [ windsurfMcpOptions . serverName || 'vite' ] = { url : sseUrl }
86
+ await fs . writeFile ( windsurfConfigPath , `${ JSON . stringify ( config , null , 2 ) } \n` )
87
+ }
88
+ catch ( e ) {
89
+ console . error ( `${ c . red . bold ( ' ➜ MCP (Windsurf): ' ) } Failed to update ${ windsurfConfigPath } ` , e )
90
+ }
91
+ }
92
+
68
93
if ( printUrl ) {
69
94
setTimeout ( ( ) => {
70
95
// eslint-disable-next-line no-console
0 commit comments