MCPcopy Index your code
hub / github.com/codeaashu/claude-code / canUseTool

Function canUseTool

src/services/MagicDocs/magicDocs.ts:172–192  ·  view source on GitHub ↗
(tool: Tool, input: unknown)

Source from the content-addressed store, hash-verified

170
171 // Create a custom canUseTool that only allows Edit for magic doc files
172 const canUseTool = async (tool: Tool, input: unknown) => {
173 if (
174 tool.name === FILE_EDIT_TOOL_NAME &&
175 typeof input === 'object' &&
176 input !== null &&
177 'file_path' in input
178 ) {
179 const filePath = input.file_path
180 if (typeof filePath === 'string' && filePath === docInfo.path) {
181 return { behavior: 'allow' as const, updatedInput: input }
182 }
183 }
184 return {
185 behavior: 'deny' as const,
186 message: `only ${FILE_EDIT_TOOL_NAME} is allowed for ${docInfo.path}`,
187 decisionReason: {
188 type: 'other' as const,
189 reason: `only ${FILE_EDIT_TOOL_NAME} is allowed`,
190 },
191 }
192 }
193
194 // Run Magic Docs update using runAgent with forked context
195 for await (const _message of runAgent({

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected