@@ -10,7 +10,7 @@ import { setupRoutes } from './connect'
10
10
11
11
export * from './types'
12
12
13
- const CONSOLE_LOG_PREFIX = c . cyan . bold ` ➜ MCP: `
13
+ const CONSOLE_LOG_PREFIX = c . cyan . bold `[ MCP] `
14
14
15
15
export function ViteMcp ( options : ViteMcpOptions = { } ) : Plugin {
16
16
const {
@@ -35,14 +35,19 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
35
35
36
36
if ( printUrl ) {
37
37
// eslint-disable-next-line no-console
38
- console . log ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Mcp server is running at ${ c . green ( sseUrl ) } ` ) } ` )
38
+ console . log ( `${ c . cyan ` ➜ MCP: ` } ${ c . gray ( `Mcp server is running at ${ c . green ( sseUrl ) } ` ) } ` )
39
39
}
40
- await updateConfigs ( root , sseUrl , options )
40
+ await updateConfigs ( root , sseUrl , options , vite )
41
41
} ,
42
42
}
43
43
}
44
44
45
- async function updateConfigs ( root : string , sseUrl : string , options : ViteMcpOptions ) : Promise < void > {
45
+ async function updateConfigs (
46
+ root : string ,
47
+ sseUrl : string ,
48
+ options : ViteMcpOptions ,
49
+ vite : ViteDevServer ,
50
+ ) : Promise < void > {
46
51
const {
47
52
updateConfig = 'auto' ,
48
53
updateConfigServerName = 'vite' ,
@@ -74,8 +79,7 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
74
79
mcp . mcpServers [ server . name ] = { url : server . url }
75
80
}
76
81
await fs . writeFile ( join ( root , '.cursor/mcp.json' ) , `${ JSON . stringify ( mcp , null , 2 ) } \n` )
77
- // eslint-disable-next-line no-console
78
- console . log ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ join ( root , '.cursor/mcp.json' ) } ` ) } ` )
82
+ vite . config . logger . info ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ join ( root , '.cursor/mcp.json' ) } ` ) } ` )
79
83
}
80
84
81
85
// VSCode
@@ -96,8 +100,7 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
96
100
}
97
101
}
98
102
await fs . writeFile ( join ( root , '.vscode/mcp.json' ) , `${ JSON . stringify ( mcp , null , 2 ) } \n` )
99
- // eslint-disable-next-line no-console
100
- console . log ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ join ( root , '.vscode/mcp.json' ) } ` ) } ` )
103
+ vite . config . logger . info ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ join ( root , '.vscode/mcp.json' ) } ` ) } ` )
101
104
}
102
105
103
106
// Windsurf
@@ -115,11 +118,10 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
115
118
config . mcpServers [ server . name ] = { serverUrl : server . url }
116
119
}
117
120
await fs . writeFile ( windsurfConfigPath , `${ JSON . stringify ( config , null , 2 ) } \n` )
118
- // eslint-disable-next-line no-console
119
- console . log ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ windsurfConfigPath } ` ) } ` )
121
+ vite . config . logger . info ( `${ CONSOLE_LOG_PREFIX } ${ c . gray ( `Updated config file ${ windsurfConfigPath } ` ) } ` )
120
122
}
121
123
catch ( e ) {
122
- console . error ( `${ CONSOLE_LOG_PREFIX } ${ c . red ( `Failed to update ${ windsurfConfigPath } ` ) } ` , e )
124
+ vite . config . logger . error ( `${ CONSOLE_LOG_PREFIX } ${ c . red ( `Failed to update ${ windsurfConfigPath } ` ) } ${ e } ` )
123
125
}
124
126
}
125
127
}
0 commit comments