# Change Request: CR-003

> Created: 2026-03-17
> Status: Approved
> Classification: Modification
> Related Feature: FEATURE-049-F

## Request Details

**Requestor:** Project Owner
**Date Received:** 2026-03-17
**Priority:** High

## Description

Add MCP tools to the app-and-agent-interaction MCP server for KB `.kb-index.json` CRUD operations. CR-002 introduced the per-folder `.kb-index.json` registry, but the AI agent (librarian) has no structured way to create/read/update/delete index entries — the only access path is through `update_file()` with a `frontmatter` dict, which is an indirect workaround.

Following the same pattern as `get_workflow_state` / `update_workflow_action`, new MCP tools will bridge AI agents to the KB index system via Flask REST endpoints.

## Business Justification

- The KB AI Librarian needs to set metadata for ALL file types (including binaries) after analyzing content
- MCP tools provide the standard agent ↔ app interaction pattern in X-IPE
- Without dedicated tools, the librarian must use indirect API calls that don't clearly map to the index concept
- Consistency: workflow state has MCP tools, KB index should too

## Proposed Changes

### New MCP Tools (in `app_agent_interaction.py`)

| Tool | Purpose | HTTP Endpoint |
|------|---------|--------------|
| `get_kb_index` | Read a folder's `.kb-index.json` entries | `GET /api/kb/index?folder=` |
| `set_kb_index_entry` | Create/update an entry (file or folder) | `PUT /api/kb/index/entry` |
| `remove_kb_index_entry` | Delete an entry | `DELETE /api/kb/index/entry` |

### New Flask Routes (in `kb_routes.py`)

| Route | Method | Purpose |
|-------|--------|---------|
| `/api/kb/index` | GET | Read all entries for a folder |
| `/api/kb/index/entry` | PUT | Set/update a single entry |
| `/api/kb/index/entry` | DELETE | Remove a single entry |

### Librarian Skill Update

Update `x-ipe-tool-kb-librarian/SKILL.md` step e to reference MCP tool `set_kb_index_entry` instead of `KBService._set_index_entry()`.

## Impact Analysis

| Area | Impact | Severity |
|------|--------|----------|
| `app_agent_interaction.py` | Add 3 new MCP tools | Low — additive |
| `kb_routes.py` | Add 3 new routes | Low — additive |
| `kb_service.py` | No changes — existing methods used by routes | None |
| Librarian skill | Update tool references | Low — documentation |
| Tests | New route + MCP tool tests | Low — additive |

## Proposed Approach

Classification: **Modification** to existing feature (additive — no breaking changes).
