Skip to content

Improve error message when MCP gateway cannot reach upstream #82

@saivedant169

Description

@saivedant169

Problem

When the MCP gateway tries to proxy a tool call to an upstream and the upstream is down, it currently returns:

{"error":{"code":-32000,"message":"upstream error: Post \"http://localhost:3000\": dial tcp 127.0.0.1:3000: connect: connection refused"}}

That is technically correct but useless to a user. It should tell them what tool they called, which upstream was chosen, and what they can do about it.

Acceptance criteria

  • When the upstream call fails, the error message should include:
    • The tool name
    • The upstream name (from config)
    • A one-line suggestion (check that the upstream is running at <URL>)
  • A unit test in internal/mcpgw/server_test.go verifies the new error format
  • Existing tests still pass

Files to touch

  • internal/mcpgw/server.go (search for upstream error: )
  • internal/mcpgw/server_test.go

How to test locally

# Start AegisFlow with realworld.yaml but do NOT start the mock-mcp server
./bin/aegisflow --config configs/realworld.yaml

# In another terminal, trigger a tool call
./bin/aegisctl test-action --protocol mcp --tool github.list_repos --target foo

The error should tell you the upstream name and URL from the config so you know exactly what to fix.

Notes

Do not leak anything sensitive in the error message. Configuration values like the upstream URL are fine. Credentials, if any, are not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions