@@ -12,14 +12,15 @@ export * from './types'
12
12
13
13
export function ViteMcp ( options : ViteMcpOptions = { } ) : Plugin {
14
14
const {
15
- mcpPath = '/__mcp' ,
16
15
updateCursorMcpJson = true ,
17
16
updateVSCodeMcpJson = true ,
18
17
updateWindsurfMcpJson = true ,
19
18
printUrl = true ,
20
19
mcpServer = ( vite : ViteDevServer ) => import ( './server' ) . then ( m => m . createMcpServerDefault ( options , vite ) ) ,
21
20
} = options
22
21
22
+ const mcpRoute = options . mcpRouteRoot ?? options . mcpPath ?? '/__mcp'
23
+
23
24
const cursorMcpOptions = typeof updateCursorMcpJson == 'boolean'
24
25
? { enabled : updateCursorMcpJson }
25
26
: updateCursorMcpJson
@@ -37,13 +38,13 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
37
38
async configureServer ( vite ) {
38
39
let mcp = await mcpServer ( vite )
39
40
mcp = await options . mcpServerSetup ?.( mcp , vite ) || mcp
40
- await setupRoutes ( mcpPath , mcp , vite )
41
+ await setupRoutes ( mcpRoute , mcp , vite )
41
42
42
43
const port = vite . config . server . port
43
44
const root = searchForWorkspaceRoot ( vite . config . root )
44
45
45
46
const protocol = vite . config . server . https ? 'https' : 'http'
46
- const sseUrl = `${ protocol } ://${ options . host || 'localhost' } :${ options . port || port } ${ mcpPath } /sse`
47
+ const sseUrl = `${ protocol } ://${ options . host || 'localhost' } :${ options . port || port } ${ mcpRoute } /sse`
47
48
48
49
if ( cursorMcpOptions . enabled ) {
49
50
if ( existsSync ( join ( root , '.cursor' ) ) ) {
0 commit comments