# Amazon Q Developer 介紹
:::success
AWS Blog : [Extend the Amazon Q Developer CLI with Model Context Protocol (MCP) for Richer Context](https://aws.amazon.com/blogs/devops/extend-the-amazon-q-developer-cli-with-mcp/)
更新時間:2025-04-30
:::
## 關於
### 使用須知
💻 **支援環境及語言(包含繁體中文)**:[Supported command line environments](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-supported-envs.html)
⚠️ **使用安全須知(請先閱讀)**:[Understanding security risks](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-chat-security.html)
### MCP 說明
Source : https://www.youtube.com/watch?v=N3vHJcHBS-w



### 操作 Q CLI 創建 AWS 資源說明

**`/help`** : show the below commands

**`/clear`** : clean up session history
**`/quit`** : quip q chat
**`/issue`**:
**`/compact`** : summary session history
```markdown!
# 錯誤1
Conversation too short to compact.
```
**`/tools`** : view and manage tools and permissions

**`/profile`** :
```markdown!
/profile create <profile name>
# Create a folder under ~/.aws/.amazonq/profiles
```
**`/prompts`** : View and retrieve prompts provided by mcp servers
```markdown!
@aws-docs explain-service --service=lambda
# Invoke the "explain-service" prompt from the "aws-docs" MCP server, passing "lambda" as the service argument.
```
**`/editor`** : Open $EDITOR (defaults to vi) to compose a prompt
```markdown!
/editor creates a fresh temporary file each time it's used
```
:::spoiler 關於 _/editor_ 最佳實踐
[(出自於官網)](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-editor.html)
指令組合最佳實踐:
• 當你需要參考特定檔案時,請先使用 /context 再使用 /editor
→ 這樣可以先建立上下文,再進入編輯狀態。
• 當你希望針對複雜問題得到簡明回應時,請先使用 /editor 再使用 /compact
→ 先進入編輯模式,再要求系統簡潔回答。
• 當你要開始全新主題時,請在 /editor 前使用 /clear
→ 清除先前對話,避免上下文干擾。
• 對於需要仔細撰寫後續問題的複雜、多段式對話,建議使用多個 /editor 工作階段
→ 便於分段處理、逐步推進問題。
• 在使用 /editor 前,請考量你目前的個人設定(Profile),以確保操作符合上下文
→ 選對對話模式,避免設定誤導 AI 回應。
:::
**`/context`** : Manage context files for the chat session

```markdown!
# Step 1
在指定路徑底下創建一個 file
# Step 2 將需要參考的檔案路徑加入 ~/.aws/.amazonq/profiles/<profile>/context.json
/context add <path/to/file>
/context show
# Step 3 開啟 editor 說明需要做什麼
/editor
# Step 4 移除 context
/editor rm <path/to/file>
```
**`/usage`** : tokens consumption

**`!`** 執行 Shell/Bash 命令
```bash!
Allow this action? Use 't' to trust (always allow) this tool for the session. [y/n/t]:
```
**`q doctor`**
**`q restart`**
---
## 前置作業
### 建立 GitHub 新專案
步驟 1 : Create a private repo in GitHub
步驟 2 : Initialized empty git repository in project directory
步驟 3 :
```
git init
git add *
git commit -m "first commit"
git branch -M main
git remote remove origin
git remote add origin <remote repository>
git push -u origin main
```
### 準備提示詞以及相關補充資訊
複製 prompt.txt 以及 AWS 架構圖到 local repo repository
---
## DEMO
### MCP Demo
提示詞 1 : [Amazon Nova Canvas MCP Server](https://awslabs.github.io/mcp/servers/nova-canvas-mcp-server/)
```bash!
Draw me a image : a girl in the forest
```
提示詞 2 : [Amazon Nova Canvas MCP Server](https://awslabs.github.io/mcp/servers/nova-canvas-mcp-server/)
```bash!
Draw me a image : A floating castle above the clouds at sunset, glowing with magical runes, surrounded by flying dragons and waterfalls pouring from the sky
幫我畫一張圖,關於雲和風和樹林的故事,史迪奇在畫面裡背對著,和他的主人
```
提示詞 3 : [MCP with Perplexity's Sonar API](https://docs.perplexity.ai/guides/mcp-server)
```bash!
Search mcp related trend using perplexity
搜尋關於NVIDIA股票價格
川普關稅政策的發展
```
提示詞 4 : 預設 Q's 工具,無需安奘
```bash!
Give me all s3 bucket names which start with *sagemaker* in us-east-1
```
提示詞 5 : [Cost Analysis MCP Server](https://awslabs.github.io/mcp/servers/cost-analysis-mcp-server/)
```bash!
Can you use get_pricing_from_api and provide me the pricing information for S3 Bucket in my account in us-east-1 region?
Can you use get_pricing_from_web and provide me the pricing info about ec2 capacity block?
```
提示詞 7 : [Cost Analysis MCP Server](https://awslabs.github.io/mcp/servers/cost-analysis-mcp-server/)
```bash!
Can you create detailed cost analysis reports with unit pricing, calculation breakdowns, and pricing models using generate_cost_report?
```
提示詞 8 : [Cost Analysis MCP Server](https://awslabs.github.io/mcp/servers/cost-analysis-mcp-server/)
```bash!
Provide me the architecture pattern for Amazon Bedrock application of the Github repository https://github.com/aws-samples/aws-genai-llm-chatbot using get_bedrock_patterns.
```
提示詞 9 : [Cost Analysis MCP Server](https://awslabs.github.io/mcp/servers/cost-analysis-mcp-server/)
```bash!
Can you analyse the CDK project from the Github repository https://github.com/aws-samples/aws-genai-llm-chatbot using analyze_cdk_project?
Help me understand the cost implications of this CDK project?
```
提示詞 10 :
[使用說明](https://www.framelink.ai/docs/quickstart?utm_source=github&utm_medium=referral&utm_campaign=readme)
```bash!
Implement this Figma frame:
<figma url goes here>
```

提示詞 11 :
```markdown!
# 官網範例
Amazon Q> /editor
# Write in editor:
I need to design a database schema for a library management system.
Requirements:
- Track books, authors, publishers
- Handle member checkouts and returns
- Support reservations and waiting lists
- Generate overdue notices
# After getting Amazon Q's response with initial schema design
# Second use of editor for follow-up with specific implementation details
Amazon Q> /editor
# Write in editor:
Based on your proposed schema, I have some follow-up questions:
1. How would you modify the Member table to support different membership tiers?
2. What indexes would you recommend for optimizing checkout queries?
3. Can you show me SQL to create the Books and Authors tables with proper relationships?
```
提示詞 12 : [Airbnb MCP Server](https://github.com/openbnb-org/mcp-server-airbnb)
```
Airbnb options near Amazon's headquarters in Seattle for May 29 - June 1
```
提示詞 13 : [Travel Planner MCP Server](https://github.com/GongRzhe/TRAVEL-PLANNER-MCP-Server)
```
Could you use travel_planner to plan the trip?
```
---
### 使用 Q CLI 創建 AWS 資源
步驟 1 : Read .txt to see tasks I give you
步驟 2 : (Optional) I would like to use converse api, check the url in the .txt file to see how to use converse api.
```
...
{
"type": "image",
"source": {
"type": "base64",
"media_type": f"image/{image_format}",
"data": base64_image
}
}
...
```
步驟 3 : Please analyze <架構圖 PNG 檔案>
步驟 4 : Based on the analyzed result, Create Python CDK code
步驟 5 : Deploy the resources using CDK
步驟 6 : Analyze the images inside images folder
步驟 7 : (Change prompt if you like : Create a compelling product description for this item with a bunch of emojis) Translate results into Traditional Chinese (it may call translate API)
步驟 8 : (執行時間比較長) Check wa.txt and translate into traditional chinese
步驟 9 : (執行時間比較長/會遇到錯誤會自我fix) Hey, check wa.txt, this is a statement extracted from the well-architect doc of genai white paper released by aws, please implement wa in this cdk project. Save latency and token usage to s3.
步驟 10 : 創建 DEMO 測試 .py 檔案
---
## Appendix
### 更多 MCP Servers
- GitHub MCP servers [這裡](https://github.com/modelcontextprotocol/servers)
- FastMCP v2 [這裡](https://github.com/jlowin/fastmcp)
- Awesome MCP Servers [這裡](https://mcpservers.org/)
- AWS MCP Servers [這裡](https://github.com/awslabs/mcp)