Convert Content Tool Reference
convert_content currently supports local path input and remote url input. Remote URLs are safely downloaded to a temporary file first, then converted to Markdown through the configured MarkItDown CLI provider. TUI renderers and toolkit-level activity integration are implemented.
Canonical source: src/modules/convert/ and src/config/load-config.ts.
Tool
| Tool | Status | Purpose |
|---|---|---|
convert_content | Local path and URL conversion implemented | Convert local files or safely downloaded remote files to Markdown with MarkItDown CLI |
Parameters
{
path?: string,
url?: string,
maxContentChars?: number,
timeoutMs?: number
}Execution validates that exactly one of path or url is provided. Providing both or neither returns INVALID_INPUT.
Current tool behavior
convertContent.enabled=falsedisables tool registration.pathmust point to an existing local file inside the active workspace (process.cwd()for the extension process). Missing paths and directories returnFILE_NOT_FOUND; paths outside the workspace returnINVALID_INPUT.- Local files larger than
convertContent.maxResponseBytesreturnFILE_TOO_LARGEbefore provider execution. urlmust usehttp:orhttps:. Other protocols returnUNSUPPORTED_PROTOCOL.- Remote URLs are validated with private-network protection before download.
- Every redirect hop is revalidated with the same private-network policy before being followed.
- Current DNS validation happens before
fetch; this blocks common private-network targets but does not claim to eliminate all DNS rebinding / DNS TOCTOU risks. Attacker-controlled DNS can still create a time-of-check/time-of-use gap because the checked IP is not pinned to the actual connection. High-risk environments should disable remote URL conversion or keepconvertContent.allowPrivateNetwork=falseuntil connection-stage IP pinning is designed and implemented. - Remote responses larger than
convertContent.maxResponseBytesreturnFILE_TOO_LARGEbefore provider execution. - Temporary downloaded files are removed after conversion succeeds or fails.
- Local and downloaded file conversion invokes the configured MarkItDown CLI provider.
- Per-call
timeoutMsandmaxContentCharsoverride config defaults when they are positive integers. - Provider output beyond
maxContentCharsis truncated withtruncated=trueafter the external command finishes. - External command stdout/stderr also have hard byte limits in
src/shared/external-command.ts; exceeding them stops the command and maps toCONVERT_FAILEDwith an output-size message. - Tool calls include compact/expanded TUI renderers for call/result display.
- Successful and failed conversions are recorded in the shared toolkit activity log with
type="convert". allowPrivateNetwork=falseblocks localhost, loopback, private, link-local, metadata-style, and internal hostnames/IPs by default. SetconvertContent.allowPrivateNetwork=trueonly for trusted environments.file_pathis not a supported canonical field; usepath.
MarkItDown provider status
src/modules/convert/provider.ts implements MarkItDownProvider:
- Uses
src/shared/external-command.tsfor configured MarkItDown CLI command availability checks and execution. - Invokes the configured executable with the input file as a structured argument, without shell interpolation.
- Applies conversion timeout through the shared external command runner.
- Checks input file size against
maxResponseBytesin the convert provider before execution. - Receives stdout/stderr from the shared runner, capped by the runner's stdout/stderr hard byte limits.
- Maps missing command, timeout, output-size limit, non-zero exit, and file-too-large failures to convert error codes.
- Truncates stdout to
maxContentCharsand returnstruncated=true.
src/shared/external-command.ts is infrastructure only: it resolves/runs short external commands and collects stdout/stderr. MarkItDown-specific behavior, convert error mapping, file-size checks, metadata, and output truncation remain in src/modules/convert/provider.ts.
Success result
{
source: string,
provider: "markitdown",
content: string,
truncated: boolean,
metadata?: {
contentType?: string,
fileName?: string,
fileSize?: number,
durationMs?: number
}
}Error codes
INVALID_INPUT
FILE_NOT_FOUND
FILE_TOO_LARGE
UNSUPPORTED_PROTOCOL
COMMAND_NOT_FOUND
CONVERT_TIMEOUT
CONVERT_FAILED
NETWORK_ERROR
PRIVATE_NETWORK_BLOCKEDSee Configuration for convertContent defaults.