Skip to content

Phase 5: MCP tool capability index -- context-aware tool loading #697

@AlexMikhalev

Description

@AlexMikhalev

Parent Epic

Part of #692 (Operational Skill Store)

Summary

Extend the MCP server to expose a tool capability index that returns only relevant tool definitions for the current task, using Aho-Corasick automata to match task descriptions against tool capability descriptions. This solves "catalog bloat" -- instead of stuffing all tool schemas into context, load only what is needed.

What Changes

Tool capability index in terraphim_mcp_server

  • Each registered MCP tool gets a capability description indexed in the KG
  • Query API matches task description against tool capabilities
  • Returns ranked list of relevant tools with their schemas

CLI

terraphim-agent tools relevant "fix the broken data pipeline"
# Returns: ssh, systemctl, config-edit, log-search (4 of 47 available tools)

MCP resource

Expose as MCP resource so agents can query before requesting tool definitions:

terraphim://tools/relevant?query=deploy+config

Affected Crates

  • terraphim_mcp_server (tool index resource)
  • terraphim_automata (capability matching)

Dependencies

Acceptance Criteria

  • Tool capability descriptions indexed in KG
  • Query returns ranked relevant tools
  • MCP resource endpoint functional
  • CLI tools relevant command works
  • Reduces token usage compared to loading all tool schemas
  • Benchmarks showing sub-100ms query time via automata

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions