MCPcopy Index your code
hub / github.com/claude-code-best/claude-code / getFilePathFromInput

Function getFilePathFromInput

src/utils/sessionFileAccessHooks.ts:49–69  ·  view source on GitHub ↗

* Extract the file path from a tool input for memdir detection. * Covers Read (file_path), Edit (file_path), and Write (file_path).

(
  toolName: string,
  toolInput: unknown,
)

Source from the content-addressed store, hash-verified

47 * Covers Read (file_path), Edit (file_path), and Write (file_path).
48 */
49function getFilePathFromInput(
50 toolName: string,
51 toolInput: unknown,
52): string | null {
53 switch (toolName) {
54 case FILE_READ_TOOL_NAME: {
55 const parsed = FileReadTool.inputSchema.safeParse(toolInput)
56 return parsed.success ? parsed.data.file_path : null
57 }
58 case FILE_EDIT_TOOL_NAME: {
59 const parsed = editInputSchema().safeParse(toolInput)
60 return parsed.success ? parsed.data.file_path : null
61 }
62 case FILE_WRITE_TOOL_NAME: {
63 const parsed = FileWriteTool.inputSchema.safeParse(toolInput)
64 return parsed.success ? parsed.data.file_path : null
65 }
66 default:
67 return null
68 }
69}
70
71/**
72 * Extract file type from tool input.

Callers 2

isMemoryFileAccessFunction · 0.85
handleSessionFileAccessFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected