Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions toolbox/enrichment/src/agent/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ function expandEnvVars(str: string): string {

export async function loadMcpTools(configPath: string): Promise<adk.MCPToolset[]> {
const mcpConfigPath = path.join(configPath, 'mcp.json');
const stat = await fs.promises.stat(mcpConfigPath);
if (!stat.isFile()) {
return [];
}

try {
const stat = await fs.promises.stat(mcpConfigPath);
if (!stat.isFile()) {
return [];
}
const content = await fs.promises.readFile(mcpConfigPath, 'utf-8');
const config = JSON.parse(content);
const toolsets: adk.MCPToolset[] = [];
Expand Down Expand Up @@ -61,19 +61,22 @@ export async function loadMcpTools(configPath: string): Promise<adk.MCPToolset[]
return toolsets;
}
catch (error: any) {
console.warn(`Warning: Failed to load mcp.json: ${error.message}`);
if (error?.code !== 'ENOENT') {
// ENOENT simply means the optional mcp.json isn't present.
console.warn(`Warning: Failed to load mcp.json: ${error.message}`);
}
return [];
}
}

export async function loadSkills(configPath: string): Promise<adk.SkillToolset[]> {
const skillsBasePath = path.join(configPath, 'skills');
const stat = await fs.promises.stat(skillsBasePath);
if (!stat.isDirectory()) {
return [];
}

try {
const stat = await fs.promises.stat(skillsBasePath);
if (!stat.isDirectory()) {
return [];
}
const skillsMap = await adk.loadAllSkillsInDir(skillsBasePath);
if (Object.keys(skillsMap).length === 0) {
return [];
Expand All @@ -86,7 +89,10 @@ export async function loadSkills(configPath: string): Promise<adk.SkillToolset[]
];
}
catch (error: any) {
console.warn(`Warning: Failed to load skills: ${error.message}`);
if (error?.code !== 'ENOENT') {
// ENOENT simply means the optional skills/ directory isn't present.
console.warn(`Warning: Failed to load skills: ${error.message}`);
}
return [];
}
}