@@ -13,6 +13,7 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
13
13
const {
14
14
mcpPath = '/__mcp' ,
15
15
updateCursorMcpJson = true ,
16
+ updateVSCodeMcpJson = true ,
16
17
printUrl = true ,
17
18
mcpServer = ( vite : ViteDevServer ) => import ( './server' ) . then ( m => m . createMcpServerDefault ( options , vite ) ) ,
18
19
} = options
@@ -21,6 +22,10 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
21
22
? { enabled : updateCursorMcpJson }
22
23
: updateCursorMcpJson
23
24
25
+ const vscodeMcpOptions = typeof updateVSCodeMcpJson == 'boolean'
26
+ ? { enabled : updateVSCodeMcpJson }
27
+ : updateVSCodeMcpJson
28
+
24
29
return {
25
30
name : 'vite-plugin-mcp' ,
26
31
async configureServer ( vite ) {
@@ -44,6 +49,21 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
44
49
}
45
50
}
46
51
52
+ if ( vscodeMcpOptions . enabled ) {
53
+ const vscodeConfig = join ( root , '.vscode/settings.json' )
54
+ if ( existsSync ( vscodeConfig ) ) {
55
+ const mcp = existsSync ( join ( root , '.vscode/mcp.json' ) )
56
+ ? JSON . parse ( await fs . readFile ( join ( root , '.vscode/mcp.json' ) , 'utf-8' ) || '{}' )
57
+ : { }
58
+ mcp . servers ||= { }
59
+ mcp . servers [ vscodeMcpOptions . serverName || 'vite' ] = {
60
+ type : 'sse' ,
61
+ url : sseUrl ,
62
+ }
63
+ await fs . writeFile ( join ( root , '.vscode/mcp.json' ) , `${ JSON . stringify ( mcp , null , 2 ) } \n` )
64
+ }
65
+ }
66
+
47
67
if ( printUrl ) {
48
68
setTimeout ( ( ) => {
49
69
// eslint-disable-next-line no-console
0 commit comments