Skip to content

fix: disabling text content on mcp with option to enable it#3

Merged
codemug merged 4 commits into
mainfrom
fix/disable-text-content-mcp
Oct 12, 2025
Merged

fix: disabling text content on mcp with option to enable it#3
codemug merged 4 commits into
mainfrom
fix/disable-text-content-mcp

Conversation

@codemug

@codemug codemug commented Sep 30, 2025

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings September 30, 2025 12:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modifies MCP tool responses to return ToolResult objects with structured content instead of plain dictionaries, while adding an optional flag to include text content alongside structured content.

  • Replaced dictionary returns with ToolResult objects containing structured content
  • Added --text-content CLI flag to optionally enable text content in MCP responses
  • Updated test assertions to work with the new ToolResult format

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
aiofmp/mcp_tools.py Modified create_tool_response to return ToolResult with configurable text content
aiofmp/cli.py Added --text-content CLI option and environment variable support
aiofmp/mcp_server.py Added imports for ToolResult and ToolTransformConfig
tests/test_mcp_tools.py Updated test assertions to validate ToolResult objects and structured content
README.md Updated documentation to include the new --text-content option

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread aiofmp/mcp_tools.py Outdated
Comment thread aiofmp/mcp_tools.py
Comment on lines +42 to +45
if include_text_content:
# Return both text and structured content
import json
text_content = json.dumps(response, indent=2)

Copilot AI Sep 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import json statement should be moved to the top of the file to avoid repeated imports on each function call when text content is enabled.

Copilot uses AI. Check for mistakes.
Comment thread tests/test_mcp_tools.py
assert response["data"] == data
assert response["message"] == "Test message"
# Check that it's a ToolResult object
from fastmcp.tools.tool import ToolResult

Copilot AI Sep 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import statement is repeated in multiple test methods. Consider moving this import to the top of the file to avoid redundant imports and improve readability.

Copilot uses AI. Check for mistakes.
Comment thread aiofmp/cli.py
os.environ["MCP_PORT"] = str(port)

# Set text content flag
os.environ["MCP_INCLUDE_TEXT_CONTENT"] = str(text_content)

Copilot AI Sep 30, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting boolean text_content to string will result in 'True' or 'False', but the environment variable check in mcp_tools.py expects 'true' or 'false' (lowercase). This will cause the flag to not work as expected.

Suggested change
os.environ["MCP_INCLUDE_TEXT_CONTENT"] = str(text_content)
os.environ["MCP_INCLUDE_TEXT_CONTENT"] = "true" if text_content else "false"

Copilot uses AI. Check for mistakes.
@codemug codemug merged commit f03afaa into main Oct 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants