Skip to content

Commit d49a1d7

Browse files
docs: extract a shared module for the agent connect snippets
The onboarding panel built the connection command inline. Move the command, labels, and JSON config into one connect-snippets module so the upcoming docs connect guide and the in-app onboarding draw from a single source and can never show different instructions. Onboarding output is unchanged.
1 parent 54af4e3 commit d49a1d7

2 files changed

Lines changed: 37 additions & 4 deletions

File tree

src/connect-snippets.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Single source of truth for how an MCP client connects to this server. Shared
2+
// by the /view first-run onboarding panel and the /docs connect guide so the two
3+
// can never drift: if they ever show different commands, that is a bug, and the
4+
// fix is to change it here. Verified against the real transport and auth flow:
5+
// /mcp speaks JSON-RPC over HTTP POST (plus SSE), implements initialize /
6+
// tools/list / tools/call, and advertises OAuth discovery so clients authorize
7+
// without a pasted token (see src/routes.ts handleMcp and README "OAuth mode").
8+
9+
export const MCP_SERVER_LABEL = 'memoryvault';
10+
export const MCP_TRANSPORT_LABEL = 'HTTP (streamable)';
11+
export const MCP_AUTH_LABEL = 'OAuth 2.1, leave the token blank and sign in once';
12+
export const CLAUDE_CODE_PREFIX = 'claude mcp add --transport http ' + MCP_SERVER_LABEL;
13+
14+
export function mcpUrlFor(origin: string): string {
15+
return origin + '/mcp';
16+
}
17+
18+
export function claudeCodeCommand(mcpUrl: string): string {
19+
return CLAUDE_CODE_PREFIX + ' ' + mcpUrl;
20+
}
21+
22+
export function mcpJsonConfig(mcpUrl: string): string {
23+
return '{\n "mcpServers": {\n "' + MCP_SERVER_LABEL + '": {\n "url": "' + mcpUrl + '"\n }\n }\n}';
24+
}

src/viewer/client-onboarding.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
// authenticated MCP path. Once a memory exists the panel collapses to a small
66
// dismissible hint. Everything here uses only this brain's own origin and the
77
// shared in-scope helpers (BASE, callMcpTool, loadMemories, showToast, esc).
8+
// The connection command/labels come from the shared connect-snippets module so
9+
// this panel and the /docs connect guide are guaranteed to match.
10+
import {
11+
CLAUDE_CODE_PREFIX,
12+
MCP_SERVER_LABEL,
13+
MCP_TRANSPORT_LABEL,
14+
MCP_AUTH_LABEL,
15+
} from '../connect-snippets.js';
16+
817
export const clientOnboarding = `
918
var onboardingForceOpen = false;
1019
var ONBOARDING_DISMISS_KEY = 'mv_onboarding_dismissed_v1';
@@ -15,8 +24,8 @@ export const clientOnboarding = `
1524
1625
function onboardingFullHtml() {
1726
var url = BASE + '/mcp';
18-
var claudeCmd = 'claude mcp add --transport http memoryvault ' + url;
19-
var jsonCfg = '{\\n "mcpServers": {\\n "memoryvault": {\\n "url": "' + url + '"\\n }\\n }\\n}';
27+
var claudeCmd = '${CLAUDE_CODE_PREFIX} ' + url;
28+
var jsonCfg = '{\\n "mcpServers": {\\n "${MCP_SERVER_LABEL}": {\\n "url": "' + url + '"\\n }\\n }\\n}';
2029
return '' +
2130
'<div class="ob-card">' +
2231
'<div class="ob-head">' +
@@ -40,8 +49,8 @@ export const clientOnboarding = `
4049
'<div class="ob-pane" data-pane="any" hidden>' +
4150
'<p class="ob-note">Add a remote MCP server with these values. This works for Codex, Cursor, and any custom client.</p>' +
4251
'<div class="ob-kv"><span>Server URL</span><code>' + esc(url) + '</code></div>' +
43-
'<div class="ob-kv"><span>Transport</span><code>HTTP (streamable)</code></div>' +
44-
'<div class="ob-kv"><span>Auth</span><code>OAuth 2.1, leave the token blank and sign in once</code></div>' +
52+
'<div class="ob-kv"><span>Transport</span><code>${MCP_TRANSPORT_LABEL}</code></div>' +
53+
'<div class="ob-kv"><span>Auth</span><code>${MCP_AUTH_LABEL}</code></div>' +
4554
'<div class="ob-row"><code class="ob-mono ob-pre">' + esc(jsonCfg) + '</code><button class="ob-copy" type="button" data-onb="copy">Copy</button></div>' +
4655
'</div>' +
4756
'</div></li>' +

0 commit comments

Comments
 (0)