mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-26 17:12:27 +03:00
Add githubSkillTools to getAllToolDefinitions() so the searchable MCP catalog matches TOTAL_MCP_TOOL_COUNT, which already counts them. The GitHub skill tools were registered and counted but missing from the catalog, so omniroute_tool_search could not surface them. Adds regression tests at both layers: catalog aggregation and client-visible discovery via the MCP client. Co-authored-by: Brandon Bennett <brandonbennett@macbookair.myfiosgateway.com>
103 lines
3.3 KiB
TypeScript
103 lines
3.3 KiB
TypeScript
/**
|
|
* getAllToolDefinitions — unified catalog of all MCP tool definitions.
|
|
*
|
|
* Aggregates the same collections referenced by TOTAL_MCP_TOOL_COUNT in server.ts:
|
|
* MCP_TOOLS + memoryTools + skillTools + agentSkillTools + githubSkillTools +
|
|
* poolTools + gamificationTools + pluginTools + notionTools + obsidianTools +
|
|
* localCorpusTools + compressionTools
|
|
*
|
|
* Tolerates both Array and Record shapes. Deduplicates by name (first wins).
|
|
*/
|
|
|
|
import { MCP_TOOLS } from "../schemas/tools.ts";
|
|
import { memoryTools } from "../tools/memoryTools.ts";
|
|
import { skillTools } from "../tools/skillTools.ts";
|
|
import { agentSkillTools } from "../tools/agentSkillTools.ts";
|
|
import { githubSkillTools } from "../tools/githubSkillTools.ts";
|
|
import { poolTools } from "../tools/poolTools.ts";
|
|
import { gamificationTools } from "../tools/gamificationTools.ts";
|
|
import { pluginTools } from "../tools/pluginTools.ts";
|
|
import { notionTools } from "../tools/notionTools.ts";
|
|
import { obsidianTools } from "../tools/obsidianTools.ts";
|
|
import { localCorpusTools } from "../tools/localCorpusTools.ts";
|
|
import { compressionTools } from "../tools/compressionTools.ts";
|
|
|
|
import type { ToolCatalogEntry } from "./search.ts";
|
|
|
|
type AnyToolLike = {
|
|
name?: unknown;
|
|
description?: unknown;
|
|
scopes?: unknown;
|
|
inputSchema?: unknown;
|
|
};
|
|
|
|
function normalizeEntry(raw: AnyToolLike): ToolCatalogEntry | null {
|
|
const name = typeof raw.name === "string" ? raw.name : null;
|
|
const description = typeof raw.description === "string" ? raw.description : "";
|
|
if (!name) return null;
|
|
|
|
const scopes: readonly string[] = Array.isArray(raw.scopes)
|
|
? (raw.scopes as string[]).filter((s): s is string => typeof s === "string")
|
|
: [];
|
|
|
|
return { name, description, scopes, inputSchema: raw.inputSchema };
|
|
}
|
|
|
|
function collectFromArray(arr: AnyToolLike[]): ToolCatalogEntry[] {
|
|
const result: ToolCatalogEntry[] = [];
|
|
for (const item of arr) {
|
|
const entry = normalizeEntry(item);
|
|
if (entry) result.push(entry);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function collectFromRecord(rec: Record<string, AnyToolLike>): ToolCatalogEntry[] {
|
|
return collectFromArray(Object.values(rec));
|
|
}
|
|
|
|
function collectAny(collection: unknown): ToolCatalogEntry[] {
|
|
if (Array.isArray(collection)) return collectFromArray(collection as AnyToolLike[]);
|
|
if (collection && typeof collection === "object") {
|
|
return collectFromRecord(collection as Record<string, AnyToolLike>);
|
|
}
|
|
return [];
|
|
}
|
|
|
|
/**
|
|
* Returns a deduplicated list of all registered MCP tool catalog entries.
|
|
* Deduplication: first occurrence by name wins.
|
|
*/
|
|
export function getAllToolDefinitions(): ToolCatalogEntry[] {
|
|
const collections: unknown[] = [
|
|
MCP_TOOLS,
|
|
memoryTools,
|
|
skillTools,
|
|
agentSkillTools,
|
|
githubSkillTools,
|
|
poolTools,
|
|
gamificationTools,
|
|
pluginTools,
|
|
notionTools,
|
|
obsidianTools,
|
|
localCorpusTools,
|
|
// Keep the concrete handler collection in the catalog as a parity guard. Canonical CCR
|
|
// definitions now live in MCP_TOOLS too; deduplication below keeps each name visible once.
|
|
compressionTools,
|
|
];
|
|
|
|
const seen = new Set<string>();
|
|
const result: ToolCatalogEntry[] = [];
|
|
|
|
for (const collection of collections) {
|
|
for (const entry of collectAny(collection)) {
|
|
if (!seen.has(entry.name)) {
|
|
seen.add(entry.name);
|
|
result.push(entry);
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|