Skip to content

fix: Format response text from server in example client implementation #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2025

Conversation

ryancormack
Copy link
Contributor

  • String(result) often ends up calling down to toString on the object. When there is a large JSON object, it ends up with object Object
  • This formats this, attempting to stringify objects, or eventually calling back down to String(text)

Issue #, if available:

Description of changes:

I was using the example here as a reference for implementing my own client, inside another Lambda function. The MCP Server it was calling was returning a large JSON object, which this client ends up parsing as [object Object].
This change formats various possibilities.

I know this is an example of a chat client here, but wanted to propose this, in case anyone else uses this as reference for their own clients.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

- `String(result)` often ends up calling down to toString on the object. When there is a large JSON object, it ends up with `object Object`
- This formats this, attempting to stringify objects, or eventually calling back down to String(text)
@clareliguori clareliguori merged commit c0523cf into awslabs:main May 22, 2025
8 checks passed
@clareliguori
Copy link
Member

Thank you for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants