Skip to content

feat(mcp): edit, merge and undo entities and topics from agents - #389

Merged
adeelahmad merged 2 commits into
mainfrom
claude/project-thread-ecob6g
Oct 15, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/project-thread-ecob6g

Conversation

@adeelahmad

@adeelahmad adeelahmad commented Oct 15, 2026 •

Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: an agent over MCP could merge entities, but couldn't rename, retype or hide one, couldn't touch topics at all, and couldn't take a change back. The assistant could propose entity changes but not topic ones.

After: MCP has edit_entity (rename, retype, add aliases, hide), edit_topic (rename, define), merge_topics, delete_topic, undo_topic_change and undo_graph_change. They need a write-scope token and call the same routes, with the same checks, as the web app. merge_topics and delete_topic answer with an undo_id for undo_topic_change, undo_graph_change takes back a merge or link made with propose_graph_change, and a rename or hide is undone by another edit. The assistant gains propose_topic_change (merge, rename, define, delete), which waits for the user's approval like entity changes do, in the app or a chat room. Approving clears the graph cache so the change shows at once.

How: app/api/mcp_tools.py adds the tools on top of the entity, topic and graph-history routes; app/domain/ai_tools.py adds the proposal tool and its carry-out; app/domain/bridge.py lets chat rooms approve it; routes/chats.py clears the graph cache after an approval. The model settings list and the chat step labels name the new tool.

Motivation and Context

Adeel: "No easy way to merge and edit entities, topics etc. Should be as easy as from the graph explorer and canvas." Agent-first: the last of the small PRs after the entities page (#384), the graph (#386), topic undo (#387) and a recording's Entities tab (#388).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (make hooks checks it on commit).
  • I added or updated tests. (tests/api/test_mcp.py editing topics and entities and undoing; tests/api/test_topics.py the assistant proposing topic changes)
  • My change requires documentation updates, and I have updated docs/ accordingly. (docs/mcp.md, docs/topics.md, docs/assistant.md, docs/chat-rooms.md)
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: delivers what the user wanted, merged on green CI. (last part; this PR completes it once merged)
  • Agents: this is the agent side: MCP tools and an assistant tool.
  • Zero setup: no new prerequisite, .env edit or manual step; the tools appear for write-scope tokens.
  • Fewest clicks and keystrokes: one tool call, or one approval for the assistant's proposal.
  • Configurable: n/a, no new setting; the assistant tool shows in the model settings list like the others.
  • Light: n/a, no new dependency or service.
  • Private and secure: writes need a write-scope token and the curate right on the namespace; the assistant only proposes. threat-model.md has a row for the curation tools.
  • Cost: no new model calls; the assistant's turns are logged in the activity ledger as before.
  • User decides: the assistant's topic changes wait for the user's approval; defaults unchanged.
  • Upgrades: n/a, no change to stored data.
  • Honest: docs describe only what is merged here.
  • Tests, docs and generated files updated. (no REST API change, so no make openapi)
  • Open standards; dependencies keep Lens MIT. (MCP; no new dependency)
  • Result reported with evidence; "refine later" items written down. (refine later: not every write path clears the graph cache yet)

🤖 Generated with Claude Code

https://claude.ai/code/session_01EzVhJCpwskyo5NhHEtS822

MCP gains edit_entity, edit_topic, merge_topics, delete_topic,
undo_topic_change and undo_graph_change, calling the same routes (and
checks) as the web app with a write-scope token. The assistant proposes
topic merges, renames, definitions and deletes for approval
(propose_topic_change), approvable in a chat room like entity changes.
Approving clears the graph cache so the change shows at once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzVhJCpwskyo5NhHEtS822
@adeelahmad adeelahmad self-assigned this Oct 15, 2026
…nions

The prose gained a row for the entity and topic curation tools; the
companions now list the same entry point and carry the prose's hash.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EzVhJCpwskyo5NhHEtS822
@adeelahmad
adeelahmad merged commit 80b6c51 into main Oct 15, 2026
11 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-ecob6g branch October 15, 2026 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants