Skip to content

Commit ebe2b53

Browse files
committed
fix(vite)!: rename mcpPath option to mcpRouteRoot
1 parent e6b32c5 commit ebe2b53

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/vite-plugin-mcp/src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ export * from './types'
1212

1313
export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
1414
const {
15-
mcpPath = '/__mcp',
1615
updateCursorMcpJson = true,
1716
updateVSCodeMcpJson = true,
1817
updateWindsurfMcpJson = true,
1918
printUrl = true,
2019
mcpServer = (vite: ViteDevServer) => import('./server').then(m => m.createMcpServerDefault(options, vite)),
2120
} = options
2221

22+
const mcpRoute = options.mcpRouteRoot ?? options.mcpPath ?? '/__mcp'
23+
2324
const cursorMcpOptions = typeof updateCursorMcpJson == 'boolean'
2425
? { enabled: updateCursorMcpJson }
2526
: updateCursorMcpJson
@@ -37,13 +38,13 @@ export function ViteMcp(options: ViteMcpOptions = {}): Plugin {
3738
async configureServer(vite) {
3839
let mcp = await mcpServer(vite)
3940
mcp = await options.mcpServerSetup?.(mcp, vite) || mcp
40-
await setupRoutes(mcpPath, mcp, vite)
41+
await setupRoutes(mcpRoute, mcp, vite)
4142

4243
const port = vite.config.server.port
4344
const root = searchForWorkspaceRoot(vite.config.root)
4445

4546
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`
4748

4849
if (cursorMcpOptions.enabled) {
4950
if (existsSync(join(root, '.cursor'))) {

packages/vite-plugin-mcp/src/types.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ export interface ViteMcpOptions {
4040
mcpServerSetup?: (server: McpServer, viteServer: ViteDevServer) => Awaitable<void | McpServer>
4141

4242
/**
43-
* The path to the MCP server, default is `/__mcp`
43+
* The root route to the MCP server, default is `/__mcp`
4444
*/
45-
mcpPath?: string
45+
mcpRouteRoot?: string
4646

4747
/**
4848
* Update the address of the MCP server in the cursor config file `.cursor/mcp.json`,
@@ -85,4 +85,9 @@ export interface ViteMcpOptions {
8585
*/
8686
serverName?: string
8787
}
88+
89+
/**
90+
* @deprecated Use `mcpRouteRoot` instead
91+
*/
92+
mcpPath?: string
8893
}

0 commit comments

Comments
 (0)