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

Function canUseTool

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected