Skip to content

fix/amazon-q mcp integration #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

harleylrn
Copy link

Description

This PR improves the Amazon Q module's MCP (Model Context Protocol) integration by using the official q mcp add command instead of manually creating JSON configuration files.

Type of Change

  • New module
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/coder/modules/amazon-q
New version: v1.1.1
Breaking change: [ ] Yes [X] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun run fmt)
  • Changes tested locally

✅ All module tests pass:
• (pass) amazon-q module > required variables
• (pass) amazon-q module > creates coder_script resource
• (pass) amazon-q module > creates coder_app resource
✅ Terraform validation: terraform validate confirms configuration is syntactically correct
✅ Code formatting: Applied terraform fmt successfully

Related Issues

None

Changes Made

Before

• Used manual JSON file creation: mkdir -p ~/.aws/amazonq and wrote to ~/.aws/amazonq/mcp.json
• Post-install script ran before MCP configuration
• Required complex JSON generation and base64 encoding

After

• Uses official Amazon Q CLI command: q mcp add coder --command "coder" --args "exp,mcp,server,--allowed-tools,coder_report_task" --env "CODER_MCP_APP_STATUS_SLUG=amazon-q"
• MCP configuration runs before post-install scripts (proper execution order)
• Removed unused mcp_json and encoded_mcp_json local variables
• Cleaner, more maintainable code

Michael Orlov and others added 2 commits July 22, 2025 11:31
- 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
- Update version from 1.1.0 to 1.1.1 in README examples
- Reflects patch release for MCP integration improvements
@DevelopmentCats
Copy link
Contributor

LGTM

Have you tested this by chance just to make sure everything still works as expected?

@harleylrn
Copy link
Author

As I didn't change anything in the module except the order of the command execution it shouldn't affect the module in any way.
I'll try to point our coder to my repo to verify that.

@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Jul 23, 2025

As I didn't change anything in the module except the order of the command execution it shouldn't affect the module in any way. I'll try to point our coder to my repo to verify that.

I'm pretty sure you are right too. It's very likely that it would still work. I am just always paranoid about checking these before pushing.

Missed --name parameter in the mcp addition
Installing default MCP server in the global scope
Force MCP server installation
@harleylrn
Copy link
Author

I'm pretty sure you are right too. It's very likely that it would still work. I am just always paranoid about checking these before pushing.

Totally understand and you were absolutely right 😄
Fixed the issues, now running smoothly:

Setting up Amazon Q CLI configuration...
Installing Amazon Q...
Downloading Amazon Q for x86_64...
Archive:  q.zip
  creating: q/
  inflating: q/install.sh            
  inflating: q/README                
  inflating: q/BUILD-INFO            
  creating: q/bin/
  inflating: q/bin/q                 
  inflating: q/bin/qterm             
  inflating: q/bin/qchat             
Installed Amazon Q version: q 1.12.7
Extracting auth tarball...
Extracted auth tarball
Configuring Amazon Q to report tasks via Coder MCP...

To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html


✓ Added MCP server 'coder' to 🌍 global

Added Coder MCP server to Amazon Q configuration
Running post-install script...
Running Amazon Q pre-install script logic...
Amazon Q CLI detected. Setting up rules...
Creating Amazon Q global context configuration...
Amazon Q global context configuration created at /home/coder/.aws/amazonq/global_context.json

📁 Created MCP config in '/home/coder/.amazonq/mcp.json'

To learn more about MCP safety, see https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-mcp-security.html


✓ Added MCP server 'github_remote' to 📄 workspace

Running Amazon Q in the background with tmux...

@matifali matifali added the version:patch Add to PRs requiring a patch version upgrade label Jul 24, 2025
@DevelopmentCats
Copy link
Contributor

Im going to review this and test it one last time today, and we can get this merged.

Everything is looking good so far. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
version:patch Add to PRs requiring a patch version upgrade
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants