@@ -10,7 +10,7 @@ import { setupRoutes } from './connect'
1010
1111export * from './types'
1212
13- const CONSOLE_LOG_PREFIX = c . cyan . bold ` ➜ MCP: `
13+ const CONSOLE_LOG_PREFIX = c . cyan . bold `[ MCP] `
1414
1515export function ViteMcp ( options : ViteMcpOptions = { } ) : Plugin {
1616 const {
@@ -35,14 +35,19 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
3535
3636 if ( printUrl ) {
3737 // 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 ) } ` ) } ` )
3939 }
40- await updateConfigs ( root , sseUrl , options )
40+ await updateConfigs ( root , sseUrl , options , vite )
4141 } ,
4242 }
4343}
4444
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 > {
4651 const {
4752 updateConfig = 'auto' ,
4853 updateConfigServerName = 'vite' ,
@@ -74,8 +79,7 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
7479 mcp . mcpServers [ server . name ] = { url : server . url }
7580 }
7681 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' ) } ` ) } ` )
7983 }
8084
8185 // VSCode
@@ -96,8 +100,7 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
96100 }
97101 }
98102 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' ) } ` ) } ` )
101104 }
102105
103106 // Windsurf
@@ -115,11 +118,10 @@ async function updateConfigs(root: string, sseUrl: string, options: ViteMcpOptio
115118 config . mcpServers [ server . name ] = { serverUrl : server . url }
116119 }
117120 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 } ` ) } ` )
120122 }
121123 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 } ` )
123125 }
124126 }
125127}
0 commit comments