Skip to content

Add structs_comms MCP tool: headless Matrix guild chat (+ multi-hop consent fix) - #1

Open
ibeezhan wants to merge 1 commit into
playstructs:mainfrom
ibeezhan:feat/comms-mcp-tool
Open

Add structs_comms MCP tool: headless Matrix guild chat (+ multi-hop consent fix)#1
ibeezhan wants to merge 1 commit into
playstructs:mainfrom
ibeezhan:feat/comms-mcp-tool

Conversation

@ibeezhan

Copy link
Copy Markdown

What

Adds a new structs_comms MCP tool that re-exposes the app's existing Matrix client (src-tauri/src/matrix/) over MCP, so an agent can read and post to guild chat rooms as the player it is already signed in as. Sign-in is the in-app wallet signature (via vplayer_bridge, which only ever signs the fixed LOGIN_GUILD message), so no key or token ever leaves the app.

Actions: status, connect, disconnect, rooms, browse, timeline, backfill, send, join, leave, dm, react, people. guild_id defaults to the active guild.

Also fixes

The OAuth consent() handler in matrix/auth.rs only followed one MAS consent form. MAS can interpose more than one interstitial form in a row (e.g. a consent screen followed by a device/scope confirmation), which previously stopped the login chain with stopped at .../consent/... instead of returning a code. The handler now posts each form in turn — always only to the issuer the homeserver named — until it reaches the authorization code.

Docs

README updated in the repo's own style: tool table (13→14 tools), file tree entry for comms.rs, and a new "Guild Comms (Matrix)" section documenting the headless sign-in chain, the action set, and the safety properties.

Testing / provenance

This patch (tool + consent fix + docs) was AI-generated (Claude) and tested end-to-end against a live guild account: connected as a real player (@1-471:…, guild SN Corp 0-5), joined a guild room, and read/posted messages over Matrix before submission.

Note for maintainers

main has advanced since this branch's base (9959b53) toward a frontend-first comms approach (chat.js / chat.html, expanded matrix/client.rs). This PR is the agent-facing MCP surface and is complementary rather than a continuation — it may want reconciling against the newer matrix/mod.rs / client.rs before merge. Happy to rebase onto latest main on request.

Re-exposes the app's existing Matrix client (src-tauri/src/matrix/) over
MCP as a new `structs_comms` tool, so an agent can read and post to guild
chat rooms as the player it is already signed in as. Sign-in is the in-app
wallet signature (via vplayer_bridge, which only ever signs the fixed
LOGIN_GUILD login message), so no key or token leaves the app.

Actions: status, connect, disconnect, rooms, browse, timeline, backfill,
send, join, leave, dm, react, people. guild_id defaults to the active guild.

Also fixes the OAuth consent handler in matrix/auth.rs to follow *multiple*
consecutive MAS consent/interstitial forms instead of just one: MAS can
interpose more than one form in a row (e.g. a consent screen followed by a
device/scope confirmation), which previously stopped the chain with
"stopped at .../consent/... instead of returning a code". Each form is
posted in turn, always only to the issuer the homeserver named.

Docs added to README (tool table, file tree, and a Guild Comms section).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant