Revert "feat: add two-layer tool call validation system (proactive + reactive) (#249)"

This reverts commit 9bc2360d31.
This commit is contained in:
YeonGyu-Kim
2025-12-26 04:12:12 +09:00
parent f9234a6a5e
commit 6160730f24
9 changed files with 8 additions and 282 deletions

View File

@@ -1,63 +0,0 @@
export interface ToolRegistry {
isValidTool(name: string): boolean
getAllToolNames(): string[]
}
interface MCPServerConfig {
tools?: Array<{ name: string }>
[key: string]: unknown
}
/**
* Create tool registry for validation
* MCP tools use prefix matching: "serverName_methodName"
*/
export function createToolRegistry(
builtinTools: Record<string, unknown>,
dynamicTools: Record<string, unknown>,
mcpServers: Record<string, MCPServerConfig>
): ToolRegistry {
const toolNames = new Set<string>([
...Object.keys(builtinTools),
...Object.keys(dynamicTools),
])
const mcpPrefixes = new Set<string>()
for (const serverName of Object.keys(mcpServers)) {
mcpPrefixes.add(`${serverName}_`)
const mcpTools = mcpServers[serverName]?.tools
if (mcpTools && Array.isArray(mcpTools)) {
for (const tool of mcpTools) {
if (tool.name) {
toolNames.add(tool.name)
}
}
}
}
return {
isValidTool(name: string): boolean {
if (!name || typeof name !== "string" || name.trim() === "") {
return false
}
if (toolNames.has(name)) {
return true
}
for (const prefix of mcpPrefixes) {
if (name.startsWith(prefix)) {
return true
}
}
return false
},
getAllToolNames(): string[] {
return Array.from(toolNames).sort()
},
}
}