Skip to content

HTTP 201 Status Code Incorrectly Treated as Error in HTTP REST Tools #1759

@SaiRaj07

Description

@SaiRaj07

Prerequisites

  • I've searched the current open issues
  • I've updated to the latest version of Toolbox

Toolbox version

us-central1-docker.pkg.dev/database-toolbox/toolbox/toolbox:latest

Environment

No response

Client

No response

Expected Behavior

When an HTTP REST tool receives a 201 status code from an API endpoint, it should be treated as a successful response, as 201 indicates a resource was successfully created.

Current Behavior

MCP Toolbox throws a ToolError when receiving HTTP 201 responses:
ToolError: unexpected status code: 201, response body: {"created_at": null, "url": "https://www.dummytest.com/api/action/",
"test": "https://www.dummytest.com/api/device/xxxxx/"}

Steps to reproduce?

1.Configure an HTTP REST tool in tools.yaml that calls a POST endpoint
2.The API endpoint returns HTTP 201 with a valid response body showing the created resource
3.MCP Toolbox treats this as an error instead of success

Additional Details

https://github.com/googleapis/genai-toolbox/blob/main/internal/tools/http/http.go
Looks like anything other than 200 is considered as error
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected status code: %d, response body: %s", resp.StatusCode, string(body))
}

No response

Metadata

Metadata

Assignees

Labels

type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions