MCPcopy
hub / github.com/claude-code-best/claude-code / getTools

Function getTools

src/tools.ts:304–360  ·  view source on GitHub ↗
(permissionContext: ToolPermissionContext)

Source from the content-addressed store, hash-verified

302}
303
304export const getTools = (permissionContext: ToolPermissionContext): Tools => {
305 // Simple mode: only Bash, Read, and Edit tools
306 if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
307 // --bare + REPL mode: REPL wraps Bash/Read/Edit/etc inside the VM, so
308 // return REPL instead of the raw primitives. Matches the non-bare path
309 // below which also hides REPL_ONLY_TOOLS when REPL is enabled.
310 if (isReplModeEnabled() && REPLTool) {
311 const replSimple: Tool[] = [REPLTool]
312 if (
313 feature('COORDINATOR_MODE') &&
314 coordinatorModeModule?.isCoordinatorMode()
315 ) {
316 replSimple.push(TaskStopTool, getSendMessageTool())
317 }
318 return filterToolsByDenyRules(replSimple, permissionContext)
319 }
320 const simpleTools: Tool[] = [BashTool, FileReadTool, FileEditTool]
321 // When coordinator mode is also active, include AgentTool and TaskStopTool
322 // so the coordinator gets Task+TaskStop (via useMergedTools filtering) and
323 // workers get Bash/Read/Edit (via filterToolsForAgent filtering).
324 if (
325 feature('COORDINATOR_MODE') &&
326 coordinatorModeModule?.isCoordinatorMode()
327 ) {
328 simpleTools.push(AgentTool, TaskStopTool, getSendMessageTool())
329 }
330 return filterToolsByDenyRules(simpleTools, permissionContext)
331 }
332
333 // Get all base tools and filter out special tools that get added conditionally
334 const specialTools = new Set([
335 ListMcpResourcesTool.name,
336 ReadMcpResourceTool.name,
337 SYNTHETIC_OUTPUT_TOOL_NAME,
338 ])
339
340 const tools = getAllBaseTools().filter(tool => !specialTools.has(tool.name))
341
342 // Filter out tools that are denied by the deny rules
343 let allowedTools = filterToolsByDenyRules(tools, permissionContext)
344
345 // When REPL mode is enabled, hide primitive tools from direct use.
346 // They're still accessible inside REPL via the VM context.
347 if (isReplModeEnabled()) {
348 const replEnabled = allowedTools.some(tool =>
349 toolMatchesName(tool, REPL_TOOL_NAME),
350 )
351 if (replEnabled) {
352 allowedTools = allowedTools.filter(
353 tool => !REPL_ONLY_TOOLS.has(tool.name),
354 )
355 }
356 }
357
358 const isEnabled = allowedTools.map(_ => _.isEnabled())
359 return allowedTools.filter((_, i) => isEnabled[i])
360}
361

Callers 12

tool-chain.test.tsFile · 0.90
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
createSessionFunction · 0.85

Calls 9

isReplModeEnabledFunction · 0.85
getSendMessageToolFunction · 0.85
filterToolsByDenyRulesFunction · 0.85
getAllBaseToolsFunction · 0.85
toolMatchesNameFunction · 0.70
isEnabledMethod · 0.65
isEnvTruthyFunction · 0.50
pushMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected