Skip to content

feat(mcp): omniroute_tool_search + one-line TS signatures — roadmap #4 - #5269

Merged
diegosouzapw merged 9 commits into
release/v3.8.40from
feat/mcp-tool-search
Jun 29, 2026
Merged

diegosouzapw merged 9 commits into
release/v3.8.40from
feat/mcp-tool-search

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

What

Adds a new MCP tool omniroute_tool_search that does lexical keyword search over every MCP tool's name/description and returns the top matches as compact one-line TypeScript signatures (~half the JSON-schema token cost), so agents discover tools on demand instead of carrying all ~88 schemas every turn. Tier-1 item of the compression feature-extraction roadmap (#4).

tools/list stays complete (no hidden tools / no deferred hot-subset in v1 — that's a follow-up, scoped to the Anthropic family). The static deny/allow reduction (toolCardinality.ts) is untouched.

How

New pure mcp-server/toolSearch/ module:

  • signature.ts — zodToTsSignature(name, inputSchema): Zod v4 introspection (field.type, _def.innerType, _def.entries) → name(args: { q: string; limit?: number }): Result. Never throws (try/catch → name(args: object) fallback).
  • search.ts — searchTools: lexical scoring reusing the getRelevanceScore pattern (phrase + token indexOf counts; name weighted over description). Anti-ReDoS: never compiles new RegExp on the query. Deterministic (stable name tie-break), limit clamped 1–25.
  • catalog.ts — getAllToolDefinitions: aggregates all 10 tool collections (array + Record shapes), dedupes by name. Includes compressionTools so omniroute_ccr_retrieve (absent from MCP_TOOLS) is searchable.
  • handler.ts — excludes the tool from its own results; output is {query, count, tools: [{name, description, scopes, signature}]} — only metadata already on tools/list plus the synthesized signature.

Wired into server.ts mirroring the base-tool pattern; new read:tools scope (resolved via MCP_TOOL_MAP, enforced by withScopeEnforcement).

Core review hardening

A dedicated review caught: (1) CRITICAL — compressionTools was missing from the catalog, so omniroute_ccr_retrieve was unsearchable (fixed + regression test); (2) the README example OMNIROUTE_MCP_SCOPES string lacked read:tools (would self-lock the discovery tool under enforcement — fixed); (3) removed a dead scoreHaystack helper.

Tests (TDD, vitest)

toolSearch.{signature,search,catalog,tool}.test.ts — all green (13 + the new regression). The e2e (InMemoryTransport) proves the tool appears in tools/list, returns omniroute_get_health on top for query:"health" with a signature string, carries read:tools, and never returns itself.

Gates (local)

lint 0 errors · typecheck:core clean · check:cycles OK · docs-sync PASS (CLAUDE.md/MCP-SERVER.md/README updated to 88 tools / 34 base / 31 scopes) · check:complexity 1968 (baseline 1981) · check:cognitive-complexity 835 (baseline 841).

Pre-existing vitest reds (NOT from this PR): httpAuthContext.test.ts (2) and an intermittent audit.test.ts (1) fail locally due to a shared local DATA_DIR with renumbered migrations + fileParallelism:true SQLite contention — they fail identically on a worktree with zero MCP changes, tool.test.ts mocks the audit DB, and audit+tool run together pass 4/4. These are environmental-local and expected to be green on the clean CI checkout. The 4 toolSearch.* files pass consistently.

Ready for review & merge.

- catalog: include compressionTools so omniroute_ccr_retrieve (absent from MCP_TOOLS) is searchable
- README: add read:tools to the example OMNIROUTE_MCP_SCOPES string (else tool_search self-locks under enforcement)
- remove dead scoreHaystack helper
- regression test for the ccr_retrieve catalog entry
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw

Copy link
Copy Markdown
Collaborator Author

Babysit summary — green except expected file-size own-growth

CI: Unit fast-path (1/2, 2/2) ✅ · Vitest (fast-path) ✅ (confirms the local httpAuthContext/audit reds were environmental-local — DB with renumbered migrations + fileParallelism; clean on CI) · dast-smoke ✅ · semgrep ✅ · semgrep-cloud ✅ · Fast Quality Gates ❌ (only check:file-size).

The one red — file-size own-growth (please rebaseline at merge):

  • open-sse/mcp-server/schemas/tools.ts: 1541 > 1497 (+44 — the toolSearchInput/toolSearchOutput/toolSearchTool definitions)
  • open-sse/mcp-server/server.ts: 1565 > 1555 (+10 — the omniroute_tool_search registration block)

Both are genuine own-growth on frozen files; same pattern rebaselined at merge across the roadmap. I did not edit config/quality/file-size-baseline.json (baseline is yours).

Local validation: lint 0 errors · typecheck:core clean · check:cycles OK · docs-sync PASS · toolSearch suite 13/13 (+ regression) · check:complexity 1968 (baseline 1981) · check:cognitive-complexity 835 (baseline 841).

Not merging — handing off for human merge + baseline bump.

@KooshaPari

Copy link
Copy Markdown
Contributor

#5269 Fast Quality unblocker is ready: #5272

It extracts the tool_search schema/tool definition and server registration into focused modules, bringing the frozen files back under cap:

  • tools.ts: 1493 lines
  • server.ts: 1549 lines

Validation on KooshaPari:fix/5269-mcp-tool-search-filesize / PR #5272:

  • npm run check:file-size
  • focused tool_search Vitest: 14/14 pass
  • eslint on touched MCP files: 0 errors; existing server any warnings only

Splits tool_search schema/registration to clear file-size cap; unblocks #5269
@diegosouzapw
diegosouzapw merged commit 99b17f1 into release/v3.8.40 Jun 29, 2026
7 checks passed
@diegosouzapw
diegosouzapw deleted the feat/mcp-tool-search branch June 29, 2026 01:09
KooshaPari added a commit to KooshaPari/OmniRoute that referenced this pull request Jun 30, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…heaper-inference#4 (cheaper-inference#5269)

roadmap cheaper-inference#4: omniroute_tool_search + one-line TS signatures. Integrated into release/v3.8.40.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants