MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getTools

Function getTools

source code/tools.ts:273–329  ·  view source on GitHub ↗
(permissionContext: ToolPermissionContext)

Source from the content-addressed store, hash-verified

271}
272
273export const getTools = (permissionContext: ToolPermissionContext): Tools => {
274 // Simple mode: only Bash, Read, and Edit tools
275 if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
276 // --bare + REPL mode: REPL wraps Bash/Read/Edit/etc inside the VM, so
277 // return REPL instead of the raw primitives. Matches the non-bare path
278 // below which also hides REPL_ONLY_TOOLS when REPL is enabled.
279 if (isReplModeEnabled() && REPLTool) {
280 const replSimple: Tool[] = [REPLTool]
281 if (
282 feature('COORDINATOR_MODE') &&
283 coordinatorModeModule?.isCoordinatorMode()
284 ) {
285 replSimple.push(TaskStopTool, getSendMessageTool())
286 }
287 return filterToolsByDenyRules(replSimple, permissionContext)
288 }
289 const simpleTools: Tool[] = [BashTool, FileReadTool, FileEditTool]
290 // When coordinator mode is also active, include AgentTool and TaskStopTool
291 // so the coordinator gets Task+TaskStop (via useMergedTools filtering) and
292 // workers get Bash/Read/Edit (via filterToolsForAgent filtering).
293 if (
294 feature('COORDINATOR_MODE') &&
295 coordinatorModeModule?.isCoordinatorMode()
296 ) {
297 simpleTools.push(AgentTool, TaskStopTool, getSendMessageTool())
298 }
299 return filterToolsByDenyRules(simpleTools, permissionContext)
300 }
301
302 // Get all base tools and filter out special tools that get added conditionally
303 const specialTools = new Set([
304 ListMcpResourcesTool.name,
305 ReadMcpResourceTool.name,
306 SYNTHETIC_OUTPUT_TOOL_NAME,
307 ])
308
309 const tools = getAllBaseTools().filter(tool => !specialTools.has(tool.name))
310
311 // Filter out tools that are denied by the deny rules
312 let allowedTools = filterToolsByDenyRules(tools, permissionContext)
313
314 // When REPL mode is enabled, hide primitive tools from direct use.
315 // They're still accessible inside REPL via the VM context.
316 if (isReplModeEnabled()) {
317 const replEnabled = allowedTools.some(tool =>
318 toolMatchesName(tool, REPL_TOOL_NAME),
319 )
320 if (replEnabled) {
321 allowedTools = allowedTools.filter(
322 tool => !REPL_ONLY_TOOLS.has(tool.name),
323 )
324 }
325 }
326
327 const isEnabled = allowedTools.map(_ => _.isEnabled())
328 return allowedTools.filter((_, i) => isEnabled[i])
329}
330

Callers 10

assembleToolPoolFunction · 0.85
getMergedToolsFunction · 0.85
runFunction · 0.85
AsyncAgentDetailDialogFunction · 0.85
logContextMetricsFunction · 0.85
callFunction · 0.85
callFunction · 0.85
REPLFunction · 0.85
startMCPServerFunction · 0.85

Calls 7

isEnvTruthyFunction · 0.85
isReplModeEnabledFunction · 0.85
getSendMessageToolFunction · 0.85
filterToolsByDenyRulesFunction · 0.85
getAllBaseToolsFunction · 0.85
toolMatchesNameFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected