aws / aws/amazon-q-developer-cli

Q CLI Profile-Specific MCP Server Not Loading Environment Variables

Aperta
#2,101 0 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
2k
Fork
439
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### Checks

- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue

### Operating system

macOS 15.5.0 (24F74)

### Expected behaviour

I don't need all of the servers running all of the time. I would like to use profile-specific servers, particularly for the figma server. The figma server works correctly, which indicates that this is likely a q cli issue.

When using `q chat --profile figma`, the MCP server defined in `~/.aws/amazonq/profiles/figma/mcp.json` should start successfully with the environment variables specified in the configuration file.

### Actual behaviour

The Figma MCP server fails to start because it's not receiving the `FIGMA_API_KEY` environment variable from the profile-specific mcp.json configuration. The server exits with error: "[ERROR] Figma API key is required (set environment variable FIGMA_API_KEY)" even though the environment variable is properly defined in the profile's mcp.json file.

```
[chat-transcript]
I found the issue! The Figma

> y

The timeout indicates the server started successfully (it would have exited immediately with an error if the API key was still missing). Let me also check if there are any Q CLI logs that might give us more insight:
[Tool uses: execute_bash]

> t

[Tool uses: fs_read]

The logs don't show specific MCP server startup failures. Let me try running Q chat with the figma profile to see what happens:
[Tool uses: execute_bash]

Let me try without the debug flag:
[Tool uses: execute_bash]

Let me try a different approach to test the MCP server loading:
[Tool uses: execute_bash]

Based on my investigation, here's what I found and the likely issues:

## Root Cause Analysis

The main issue is that **the Figma MCP server is failing to start** because it's not receiving the `FIGMA_API_KEY` environment variable properly. Here's what's happening:

1. **Environment Variable Issue**: When I tested the server manually without the environment variable, it failed with: `[ERROR] Figma API key is required (set environment variable FIGMA_API_KEY)`

2. **MCP Configuration**: Your `mcp.json` file looks correct and includes the environment variable:
\```json
"env": {
"FIGMA_API_KEY": "TOKEN"
}
\```

## Potential Solutions

### 1. **Verify API Key Validity**
The API key might be expired or invalid. Test it manually:

\```bash
curl -H "X-Figma-Token: TOKEN" \
https://api.figma.com/v1/me
\```

### 2. **Test MCP Server Manually**
Verify the server works with the environment variable:

\```bash
cd /Users/kgarmoe/workplace/FigmaMCP/src/FigmaMCP
FIGMA_API_KEY=TOKEN npm start
\```

### 3. **Check Q CLI MCP Loading**
The Q CLI might not be properly passing environment variables to MCP servers. Try adding some debugging to see if the server is even being started.

### 4. **Alternative Configuration**
Try using a `.env` file in the MCP server directory instead:

\```bash
echo "FIGMA_API_KEY=TOKEN" > /Users/kgarmoe/workplace/FigmaMCP/src/FigmaMCP/.env
\```

### 5. **Check Q CLI Version**
Make sure you're using a recent version of Q CLI that properly supports profile-specific MCP configurations:

\```bash
q --version
\```

## Next Steps

1. First, test the API key validity with the curl command above
2. If the API key is valid, try the manual server test
3. If that works, the issue is likely with how Q CLI is loading profile-specific MCP servers
4. Consider filing a bug report with AWS if the profile-specific MCP loading isn't working as expected

The most likely issue is that Q CLI isn't properly passing the environment variables from the profile's `mcp.json` to the MCP server process.
[Tool uses: none]

> /issue

I can help you report an issue or make a feature request! I have access to a tool that can open a pre-filled GitHub issue template with your conversation context.
[Tool uses: report_issue]

(...truncated)
```

### Steps to reproduce

1. Create profile-specific MCP configuration at `~/.aws/amazonq/profiles/figma/mcp.json` with environment variables
2. Run `q chat --profile figma`
3. MCP server fails to start due to missing environment variable
4. Manual testing shows the server works when environment variable is provided directly

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia riproducendo il problema con q chat --profile figma e la configurazione ~/.aws/amazonq/profiles/figma/mcp.json specifica del profilo, quindi esamina il percorso di caricamento dei server MCP della CLI. Il lavoro è completato quando il FIGMA_API_KEY configurato raggiunge il server MCP specifico del profilo e il server Figma si avvia correttamente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.