MCPcopy Create free account
hub / github.com/freecodexyz/free-code / getLargeOutputInstructions

Function getLargeOutputInstructions

src/utils/mcpOutputStorage.ts:39–59  ·  view source on GitHub ↗
(
  rawOutputPath: string,
  contentLength: number,
  formatDescription: string,
  maxReadLength?: number,
)

Source from the content-addressed store, hash-verified

37 * @returns Instruction text to include in the tool result
38 */
39export function getLargeOutputInstructions(
40 rawOutputPath: string,
41 contentLength: number,
42 formatDescription: string,
43 maxReadLength?: number,
44): string {
45 const baseInstructions =
46 `Error: result (${contentLength.toLocaleString()} characters) exceeds maximum allowed tokens. Output has been saved to ${rawOutputPath}.\n` +
47 `Format: ${formatDescription}\n` +
48 `Use offset and limit parameters to read specific portions of the file, search within it for specific content, and jq to make structured queries.\n` +
49 `REQUIREMENTS FOR SUMMARIZATION/ANALYSIS/REVIEW:\n` +
50 `- You MUST read the content from the file at ${rawOutputPath} in sequential chunks until 100% of the content has been read.\n`
51
52 const truncationWarning = maxReadLength
53 ? `- If you receive truncation warnings when reading the file ("[N lines truncated]"), reduce the chunk size until you have read 100% of the content without truncation ***DO NOT PROCEED UNTIL YOU HAVE DONE THIS***. Bash output is limited to ${maxReadLength.toLocaleString()} chars.\n`
54 : `- If you receive truncation warnings when reading the file, reduce the chunk size until you have read 100% of the content without truncation.\n`
55
56 const completionRequirement = `- Before producing ANY summary or analysis, you MUST explicitly describe what portion of the content you have read. ***If you did not read the entire content, you MUST explicitly state this.***\n`
57
58 return baseInstructions + truncationWarning + completionRequirement
59}
60
61/**
62 * Map a mime type to a file extension. Conservative: known types get their

Callers 1

processMCPResultFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected