MCPcopy Create free account
hub / github.com/Noumena-Network/code / getFilePathFromToolInput

Function getFilePathFromToolInput

src/utils/collapseReadSearch.ts:76–87  ·  view source on GitHub ↗

* Extract the primary file/directory path from a tool_use input. * Handles both `file_path` (Read/Write/Edit) and `path` (Grep/Glob). * `path` may be a string or an array of strings for multi-directory tools.

(toolInput: unknown)

Source from the content-addressed store, hash-verified

74 * `path` may be a string or an array of strings for multi-directory tools.
75 */
76function getFilePathFromToolInput(toolInput: unknown): string | undefined {
77 const input = toolInput as
78 | { file_path?: string; path?: string | string[]; pattern?: string; glob?: string }
79 | undefined
80 if (input?.file_path) {
81 return input.file_path
82 }
83 if (input?.path) {
84 return Array.isArray(input.path) ? input.path[0] : input.path
85 }
86 return undefined
87}
88
89/**
90 * Check if a search tool use targets memory files by examining its path, pattern, and glob.

Callers 1

isMemoryWriteOrEditFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected