Add Agent Bridge addon (AI control bridge + MCP server) - #934
Draft
brianmcaudill wants to merge 1 commit into
Draft
Add Agent Bridge addon (AI control bridge + MCP server)#934brianmcaudill wants to merge 1 commit into
brianmcaudill wants to merge 1 commit into
Conversation
Agent Bridge embeds a control bridge in a running Gramps session so an AI agent can drive the live application: read and modify the tree, operate the UI, and create and load plugins on the fly. It ships an MCP (Model Context Protocol) server so any MCP-capable AI can drive Gramps through standard tools. The gramplet polls a watched control directory on the GTK main thread and executes submitted Python in a persistent namespace with dbstate, db, uistate, gui and gramps_lib bound; the MCP server is a thin stdio adapter over that directory. No network port is opened. As defense-in-depth, every request must carry a shared secret token. The gramplet generates it on first run at ~/.gramps_agent/token (owner-only) and refuses any request without it; the MCP server and the debug CLI read the same file automatically. GRAMPS_AGENT_TOKEN overrides the file.
brianmcaudill
force-pushed
the
agentbridge60
branch
from
June 1, 2026 18:48
d681b16 to
c6bc820
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft / RFC — submitting for discussion per CONTRIBUTING's guidance on novel addons, especially around the security model below.
What it is
Agent Bridge embeds a control bridge inside a running Gramps session so an AI agent can drive the live application — read/modify the tree, operate the UI, and create and load plugins on the fly. It ships an MCP (Model Context Protocol) server, so any MCP-capable AI (Claude, etc.) can drive Gramps through standard tools with no custom glue.
Architecture
The gramplet polls a control directory on the GTK main thread via
GLib.timeout_add, so injected code can safely touch the database and the GUI. Code runs in a persistent namespace withdbstate,db,uistate,gui,gramps_lib, andbridgebound (assignresultto return a value). The MCP server is a thin stdio adapter over that directory — it needs themcppackage, not Gramps' interpreter.Tools exposed:
gramps_status,gramps_eval,gramps_install_plugin,gramps_people_count,gramps_search_people,gramps_active_person,gramps_set_active_person.Security (please weigh in)
This executes arbitrary Python at the user's privileges, by design — comparable to the built-in Python Shell gramplet, but drivable by an external agent. Mitigations: no network port (control is file-only under
~/.gramps_agent, i.e. the user-account trust boundary),audience=DEVELOPER, and prominent warnings in the README. Happy to add a token gate (a secret file the bridge checks per request) for defense-in-depth if maintainers prefer.Testing
Verified end-to-end on GrampsAIO 6.0.8 (Windows) against an 868-person tree: bridge ping, live
eval(db/uistate access), name search, on-the-fly plugin install with auto-registration (reg_plugins(..., rescan=True)), and a full MCP client→server→bridge→Gramps round-trip exercising the tools above.Notes for reviewers
gramps_target_version="6.0"onmaintenance/gramps60; can port to 6.1.gramps_mcp_server.pyandagent_send.pyare a standalone MCP server and a debug CLI; they are not registered as Gramps plugins.po/template.potwas hand-generated (no gettext toolchain on the dev box); happy to regenerate via the build.