@@ -125,24 +125,7 @@ variable "ai_prompt" {
125125locals {
126126 encoded_pre_install_script = var. experiment_pre_install_script != null ? base64encode (var. experiment_pre_install_script ) : " "
127127 encoded_post_install_script = var. experiment_post_install_script != null ? base64encode (var. experiment_post_install_script ) : " "
128- # We need to use allowed tools to limit the context Amazon Q receives.
129- # Amazon Q can't handle big contexts, and the `create_template_version` tool
130- # has a description that's too long.
131- mcp_json = << EOT
132- {
133- "mcpServers": {
134- "coder": {
135- "command": "coder",
136- "args": ["exp", "mcp", "server", "--allowed-tools", "coder_report_task"],
137- "env": {
138- "CODER_MCP_APP_STATUS_SLUG": "amazon-q"
139- }
140- }
141- }
142- }
143- EOT
144- encoded_mcp_json = base64encode (local. mcp_json )
145- full_prompt = <<- EOT
128+ full_prompt = <<- EOT
146129 ${ var . system_prompt }
147130
148131 Your first task is:
@@ -211,20 +194,19 @@ resource "coder_script" "amazon_q" {
211194 cd "$PREV_DIR"
212195 echo "Extracted auth tarball"
213196
197+ if [ "${ var . experiment_report_tasks } " = "true" ]; then
198+ echo "Configuring Amazon Q to report tasks via Coder MCP..."
199+ 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
200+ echo "Added Coder MCP server to Amazon Q configuration"
201+ fi
202+
214203 if [ -n "${ local . encoded_post_install_script } " ]; then
215204 echo "Running post-install script..."
216205 echo "${ local . encoded_post_install_script } " | base64 -d > /tmp/post_install.sh
217206 chmod +x /tmp/post_install.sh
218207 /tmp/post_install.sh
219208 fi
220209
221- if [ "${ var . experiment_report_tasks } " = "true" ]; then
222- echo "Configuring Amazon Q to report tasks via Coder MCP..."
223- mkdir -p ~/.aws/amazonq
224- echo "${ local . encoded_mcp_json } " | base64 -d > ~/.aws/amazonq/mcp.json
225- echo "Created the ~/.aws/amazonq/mcp.json configuration file"
226- fi
227-
228210 if [ "${ var . experiment_use_tmux } " = "true" ] && [ "${ var . experiment_use_screen } " = "true" ]; then
229211 echo "Error: Both experiment_use_tmux and experiment_use_screen cannot be true simultaneously."
230212 echo "Please set only one of them to true."
0 commit comments