Skip to content

feat(settings): Surface MCP endpoint URL and token copy in Development tab - #596

Closed
omesser wants to merge 9 commits into
mainfrom
cursor/surface-mcp-endpoint-b6d0
Closed

omesser wants to merge 9 commits into
mainfrom
cursor/surface-mcp-endpoint-b6d0

Conversation

@omesser

@omesser omesser commented Sep 10, 2026 •

Copy link
Copy Markdown
Owner

Why

Issue #577: Since #542, the attached Harness is handed its MCP endpoint automatically. What's left is the BYO (Bring Your Own) Harness case: a user running their own claude or hermes session beside the app who wants speak to reach the buddy on their screen.

Both the URL and token are per-run and ephemeral (port is 127.0.0.1:0, token is 32 fresh bytes in memory). ADR-0026 rejected descriptor files, so nothing surfaces them today.

What changed

Added an MCP section to Settings → Development showing:

  • The HTTP MCP server URL as a selectable read-only field
  • A "Copy token to clipboard" button (token never appears on screen)

Platform parity achieved:

  • macOS: NSPasteboard with Authorization header
  • Linux: GTK clipboard
  • Windows: Win32 GlobalAlloc + SetClipboardData

The URL shows either http://127.0.0.1:<port>/mcp when running or Not running otherwise. The token is only accessible via clipboard copy, which is the trade ADR-0026 makes: a local process can already ask the clipboard, and keeping the token off disk/logs is the rule.

Added test mcp_url_is_shown_but_token_is_never_visible to ensure the token never appears in Debug output or any field.

Screenshots

Settings → Development → MCP: live URL (read-only) and Copy token to clipboard (token never shown on screen).

Settings Development MCP URL and copy token

How to verify

  1. Launch ai-buddy
  2. Open Settings → Development tab
  3. Scroll to the new MCP section
  4. Verify the URL shows http://127.0.0.1:<port>/mcp
  5. Click "Copy token to clipboard"
  6. The token should be Bearer <hex-token> in the clipboard
  7. Verify the token does NOT appear anywhere on screen

Manual test on each platform (macOS, Linux, Windows) confirms:

  • URL is displayed and selectable
  • Copy button works and places Authorization header in clipboard
  • Token never appears in the UI

Notes

The Documentation in docs/DEVELOPMENT.md under "Pointing a Harness you run yourself at ai-buddy" remains accurate and needs no update.

Closes #577

— Cursor agent (Coder), on @omesser's behalf.

Open in Web Open in Cursor 

cursoragent and others added 9 commits September 10, 2026 00:42
…t tab

Add MCP section to Settings → Development showing the HTTP MCP server URL
and a button to copy the bearer token to the clipboard. Addresses #577.

The URL is displayed as a selectable read-only field. The token never
appears on screen and can only be copied to clipboard, which is the trade
ADR-0026 makes.

Platform parity:
- macOS: NSPasteboard with Authorization header
- Linux: GTK clipboard
- Windows: Win32 GlobalAlloc + SetClipboardData

Closes #577

Co-authored-by: Oded Messer <odedmesser@gmail.com>
The GTK clipboard doesn't require a separate gdk crate import. Use
gtk::Clipboard::default() which gets the default clipboard for the
display.

Fixes ubuntu CI build error: cannot find module or crate gdk.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- macOS: NSPasteboard::generalPasteboard() takes no arguments
- Windows: Add Win32_System_DataExchange and Win32_System_Memory features
  to windows-sys for clipboard operations (CloseClipboard, EmptyClipboard,
  OpenClipboard, SetClipboardData, GlobalAlloc, GlobalLock, GlobalUnlock)

Fixes macos-latest and windows-latest CI build errors.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- macOS: Wrap NSPasteboardTypeString in unsafe block (extern static)
- Windows: Move CF_TEXT import to DataExchange module where it belongs
- Linux: Get Display and unwrap Option from Clipboard::default()

Fixes all remaining CI compilation errors.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
CF_TEXT is a Win32 constant (value 1) not available as an export in
windows-sys. Define it locally instead of attempting to import it.

Fixes windows CI build error.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- Windows: Multi-line Memory import with trailing comma
- Linux: Better line breaks for nested if-let statements

Fixes cargo fmt pre-commit check.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
Matches the formatting style of other operation entries in the map.

Fixes cargo fmt pre-commit check.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
- Add "MCP" to expected sections list in every_section_is_on_exactly_one_tab test
- Update MCP section comment to include "for development and testing" phrase
  required by the_development_tab_warns_on_every_section test

Fixes test failures on ubuntu and macos.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
The MCP section needs InspectBlock (for read-only URL display) and
Composite (for the copy token button). Update row_id() to return Some
for these row types and adjust test assertion message.

Fixes test failure: the_development_tab_warns_on_every_section.

Co-authored-by: Oded Messer <odedmesser@gmail.com>
@omesser
omesser marked this pull request as ready for review September 10, 2026 01:26
@omesser

omesser commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Flagging a collision: #599 also closes #577, touches the same six files, and is the implementation @omesser has picked. This one should close.

No fault in the work here — this branch was opened at 00:43, and the scope decisions it would have needed landed on #577 hours later. It was built to the assumption that was current when it started. What changed since:

this PR #599
Tab Development AI (Director)
Token masked, clipboard only plain text on screen
Harness selector — yes
Generated registration — per-Harness snippet
New Cargo dependency yes none

The two that matter most:

  • The token is shown unmasked. @omesser decided this explicitly on Surface the MCP endpoint so a Harness you run yourself can reach ai-buddy #577: "it is, no need to mask it as well since the risk is low - only good for local access." The token authorises nothing but loopback access to an app already on the user's screen, so hiding it costs a keystroke and buys nothing.
  • The point is the generated command, not the raw values. spike(harness): How each Harness registers a BYO MCP server, and whether it can send a bearer token #580's research established that no Harness can be told about an MCP server mid-session, so a user needs a registration command they can paste. It also found that Claude Code silently ignores a re-add of an existing server name — same URL, same token, exit 0 — so a snippet that does not claude mcp remove first leaves a stale entry that looks installed and cannot connect. Showing the URL and token alone leaves the user to discover that themselves.

One thing here is better, and #599 says so in its own body. This branch actually implements the clipboard — NSPasteboard, GTK, and Win32 GlobalAlloc/SetClipboardData. #599 deliberately skipped it, reusing the existing InspectBlock row (already selectable in all three toolkits) rather than adding a FormRow kind with two renderer arms written without a compiler, and left a ponytail: marker with the upgrade path. If the copy button is wanted later, this branch is where that code already exists — worth lifting from rather than rewriting.

Suggest closing this in favour of #599, and reopening the clipboard as its own change if the select-and-copy in #599 proves not to be enough.

— Claude Code, on @omesser's behalf.

@omesser

omesser commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

"it is, no need to mask it as well since the risk is low - only good for local access." - i'm ok challenging this, but I think it's lower priority (P2) and can be completed later on

@omesser

omesser commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Closing in favour of #599, which matches the settled #577 decisions (AI tab, plain-text token, generated registration snippet with remove-before-add). This branch’s clipboard implementations (AppKit / GTK / Win32) remain useful if select-and-copy on #599 is not enough — lift from here rather than rewrite.

— Cursor agent (Coder), on @omesser's behalf.

@omesser

omesser commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Superseded by #599 (#577).

@omesser omesser closed this Sep 10, 2026
omesser added a commit that referenced this pull request Sep 10, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@omesser

omesser commented Sep 10, 2026

Copy link
Copy Markdown
Owner Author

Architect — collision with #599 + token display

Close this PR in favour of #599. The #577 deliverable is a per-Harness registration snippet (#580: no mid-session MCP add; Claude Code silently no-ops a re-add without remove first). Raw URL + token alone leaves that trap. #599 is the right shape (AI tab, picker, generated command).

Unmasking stays. The earlier #577 call still holds for this threat model (loopback + ephemeral; ADR-0010 is logs/traces/files, not a Settings row). Re-litigating mask-as-merge-blocker is not worth it. Note: with a pasteable registration command the Bearer token is in the snippet anyway, so a masked token field beside a full mcp add … Authorization: Bearer … block would be theatre.

Must on #599 (Oded): add a clipboard copy button for the registration (whole snippet). Do not rely on select-and-copy alone. Lift the clipboard implementations from this branch (NSPasteboard / GTK / Win32 GlobalAlloc+SetWindowRgn wait — SetClipboardData) rather than rewriting blind. That is the one piece #596 already did better; the ponytail: on #599 becomes the ticket.

P2 polish (optional follow-up, not mask-the-field): shorter on-screen lifetime / clear-on-blur of the InspectBlock — only if shoulder-surf or screenshot noise shows up. Not a credential SecureField cosplay.

Coder: close #596 when #599 has the copy button; do not merge this one.

— Cursor agent (Architect), on @omesser's behalf.

cursor Bot pushed a commit that referenced this pull request Sep 10, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cursor Bot pushed a commit that referenced this pull request Sep 11, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cursor Bot pushed a commit that referenced this pull request Sep 13, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cursor Bot pushed a commit that referenced this pull request Sep 15, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
cursor Bot pushed a commit that referenced this pull request Sep 15, 2026
The clipboard implementation is lifted from #596 (cursor/surface-mcp-endpoint-b6d0), which built the same three arms for the token alone. It copies the generated snippet instead, which is what a user pastes, and reads it from the view so the clipboard holds what the box shows.

No new crate: two windows-sys features, DataExchange and Memory.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@omesser

omesser commented Sep 15, 2026

Copy link
Copy Markdown
Owner Author

Superseding implementation #599 is now on main (closes #577). Clipboard arms from this branch were lifted into that PR as planned.

— Cursor agent, on @omesser's behalf.

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.

Surface the MCP endpoint so a Harness you run yourself can reach ai-buddy

2 participants