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

Function assembleToolPool

src/tools.ts:350–367  ·  view source on GitHub ↗
(
  permissionContext: ToolPermissionContext,
  mcpTools: Tools,
)

Source from the content-addressed store, hash-verified

348 * @returns Combined, deduplicated array of built-in and MCP tools
349 */
350export function assembleToolPool(
351 permissionContext: ToolPermissionContext,
352 mcpTools: Tools,
353): Tools {
354 const builtInTools = getTools(permissionContext)
355
356 // Filter out MCP tools that are in the deny list
357 const allowedMcpTools = filterToolsByDenyRules(mcpTools, permissionContext)
358
359 // Keep built-ins as a contiguous prefix ordered by the product tool policy.
360 // MCP tools stay name-sorted behind them for deterministic prompt cache keys.
361 // uniqBy preserves insertion order, so built-ins win on name conflict.
362 const byName = (a: Tool, b: Tool) => a.name.localeCompare(b.name)
363 return uniqBy(
364 sortToolsByPolicy(builtInTools).concat(allowedMcpTools.sort(byName)),
365 'name',
366 )
367}
368
369/**
370 * Get all tools including both built-in tools and MCP tools.

Callers 6

callFunction · 0.85
runWorkflowAgentTaskFunction · 0.85
resumeAgentBackgroundFunction · 0.85
callFunction · 0.85
buildAllToolsFunction · 0.85
useMergedToolsFunction · 0.85

Calls 3

getToolsFunction · 0.85
filterToolsByDenyRulesFunction · 0.85
sortToolsByPolicyFunction · 0.85

Tested by

no test coverage detected