MCPcopy Create free account
hub / github.com/IgorWarzocha/howcode / createAttachmentFileTools

Function createAttachmentFileTools

desktop/runtime/attachment-file-tools.ts:119–143  ·  view source on GitHub ↗
(options: { cwd: string; autoResizeImages: boolean })

Source from the content-addressed store, hash-verified

117}
118
119export function createAttachmentFileTools(options: { cwd: string; autoResizeImages: boolean }): {
120 tools: ToolDefinition[]
121 access: AttachmentFileAccess
122} {
123 const grants: AttachmentGrant = { files: new Set(), directories: new Set() }
124 const attachmentAccess = createAttachmentFileAccess(grants)
125
126 const readTool = createReadToolDefinition(options.cwd, {
127 autoResizeImages: options.autoResizeImages,
128 })
129 const readExecute = readTool.execute.bind(readTool)
130 readTool.execute = async (toolCallId, params, signal, onUpdate, ctx) => {
131 await assertGrantedPath(params.path, grants, options.cwd)
132 return await readExecute(toolCallId, params, signal, onUpdate, ctx)
133 }
134
135 const lsTool = createLsToolDefinition(options.cwd)
136 const lsExecute = lsTool.execute.bind(lsTool)
137 lsTool.execute = async (toolCallId, params, signal, onUpdate, ctx) => {
138 await assertGrantedDirectoryPath(params.path ?? '.', grants, options.cwd)
139 return await lsExecute(toolCallId, params, signal, onUpdate, ctx)
140 }
141
142 return { tools: [readTool, lsTool] as unknown as ToolDefinition[], access: attachmentAccess }
143}

Callers 3

createRuntimeFunction · 0.90
createRuntimeFunction · 0.90

Calls 3

assertGrantedPathFunction · 0.85

Tested by

no test coverage detected