UAT: MCP tool resource slots inferred by MCPToolAdapter.register_tools() are stored only in source_metadata — never written to tool_resource_bindings DB table or domain Tool.resource_slots #2126

Open
opened 2026-04-03 04:17:36 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/mcp-adapter-resource-slots-not-persisted
  • Commit Message: fix(mcp): wire inferred resource slots from MCPToolAdapter into tool_resource_bindings and domain Tool.resource_slots
  • Milestone: v3.7.0
  • Parent Epic: #398

Background

MCPToolAdapter.register_tools() infers resource slots from MCP tool parameter schemas (e.g., file_path → file resource slot, directory → directory resource slot, repo_path → repository resource slot) but stores them only in the ToolSpec.source_metadata JSON blob. They are never written to the tool_resource_bindings database table or to the domain Tool.resource_slots field.

The code contains an explicit TODO comment acknowledging this gap:

# 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.

Issue #882 (which this TODO references) has been closed, but the wiring was never completed. The tool_resource_bindings table exists in the database schema (src/cleveragents/infrastructure/database/models.py line 1938) but MCP-inferred resource slots are never written to it.

Steps to Reproduce

  1. Register an MCP skill with a tool that has file_path in its schema
  2. Check tool_resource_bindings table — it will be empty for MCP tools
  3. Check Tool.resource_slots for the registered MCP tool — it will be empty

Expected Behavior

Per the specification, resource slots inferred from MCP tool schemas should be persisted to the tool_resource_bindings table and available via the domain Tool.resource_slots field, so that the resource binding system can use them for contextual binding and access control.

Actual Behavior

Inferred resource slots are silently dropped after inference — stored only in ToolSpec.source_metadata and never propagated to the domain model or database.

Code Locations

  • src/cleveragents/mcp/adapter.py, lines 591–596 (TODO comment)
  • src/cleveragents/mcp/adapter.py, lines 580–615 (register_tools() method)
  • src/cleveragents/infrastructure/database/models.py, line 1938 (tool_resource_bindings table)

Impact

MCP tools cannot participate in the resource binding system. Contextual resource binding (e.g., automatically binding the current project's repository to a repo_path parameter) does not work for MCP tools, even though the adapter correctly infers the slots. Severity: Medium — MCP tools work for basic invocation but the resource binding integration is incomplete.

Subtasks

  • Write a failing Behave scenario demonstrating that MCPToolAdapter.register_tools() does not populate Tool.resource_slots for a tool with file_path in its schema
  • Write a failing Behave scenario demonstrating that tool_resource_bindings rows are absent after MCP tool registration
  • Update MCPToolAdapter.register_tools() to read inferred resource slots from ToolSpec.source_metadata and populate the domain Tool.resource_slots field
  • Update MCPToolAdapter.register_tools() (or the downstream ToolRegistry call) to write inferred resource slots to the tool_resource_bindings database table
  • Remove the stale TODO(#882) comment from src/cleveragents/mcp/adapter.py lines 591–596
  • Add a Robot Framework integration test verifying end-to-end: register MCP skill → query tool_resource_bindings → assert rows present with correct slot types
  • Update docs/api/mcp.md if register_tools() signature or behaviour documentation is affected
  • Run nox and confirm all stages pass with coverage ≥ 97%

Definition of Done

  • Failing Behave scenarios exist before any implementation change (TDD)
  • MCPToolAdapter.register_tools() populates Tool.resource_slots from inferred schema slots
  • tool_resource_bindings table contains rows for MCP tools after registration
  • Stale TODO(#882) comment removed from adapter.py
  • Robot Framework integration test passes end-to-end
  • docs/api/mcp.md updated if applicable
  • All nox stages pass
  • Coverage >= 97%
  • PR reviewed and merged, this issue closed

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/mcp-adapter-resource-slots-not-persisted` - **Commit Message**: `fix(mcp): wire inferred resource slots from MCPToolAdapter into tool_resource_bindings and domain Tool.resource_slots` - **Milestone**: v3.7.0 - **Parent Epic**: #398 ## Background `MCPToolAdapter.register_tools()` infers resource slots from MCP tool parameter schemas (e.g., `file_path` → file resource slot, `directory` → directory resource slot, `repo_path` → repository resource slot) but stores them only in the `ToolSpec.source_metadata` JSON blob. They are never written to the `tool_resource_bindings` database table or to the domain `Tool.resource_slots` field. The code contains an explicit TODO comment acknowledging this gap: ```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. ``` Issue #882 (which this TODO references) has been **closed**, but the wiring was never completed. The `tool_resource_bindings` table exists in the database schema (`src/cleveragents/infrastructure/database/models.py` line 1938) but MCP-inferred resource slots are never written to it. ## Steps to Reproduce 1. Register an MCP skill with a tool that has `file_path` in its schema 2. Check `tool_resource_bindings` table — it will be empty for MCP tools 3. Check `Tool.resource_slots` for the registered MCP tool — it will be empty ## Expected Behavior Per the specification, resource slots inferred from MCP tool schemas should be persisted to the `tool_resource_bindings` table and available via the domain `Tool.resource_slots` field, so that the resource binding system can use them for contextual binding and access control. ## Actual Behavior Inferred resource slots are silently dropped after inference — stored only in `ToolSpec.source_metadata` and never propagated to the domain model or database. ## Code Locations - `src/cleveragents/mcp/adapter.py`, lines 591–596 (TODO comment) - `src/cleveragents/mcp/adapter.py`, lines 580–615 (`register_tools()` method) - `src/cleveragents/infrastructure/database/models.py`, line 1938 (`tool_resource_bindings` table) ## Impact MCP tools cannot participate in the resource binding system. Contextual resource binding (e.g., automatically binding the current project's repository to a `repo_path` parameter) does not work for MCP tools, even though the adapter correctly infers the slots. **Severity: Medium** — MCP tools work for basic invocation but the resource binding integration is incomplete. ## Subtasks - [ ] Write a failing Behave scenario demonstrating that `MCPToolAdapter.register_tools()` does not populate `Tool.resource_slots` for a tool with `file_path` in its schema - [ ] Write a failing Behave scenario demonstrating that `tool_resource_bindings` rows are absent after MCP tool registration - [ ] Update `MCPToolAdapter.register_tools()` to read inferred resource slots from `ToolSpec.source_metadata` and populate the domain `Tool.resource_slots` field - [ ] Update `MCPToolAdapter.register_tools()` (or the downstream `ToolRegistry` call) to write inferred resource slots to the `tool_resource_bindings` database table - [ ] Remove the stale `TODO(#882)` comment from `src/cleveragents/mcp/adapter.py` lines 591–596 - [ ] Add a Robot Framework integration test verifying end-to-end: register MCP skill → query `tool_resource_bindings` → assert rows present with correct slot types - [ ] Update `docs/api/mcp.md` if `register_tools()` signature or behaviour documentation is affected - [ ] Run `nox` and confirm all stages pass with coverage ≥ 97% ## Definition of Done - [ ] Failing Behave scenarios exist before any implementation change (TDD) - [ ] `MCPToolAdapter.register_tools()` populates `Tool.resource_slots` from inferred schema slots - [ ] `tool_resource_bindings` table contains rows for MCP tools after registration - [ ] Stale `TODO(#882)` comment removed from `adapter.py` - [ ] Robot Framework integration test passes end-to-end - [ ] `docs/api/mcp.md` updated if applicable - [ ] All nox stages pass - [ ] Coverage >= 97% - [ ] PR reviewed and merged, this issue closed --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-new-issue-creator
freemo added this to the v3.7.0 milestone 2026-04-03 04:17:43 +00:00
freemo self-assigned this 2026-04-03 16:58:04 +00:00
Author
Owner

MoSCoW classification: Should Have

Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

MoSCoW classification: **Should Have** Rationale: This issue addresses a spec requirement or important quality improvement. It should be included in the milestone if possible. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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.

Blocks
#398 Epic: Post-MVP Resources
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2126
No description provided.