Skip to content

Fix/remove indent in server result (issue 114) #115

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fastapi_mcp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ async def _execute_api_tool(
# TODO: Better typing for the AsyncClientProtocol. It should return a ResponseProtocol that has a json() method that returns a dict/list/etc.
try:
result = response.json()
result_text = json.dumps(result, indent=2, ensure_ascii=False)
result_text = json.dumps(result, indent=None, ensure_ascii=False)
except json.JSONDecodeError:
if hasattr(response, "text"):
result_text = response.text
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mcp_execute_api_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def test_execute_api_tool_success(simple_fastapi_app: FastAPI):
# Verify the result
assert len(result) == 1
assert isinstance(result[0], TextContent)
assert result[0].text == '{\n "id": 1,\n "name": "Test Item"\n}'
assert result[0].text == '{"id": 1, "name": "Test Item"}'

# Verify the HTTP client was called correctly
mock_client.get.assert_called_once_with(
Expand Down