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

Function getTools

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

Source from the content-addressed store, hash-verified

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

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 9

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

Tested by

no test coverage detected