Skip to content

feat(mcp): add file output for large conversions#2202

Open
dexhunter wants to merge 1 commit into
microsoft:mainfrom
dexhunter:weco/mcp-file-output
Open

feat(mcp): add file output for large conversions#2202
dexhunter wants to merge 1 commit into
microsoft:mainfrom
dexhunter:weco/mcp-file-output

Conversation

@dexhunter

@dexhunter dexhunter commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Add an opt-in output_file mode to the MarkItDown MCP tool for conversions that exceed an MCP client's response limit.

The default convert_to_markdown(uri) behavior is unchanged. When output_file is set, the tool writes the complete markdown to a new permission-restricted file and returns its absolute path instead of returning the full document through MCP.

Motivation

Issue #1332 reports a 51,164-token conversion exceeding a 25,000-token MCP response limit and requests an option to write the result to a file. Returning a short local path avoids the response-size failure while preserving the full converted document. Automatic pagination from #1333 remains separate work.

Safety

  • Output files are created with mode 0600 on POSIX systems (platform-default permissions on Windows), and existing files are never overwritten.
  • Partial files are removed when a write fails.
  • The documentation covers shared-filesystem and Docker volume usage and makes clear that the caller owns cleanup.

Evidence

A strict synthetic large-document evaluation measured the MCP tool result:

baseline_response_bytes: 665020
output_file_response_bytes: 29
reduction: 99.996%
behavior_hash: 20dd505e39710c8c (unchanged)

Supplementary autoresearch: public dashboard.

Validation

hatch test
# 6 passed

uvx ruff check --fix .
uvx black --check .
git diff --check

Fixes #1332

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.

MCP has no option to write the markdown to a file

1 participant