amazon-q-developer-cli icon indicating copy to clipboard operation
amazon-q-developer-cli copied to clipboard

Improperly formed request

Open aqiao opened this issue 1 year ago • 3 comments

Checks

Operating system

macOS 13.1.0 (22C65)

Expected behaviour

i setup a mcp server on local laptop, then integrate it with q developer cli. After placing the mcp.json file in ~/.aws/amazonq, i can see my mcp tool by running /tools command, however when input any prompt in q cli, it show below error

⠏ Thinking...2025-05-14T07:20:26.419572Z ERROR q_chat: 949: An error occurred processing the current state e=Client(CodewhispererGenerateAssistantResponse(ServiceError(ServiceError { source: Unhandled(Unhandled { source: ErrorMetadata { code: Some("ValidationException"), message: Some("Improperly formed request."), extras: Some({"aws_request_id": "313be90a-9028-4e8c-b3a9-25056c0546f6"}) }, meta: ErrorMetadata { code: Some("ValidationException"), message: Some("Improperly formed request."), extras: Some({"aws_request_id": "313be90a-9028-4e8c-b3a9-25056c0546f6"}) } }), raw: Response { status: StatusCode(400), headers: Headers { headers: {"date": HeaderValue { _private: H1("Wed, 14 May 2025 07:20:26 GMT") }, "content-type": HeaderValue { _private: H1("application/x-amz-json-1.0") }, "content-length": HeaderValue { _private: H1("100") }, "connection": HeaderValue { _private: H1("keep-alive") }, "x-amzn-requestid": HeaderValue { _private: H1("313be90a-9028-4e8c-b3a9-25056c0546f6") }, "x-xss-protection": HeaderValue { _private: H1("1; mode=block") }, "strict-transport-security": HeaderValue { _private: H1("max-age=47304000; includeSubDomains") }, "x-frame-options": HeaderValue { _private: H1("DENY") }, "cache-control": HeaderValue { _private: H1("no-cache") }, "x-content-type-options": HeaderValue { _private: H1("nosniff") }} }, body: SdkBody { inner: Once(Some(b"{\"__type\":\"com.amazon.aws.codewhisperer#ValidationException\",\"message\":\"Improperly formed request.\"}")), retryable: true }, extensions: Extensions { extensions_02x: Extensions, extensions_1x: Extensions } } })))
Amazon Q is having trouble responding right now: 
   0: unhandled error (ValidationException)
   1: service error
   2: unhandled error (ValidationException)
   3: Error { code: "ValidationException", message: "Improperly formed request.", aws_request_id: "313be90a-9028-4e8c-b3a9-25056c0546f6" }

Location:
   /private/tmp/788abf33-519d-4264-918b-e563eeb425ff/crates/q_chat/src/lib.rs:1015

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Here is the mcp.json

{
  "mcpServers": {
    "hello": {
      "command": "/q-developer-workshop/file-server/venv/bin/python",
      "args": ["/q-developer-workshop/file-server/HelloWorldServer.py"],
      "env": {
        "COLORBT_SHOW_HIDDEN": "1",
        "RUST_BACKTRACE": "1"
      }
    }
  }
}

And here is my mcp server code

from mcp.server.fastmcp import FastMCP


mcp = FastMCP('hello')


@mcp.tool()
def say_hi():
    return "hello world"


if __name__ == '__main__':
    mcp.run(transport='stdio')

Actual behaviour

q developer cli could call my mcp tool

Steps to reproduce

No response

Environment

<This will be visible to anyone. Do not include personal or sensitive information>

[q-details]
version = "1.9.1"
hash = "5d2c2807cab9bc6c9dc5fcd05f92c7a979e8a4f7"
date = "2025-04-29T06:22:42.917989Z (15d ago)"
variant = "full"

[system-info]
os = "macOS 13.1.0 (22C65)"
chip = "Apple M1 Pro"
total-cores = 10
memory = "16.00 GB"

[environment]
cwd = "/Users/USER/.aws/amazonq"
cli-path = "/Users/USER/.aws/amazonq"
os = "Mac"
shell-path = "/bin/zsh"
shell-version = "5.8"
terminal = "macOS"
install-method = "unknown"

[env-vars]
PATH = "/opt/homebrew/opt/graphicsmagick/bin:/opt/apache-maven-3.8.4/bin:/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home/bin:/opt/spark-3.2.1-bin-hadoop3.2/bin:/Users/USER/PycharmProjects/pythonProject/venv/bin/python3.10:/Users/USER/anaconda3/bin:/Users/USER/anaconda3/condabin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/3.6/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/go/bin:/Users/USER/.local/bin:/opt/homebrew/bin"
QTERM_SESSION_ID = "cf8999a2bb8d4a34846b6505001320fe"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.9.1"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.apple.Terminal"

aqiao avatar May 14 '25 07:05 aqiao

I noticed there is an existing issue: https://github.com/aws/amazon-q-developer-cli/issues/1025

however it closed, so i have to raise a new one

aqiao avatar May 14 '25 07:05 aqiao

Same issue here. I have a simple FastMCP server defined in my mcp.json. In Q, asking Hello causes the same 'Improperly formed request' error. If I remove the definition, Q works. This was working before I updated to 1.13.3.

xojins avatar Aug 13 '25 15:08 xojins

Did anyone find a fix to this issue?

AmayX avatar Oct 26 '25 17:10 AmayX