From 88fbb9842e61f2c2c566221bc70a91834647ed58 Mon Sep 17 00:00:00 2001 From: Michael Orlov Date: Tue, 22 Jul 2025 11:31:39 -0400 Subject: [PATCH 1/5] fix: improve Amazon Q MCP integration using q mcp add command - Replace manual mcp.json file creation with q mcp add command - Reorder execution to run MCP configuration before post-install scripts - Remove unused mcp_json and encoded_mcp_json local variables - Ensure proper MCP server registration using official Amazon Q CLI --- registry/coder/modules/amazon-q/main.tf | 32 ++++++------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/registry/coder/modules/amazon-q/main.tf b/registry/coder/modules/amazon-q/main.tf index 851aa062..2266eb37 100644 --- a/registry/coder/modules/amazon-q/main.tf +++ b/registry/coder/modules/amazon-q/main.tf @@ -125,24 +125,7 @@ variable "ai_prompt" { locals { encoded_pre_install_script = var.experiment_pre_install_script != null ? base64encode(var.experiment_pre_install_script) : "" encoded_post_install_script = var.experiment_post_install_script != null ? base64encode(var.experiment_post_install_script) : "" - # We need to use allowed tools to limit the context Amazon Q receives. - # Amazon Q can't handle big contexts, and the `create_template_version` tool - # has a description that's too long. - mcp_json = < /tmp/post_install.sh @@ -218,13 +207,6 @@ resource "coder_script" "amazon_q" { /tmp/post_install.sh fi - if [ "${var.experiment_report_tasks}" = "true" ]; then - echo "Configuring Amazon Q to report tasks via Coder MCP..." - mkdir -p ~/.aws/amazonq - echo "${local.encoded_mcp_json}" | base64 -d > ~/.aws/amazonq/mcp.json - echo "Created the ~/.aws/amazonq/mcp.json configuration file" - fi - if [ "${var.experiment_use_tmux}" = "true" ] && [ "${var.experiment_use_screen}" = "true" ]; then echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously." echo "Please set only one of them to true." From af2150e656919419989570207e818beba6c4a4f9 Mon Sep 17 00:00:00 2001 From: harleylrn Date: Tue, 22 Jul 2025 12:04:16 -0400 Subject: [PATCH 2/5] chore: bump amazon-q module version to 1.1.1 - Update version from 1.1.0 to 1.1.1 in README examples - Reflects patch release for MCP integration improvements --- registry/coder/modules/amazon-q/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/registry/coder/modules/amazon-q/README.md b/registry/coder/modules/amazon-q/README.md index e4fe0837..84bf7835 100644 --- a/registry/coder/modules/amazon-q/README.md +++ b/registry/coder/modules/amazon-q/README.md @@ -14,7 +14,7 @@ Run [Amazon Q](https://aws.amazon.com/q/) in your workspace to access Amazon's A ```tf module "amazon-q" { source = "registry.coder.com/coder/amazon-q/coder" - version = "1.1.0" + version = "1.1.1" agent_id = coder_agent.example.id # Required: see below for how to generate experiment_auth_tarball = var.amazon_q_auth_tarball @@ -82,7 +82,7 @@ module "amazon-q" { ```tf module "amazon-q" { source = "registry.coder.com/coder/amazon-q/coder" - version = "1.1.0" + version = "1.1.1" agent_id = coder_agent.example.id experiment_auth_tarball = var.amazon_q_auth_tarball experiment_use_tmux = true @@ -94,7 +94,7 @@ module "amazon-q" { ```tf module "amazon-q" { source = "registry.coder.com/coder/amazon-q/coder" - version = "1.1.0" + version = "1.1.1" agent_id = coder_agent.example.id experiment_auth_tarball = var.amazon_q_auth_tarball experiment_report_tasks = true @@ -106,7 +106,7 @@ module "amazon-q" { ```tf module "amazon-q" { source = "registry.coder.com/coder/amazon-q/coder" - version = "1.1.0" + version = "1.1.1" agent_id = coder_agent.example.id experiment_auth_tarball = var.amazon_q_auth_tarball experiment_pre_install_script = "echo Pre-install!" From 57cb762d2258113d74f9e9b8c90a0395eddfae81 Mon Sep 17 00:00:00 2001 From: Michael Orlov <34108460+harleylrn@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:23:03 -0400 Subject: [PATCH 3/5] fix: added --name parameter Missed --name parameter in the mcp addition --- registry/coder/modules/amazon-q/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/amazon-q/main.tf b/registry/coder/modules/amazon-q/main.tf index 2266eb37..40565956 100644 --- a/registry/coder/modules/amazon-q/main.tf +++ b/registry/coder/modules/amazon-q/main.tf @@ -196,7 +196,7 @@ resource "coder_script" "amazon_q" { if [ "${var.experiment_report_tasks}" = "true" ]; then echo "Configuring Amazon Q to report tasks via Coder MCP..." - q mcp add coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" + q mcp add --name coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" echo "Added Coder MCP server to Amazon Q configuration" fi From 4b082e61718291894fef722b18cb6c7ec6d736a0 Mon Sep 17 00:00:00 2001 From: Michael Orlov <34108460+harleylrn@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:27:20 -0400 Subject: [PATCH 4/5] feat: added --scope global Installing default MCP server in the global scope --- registry/coder/modules/amazon-q/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/amazon-q/main.tf b/registry/coder/modules/amazon-q/main.tf index 40565956..8e960483 100644 --- a/registry/coder/modules/amazon-q/main.tf +++ b/registry/coder/modules/amazon-q/main.tf @@ -196,7 +196,7 @@ resource "coder_script" "amazon_q" { if [ "${var.experiment_report_tasks}" = "true" ]; then echo "Configuring Amazon Q to report tasks via Coder MCP..." - q mcp add --name coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" + q mcp add --name coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" --scope global echo "Added Coder MCP server to Amazon Q configuration" fi From 06faa64432281fb6a72b2df28a79acb8e8e1a2bc Mon Sep 17 00:00:00 2001 From: Michael Orlov <34108460+harleylrn@users.noreply.github.com> Date: Wed, 23 Jul 2025 17:31:20 -0400 Subject: [PATCH 5/5] added --force Force MCP server installation --- registry/coder/modules/amazon-q/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/amazon-q/main.tf b/registry/coder/modules/amazon-q/main.tf index 8e960483..dcc03156 100644 --- a/registry/coder/modules/amazon-q/main.tf +++ b/registry/coder/modules/amazon-q/main.tf @@ -196,7 +196,7 @@ resource "coder_script" "amazon_q" { if [ "${var.experiment_report_tasks}" = "true" ]; then echo "Configuring Amazon Q to report tasks via Coder MCP..." - q mcp add --name coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" --scope global + q mcp add --name coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q" --scope global --force echo "Added Coder MCP server to Amazon Q configuration" fi