Skip to content

How should I handle when the response from MCP or some tool is JSON, which contains the base64 encoding of the file. #1001

Open
@cthulhu-tww

Description

@cthulhu-tww

Question

For example, my MCP is a StreamableHttp, and the tool is text2image, which returns an image containing base64 in JSON. When I called the tool, I got an error: An error occurred while running the tool. Please try again. Error: Error code: 400 - {'error': {'code': 'invalid_parameter_error', 'param': None, 'message': '<400> InternalError.Algo.InvalidParameter: Range of input length should be [1, 129024]', 'type': 'invalid_request_error'}, 'id': 'chatcmpl-049fe5e6-3977-929d-b1ad-1b069f5980b5', 'request_id': '049fe5e6-3977-929d-b1ad-1b069f5980b5'}, After my investigation, I found that the error occurred in the _get_new_response() function. How should I preprocess my JSON before passing it as a parameter to this function, such as saving the file locally and modifying the JSON to a regular short string.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions