@@ -57,7 +57,7 @@ export async function configureCopilot(vscodeContext: vscode.ExtensionContext, c
5757 const cliPath = await configuration . getCliPath ( ) ;
5858 /* eslint-disable @typescript-eslint/no-unsafe-return */
5959 const args = [ 'mcp' , '-t' , 'stdio' ] ;
60- const snykEnv = await getSnykMcpEnv ( configuration ) ;
60+ const snykEnv = getSnykMcpEnv ( configuration ) ;
6161 const processEnv : Env = { } ;
6262 Object . entries ( process . env ) . forEach ( ( [ key , value ] ) => {
6363 processEnv [ key ] = value ?? '' ;
@@ -105,7 +105,7 @@ export async function configureWindsurf(vscodeContext: vscode.ExtensionContext,
105105 Logger . debug ( `Windsurf base directory not found at ${ baseDir } , skipping MCP configuration.` ) ;
106106 } else {
107107 const cliPath = await configuration . getCliPath ( ) ;
108- const env = await getSnykMcpEnv ( configuration ) ;
108+ const env = getSnykMcpEnv ( configuration ) ;
109109 await ensureMcpServerInJson ( configPath , SERVER_KEY , cliPath , [ 'mcp' , '-t' , 'stdio' ] , env ) ;
110110 Logger . debug ( `Ensured Windsurf MCP config at ${ configPath } ` ) ;
111111 }
@@ -136,7 +136,7 @@ export async function configureCursor(vscodeContext: vscode.ExtensionContext, co
136136 if ( autoConfigureMcpServer ) {
137137 const configPath = path . join ( os . homedir ( ) , '.cursor' , 'mcp.json' ) ;
138138 const cliPath = await configuration . getCliPath ( ) ;
139- const env = await getSnykMcpEnv ( configuration ) ;
139+ const env = getSnykMcpEnv ( configuration ) ;
140140
141141 await ensureMcpServerInJson ( configPath , SERVER_KEY , cliPath , [ 'mcp' , '-t' , 'stdio' ] , env ) ;
142142 Logger . debug ( `Ensured Cursor MCP config at ${ configPath } ` ) ;
@@ -198,13 +198,13 @@ async function ensureMcpServerInJson(
198198 const existing = config . mcpServers [ keyToUse ] ;
199199 const desired : McpServer = { command, args, env } ;
200200
201- // Merge env: keep existing keys; override Snyk keys only if already present
201+ // Merge env: keep existing keys; add or override Snyk keys
202202 let resultingEnv : Env ;
203203 if ( existing && existing . env ) {
204204 resultingEnv = { ...existing . env } ;
205- const overrideKeys : ( keyof Env ) [ ] = [ 'SNYK_TOKEN ' , 'SNYK_CFG_ORG ' , 'SNYK_API ' ] ;
205+ const overrideKeys : ( keyof Env ) [ ] = [ 'SNYK_CFG_ORG ' , 'SNYK_API ' , 'IDE_CONFIG_PATH' , 'TRUSTED_FOLDERS '] ;
206206 for ( const k of overrideKeys ) {
207- if ( Object . hasOwn ( existing . env , k ) && typeof env [ k ] !== 'undefined' ) {
207+ if ( typeof env [ k ] !== 'undefined' ) {
208208 resultingEnv [ k ] = env [ k ] ;
209209 }
210210 }
@@ -309,7 +309,7 @@ async function ensureInGitignore(patterns: string[]): Promise<void> {
309309 ) ;
310310}
311311
312- async function getSnykMcpEnv ( configuration : IConfiguration ) : Promise < Env > {
312+ function getSnykMcpEnv ( configuration : IConfiguration ) : Env {
313313 const env : Env = { } ;
314314 if ( configuration . organization ) {
315315 env . SNYK_CFG_ORG = configuration . organization ;
@@ -321,11 +321,7 @@ async function getSnykMcpEnv(configuration: IConfiguration): Promise<Env> {
321321 if ( trustedFolders . length > 0 ) {
322322 env . TRUSTED_FOLDERS = trustedFolders . join ( ';' ) ;
323323 }
324- const token = await configuration . getToken ( ) ;
325- const authMethod = configuration . getAuthenticationMethod ( ) ;
326- if ( ( authMethod === 'pat' || authMethod === 'token' ) && token ) {
327- env . SNYK_TOKEN = token ;
328- }
324+ env . IDE_CONFIG_PATH = vscode . env . appName ;
329325
330326 return env ;
331327}
0 commit comments