A FastMCP server implementation that allows other AI agents to interact with Amazon Q CLI through the Model Context Protocol (MCP).
- q_chat: Execute Q CLI chat commands with AI assistant
- q_whoami: Get current Q CLI user information
- q_diagnostic: Run Q CLI diagnostic tests
q_mcp_server/
├── q_cli_mcp/ # Main package directory
│ ├── __init__.py # Package initialization
│ └── server.py # MCP server implementation
├── pyproject.toml # Package configuration
├── requirements.txt # Dependencies
├── add_to_q.sh # Installation script
└── README.md # This file
./add_to_q.sh- Install the package dependencies:
uv sync- Add to Q CLI:
q mcp add q-cli-proxy --command "uvx" --args "--from /path/to/q_mcp_server q-cli-mcp-server"q mcp list
q mcp status --name q-cli-proxy# Using uv (in project environment)
uv run q-cli-mcp-server
# Using uvx (isolated environment)
uvx --from . q-cli-mcp-serverOnce added to Q CLI, you can use the tools:
q "Use the q_chat tool to ask: What is 1+1?"
q "Use the q_whoami tool to get user information"
q "Use the q_diagnostic tool to run diagnostics"The server uses FastMCP with proper subprocess handling for Q CLI commands:
- Non-interactive mode with trusted tools
- Proper stdin/stdout management
- Environment variable handling
- Robust error handling and logging
- Proper Python package structure with entry points
# Call q_chat tool
result = await session.call_tool("q_chat", {"prompt": "1+1"})
# Call q_whoami tool
result = await session.call_tool("q_whoami", {})
# Call q_diagnostic tool
result = await session.call_tool("q_diagnostic", {})q_cli_mcp/server.py: Main MCP server implementationq_cli_mcp/__init__.py: Package initializationpyproject.toml: Project and dependency configuration with entry pointsrequirements.txt: Python dependenciesadd_to_q.sh: Installation script
The MCP server configuration is stored in .amazonq/mcp.json and uses uvx for dependency isolation with proper package entry points.