aws / aws/amazon-q-developer-cli
Q CLI Profile-Specific MCP Server Not Loading Environment Variables
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
### 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
Contributor guide
Assessment
This issue has not been assessed yet.