6aa84002b3
MCP clients see tools namespaced by the server's local name already
(mcp__<server>__<tool>), so the fable_ prefix on every tool name was
redundant and ate tokens in the model's tool list.
Tools renamed (34 total):
fable_search → search
fable_list_notes / get_note / create_note / update_note / delete_note → list_notes / ...
fable_list_tasks / get_task / create_task / update_task / add_task_log → list_tasks / ...
fable_list_projects / get_project / create_project / update_project → list_projects / ...
fable_list_milestones / create_milestone / update_milestone → list_milestones / ...
fable_list_events / create_event / get_event / update_event / delete_event → list_events / ...
fable_list_tags → list_tags
fable_get_recent → get_recent
fable_list_persons / create_person / update_person → list_persons / ...
fable_list_places / create_place / update_place → list_places / ...
fable_list_lists / create_list / update_list → list_lists / ...
Also rebranded in MCP scope:
FastMCP("fable", ...) → FastMCP("scribe", ...)
auth realm "fable-mcp" → "scribe-mcp"
ASGI scope key fable_user_id → scribe_user_id
ContextVar label fable_mcp_user_id → scribe_mcp_user_id
Tool docstrings "in Fable" / "Fable task" → "in Scribe" / "Scribe task"
Server _INSTRUCTIONS prose
Deliberately kept:
- The internal Python package name `fabledassistant` (per project naming
convention — internal stays).
- "Fabled Scribe" as the official product/brand name (page footer,
smtp_from_name default).
- References to the legacy `fable-mcp/` standalone package in docstrings
explaining what we ported from — accurate until that directory is
deleted in Phase 10.
Client impact: existing MCP registrations need
claude mcp remove <name> && claude mcp add ...
once with a freshly-copied snippet from Settings → MCP Access. Claude
Code then re-discovers tools on connect — old conversations that
referenced fable_* tool names will see "tool not found" on those calls
until updated.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
94 lines
3.0 KiB
Python
94 lines
3.0 KiB
Python
"""Tests for fable_*_project tools."""
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from fabledassistant.mcp._context import _user_id_ctx
|
|
from fabledassistant.mcp.tools.projects import (
|
|
list_projects, get_project, create_project,
|
|
update_project,
|
|
)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _bind_user():
|
|
token = _user_id_ctx.set(7)
|
|
yield
|
|
_user_id_ctx.reset(token)
|
|
|
|
|
|
def _fake_project(**overrides) -> MagicMock:
|
|
p = MagicMock()
|
|
base = {"id": 1, "title": "P", "description": "", "goal": "",
|
|
"status": "active", "color": None, "auto_summary": None}
|
|
base.update(overrides)
|
|
p.to_dict.return_value = base
|
|
return p
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_list_projects_wraps_in_dict():
|
|
rows = [_fake_project(id=1), _fake_project(id=2)]
|
|
with patch(
|
|
"fabledassistant.mcp.tools.projects.projects_svc.list_projects",
|
|
AsyncMock(return_value=rows),
|
|
):
|
|
out = await list_projects()
|
|
assert len(out["projects"]) == 2
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_project_enriches_with_milestone_summary():
|
|
p = _fake_project(id=5, title="found")
|
|
milestone_summary = [{"id": 10, "title": "MS", "task_count": 3}]
|
|
with patch(
|
|
"fabledassistant.mcp.tools.projects.projects_svc.get_project",
|
|
AsyncMock(return_value=p),
|
|
), patch(
|
|
"fabledassistant.mcp.tools.projects.milestones_svc.get_project_milestone_summary",
|
|
AsyncMock(return_value=milestone_summary),
|
|
):
|
|
out = await get_project(project_id=5)
|
|
assert out["id"] == 5
|
|
assert out["milestone_summary"] == milestone_summary
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_get_project_raises_when_not_found():
|
|
with patch(
|
|
"fabledassistant.mcp.tools.projects.projects_svc.get_project",
|
|
AsyncMock(return_value=None),
|
|
):
|
|
with pytest.raises(ValueError, match="project 999 not found"):
|
|
await get_project(project_id=999)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_create_project_passes_color_empty_as_none():
|
|
p = _fake_project()
|
|
mock = AsyncMock(return_value=p)
|
|
with patch("fabledassistant.mcp.tools.projects.projects_svc.create_project", mock):
|
|
await create_project(title="P", color="")
|
|
assert mock.call_args.kwargs["color"] is None
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_update_project_only_sends_non_default_fields():
|
|
p = _fake_project()
|
|
mock = AsyncMock(return_value=p)
|
|
with patch("fabledassistant.mcp.tools.projects.projects_svc.update_project", mock):
|
|
await update_project(project_id=1, status="archived")
|
|
args, kwargs = mock.call_args
|
|
assert args == (7, 1)
|
|
assert kwargs == {"status": "archived"}
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_update_project_raises_when_not_found():
|
|
with patch(
|
|
"fabledassistant.mcp.tools.projects.projects_svc.update_project",
|
|
AsyncMock(return_value=None),
|
|
):
|
|
with pytest.raises(ValueError, match="project 999 not found"):
|
|
await update_project(project_id=999, title="x")
|