UAT: MCP adapter infers resource slots but never wires them into domain Tool objects or DB #5474

Open
opened 2026-04-09 06:57:08 +00:00 by HAL9000 · 1 comment
Owner

Bug Report

Feature Area: MCP Adapter — Tool call routing / Resource slot binding
Severity: Backlog — resource slot inference is implemented but not consumed
Found by: UAT Testing (tool-router-mcp-adapter area)

What Was Tested

Code-level analysis of src/cleveragents/mcp/adapter.py — specifically the register_tools() method (lines 549–638) and the infer_resource_slots() static method (lines 652–736).

Expected Behavior (from spec)

When MCP tools are registered into the ToolRegistry, their inferred resource slots should be stored in the domain Tool objects and persisted to the database via the tool_resource_bindings table (migration c1_001). This enables the runtime to correctly bind resources to MCP tool invocations.

Actual Behavior

The register_tools() method infers resource slots and stores them in source_metadata, but there is a TODO comment acknowledging that nothing downstream reads them:

# TODO(#882): resource_slots are stored in source_metadata but
# nothing downstream reads them yet.  The ToolRegistry persists
# resource bindings via domain Tool.resource_slots, and the DB
# migration (c1_001) stores them in tool_resource_bindings.
# A follow-up ticket should wire inferred slots into the domain
# Tool objects so the registry and DB actually consume them.
cap_meta = self.capability_metadata
spec = ToolSpec(
    ...
    source_metadata={
        "server": self._config.name,
        "resource_slots": slot_dicts,  # Stored but never read
        ...
    },
)

The ToolRegistry.find_tools_for_resource() method looks for source_metadata["resource_bindings"] (not "resource_slots"), so even the key name is inconsistent.

Code Location

  • Bug: src/cleveragents/mcp/adapter.py, lines 611–616 (TODO comment)
  • Inconsistency: src/cleveragents/tool/registry.py, line 127 — looks for "resource_bindings" but MCP stores "resource_slots"

Impact

  • ToolRegistry.find_tools_for_resource() will never find MCP tools even when they have matching resource slots
  • MCP tool resource bindings are never persisted to the tool_resource_bindings DB table
  • The resource slot inference logic in infer_resource_slots() is effectively dead code

Fix

  1. Rename the key from "resource_slots" to "resource_bindings" in register_tools() to match what find_tools_for_resource() expects
  2. Wire the inferred slots into the domain Tool objects when registering MCP tools
  3. Persist the resource bindings to the DB via the existing tool_resource_bindings migration

Metadata

Commit Message: fix(mcp): wire inferred resource slots into domain Tool objects and ToolRegistry
Branch: fix/mcp-resource-slots-wiring

Subtasks

  • Rename "resource_slots" to "resource_bindings" in MCPToolAdapter.register_tools() source_metadata
  • Wire inferred resource slots into domain Tool.resource_slots field
  • Persist resource bindings to DB via tool_resource_bindings table
  • Add unit tests verifying find_tools_for_resource() finds MCP tools with matching slots
  • Remove the TODO(#882) comment once fixed

Definition of Done

  • ToolRegistry.find_tools_for_resource("file") returns MCP tools that have a file_path parameter
  • MCP tool resource bindings are persisted to the DB
  • All existing tests pass

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: uat-tester

## Bug Report **Feature Area:** MCP Adapter — Tool call routing / Resource slot binding **Severity:** Backlog — resource slot inference is implemented but not consumed **Found by:** UAT Testing (tool-router-mcp-adapter area) ### What Was Tested Code-level analysis of `src/cleveragents/mcp/adapter.py` — specifically the `register_tools()` method (lines 549–638) and the `infer_resource_slots()` static method (lines 652–736). ### Expected Behavior (from spec) When MCP tools are registered into the `ToolRegistry`, their inferred resource slots should be stored in the domain `Tool` objects and persisted to the database via the `tool_resource_bindings` table (migration `c1_001`). This enables the runtime to correctly bind resources to MCP tool invocations. ### Actual Behavior The `register_tools()` method infers resource slots and stores them in `source_metadata`, but there is a TODO comment acknowledging that nothing downstream reads them: ```python # TODO(#882): resource_slots are stored in source_metadata but # nothing downstream reads them yet. The ToolRegistry persists # resource bindings via domain Tool.resource_slots, and the DB # migration (c1_001) stores them in tool_resource_bindings. # A follow-up ticket should wire inferred slots into the domain # Tool objects so the registry and DB actually consume them. cap_meta = self.capability_metadata spec = ToolSpec( ... source_metadata={ "server": self._config.name, "resource_slots": slot_dicts, # Stored but never read ... }, ) ``` The `ToolRegistry.find_tools_for_resource()` method looks for `source_metadata["resource_bindings"]` (not `"resource_slots"`), so even the key name is inconsistent. ### Code Location - **Bug**: `src/cleveragents/mcp/adapter.py`, lines 611–616 (TODO comment) - **Inconsistency**: `src/cleveragents/tool/registry.py`, line 127 — looks for `"resource_bindings"` but MCP stores `"resource_slots"` ### Impact - `ToolRegistry.find_tools_for_resource()` will never find MCP tools even when they have matching resource slots - MCP tool resource bindings are never persisted to the `tool_resource_bindings` DB table - The resource slot inference logic in `infer_resource_slots()` is effectively dead code ### Fix 1. Rename the key from `"resource_slots"` to `"resource_bindings"` in `register_tools()` to match what `find_tools_for_resource()` expects 2. Wire the inferred slots into the domain `Tool` objects when registering MCP tools 3. Persist the resource bindings to the DB via the existing `tool_resource_bindings` migration ### Metadata ``` Commit Message: fix(mcp): wire inferred resource slots into domain Tool objects and ToolRegistry Branch: fix/mcp-resource-slots-wiring ``` ### Subtasks - [ ] Rename `"resource_slots"` to `"resource_bindings"` in `MCPToolAdapter.register_tools()` source_metadata - [ ] Wire inferred resource slots into domain `Tool.resource_slots` field - [ ] Persist resource bindings to DB via `tool_resource_bindings` table - [ ] Add unit tests verifying `find_tools_for_resource()` finds MCP tools with matching slots - [ ] Remove the TODO(#882) comment once fixed ### Definition of Done - `ToolRegistry.find_tools_for_resource("file")` returns MCP tools that have a `file_path` parameter - MCP tool resource bindings are persisted to the DB - All existing tests pass --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: uat-tester
HAL9000 added this to the v3.2.0 milestone 2026-04-09 06:59:20 +00:00
Author
Owner

Label compliance fix applied:

  • Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: backlog-groomer

Label compliance fix applied: - Added missing labels and/or milestone to bring issue into compliance with CONTRIBUTING.md --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: backlog-groomer
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveragents-core#5474
No description provided.