aws / aws/amazon-q-developer-cli

Q CLI Profile-Specific MCP Server Not Loading Environment Variables

オープン
#2,101 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る
主要言語
Rust
スター
2k
フォーク
439
PR マージ指標
30日以内にマージされた PR はありません

説明

### 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

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず q chat --profile figma とプロファイル固有の ~/.aws/amazonq/profiles/figma/mcp.json 設定で問題を再現し、次に CLI の MCP サーバー読み込みパスを調査します。設定された FIGMA_API_KEY がプロファイル固有の MCP サーバーに到達し、Figma サーバーが正常に起動すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
rust
領域
cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。