Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Add browser handoff links for Cursor and VS Code hosted MCP setup, editable connection names, and manual configuration fallbacks. (#2809, #2828)
- Add a hosted-console Connect guide for Claude Code, Codex, Claude web/Desktop, and Cursor, with deployment-owned endpoint discovery and current-user connection status. (#2803)
- Incorporate the 2.0.42 macOS verification dialog security fix and prepare safety package 1.0.3, retaining beta’s timing-safe challenge comparison. (#2686)
- Publish the safety package before the server and retain beta channel protection during version-safe release dry runs. (#2686)
Expand Down
9 changes: 7 additions & 2 deletions docs/guides/hosted-client-connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ Sign in to the hosted console and open **Connect**. The console reads the deploy
- Codex
- Claude web and Desktop custom connectors
- Cursor
- VS Code / GitHub Copilot

Client documentation: [Claude Code MCP](https://code.claude.com/docs/en/mcp), [Claude custom connectors](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp), [Codex MCP](https://learn.chatgpt.com/docs/extend/mcp), and [Cursor install links](https://prod.cursor.com/docs/mcp/install-links).
Client documentation: [Claude Code MCP](https://code.claude.com/docs/en/mcp), [Claude custom connectors](https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp), [Codex MCP](https://learn.chatgpt.com/docs/extend/mcp), [Cursor install links](https://prod.cursor.com/docs/mcp/install-links), and [VS Code MCP installation](https://code.visualstudio.com/api/extension-guides/ai/mcp).

Use the separate connection name `dollhouse-beta` so an existing local `dollhousemcp` configuration remains unchanged. After adding the endpoint, complete OAuth in the browser when the client prompts you. Copying a command or opening an install link only starts setup; the console reports a connection after the client establishes a real MCP session. Use **Connect → Connected apps** or the full **Sessions** tab to verify it.
The default name is `dollhouse-beta`. You can edit it before setup, using 1–64 ASCII letters, numbers, hyphens, or underscores, starting with a letter or number. Choose a name that is free in your client so an existing local `dollhousemcp` or hosted connection remains unchanged. The console cannot read local client configuration or detect a name collision. Review the proposed name and URL in your client before saving; a name already in use may replace that client's entry.

For Cursor or VS Code, select its tab and choose **Open in Cursor** or **Open in VS Code**. Your browser asks to open the installed desktop app. Review the proposed server there, save it, start or enable it if prompted, and complete OAuth in the browser. If the app is missing, the browser does not open it, or you cancel, install or open the app and retry the link. You can also use the manual JSON on the same tab: merge the named entry into your existing Cursor `mcpServers` or VS Code `servers` configuration without replacing other entries. In VS Code, **MCP: Add Server** → **HTTP** in the Command Palette is another fallback; use the endpoint and connection name shown on the page.

For Claude Code and Codex, use the shown CLI commands. For Claude web or Desktop, add a custom connector with the shown URL and name. Copying a command or opening a native install link only starts setup; it does not confirm installation or connection. Use **Connect → Connected apps** or the full **Sessions** tab to verify a real MCP session. To remove a connection, remove its named entry in the client. Remove saved OAuth authorization separately through that client's account controls if desired.

Basic hosted access does not require a local DollhouseMCP server. Local permission hooks and host audit require separate local support and are not installed by the hosted flow.

Expand Down
78 changes: 78 additions & 0 deletions src/web-console/ui/connect-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/** Pure connection configuration; native formats stay separate from UI and permission evaluation. */

export const DEFAULT_CONNECTION_NAME = 'dollhouse-beta';

export function validateConnectionName(value) {
const match = typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.exec(value);
// JavaScript's $ anchor also matches just before a final newline.
if (!match || match[0] !== value) {
throw new Error('Use 1–64 letters, numbers, hyphens or underscores, starting with a letter or number.');
}
return value;
}

export function hostedConnectionProfile(endpoint, pageOrigin, connectionName = DEFAULT_CONNECTION_NAME) {
return Object.freeze({
schemaVersion: 1,
connectionName: validateConnectionName(connectionName),
endpoint: validateHostedMcpEndpoint(endpoint, pageOrigin),
transport: 'streamable-http',
});
}

export function validateHostedMcpEndpoint(value, pageOrigin) {
if (typeof value !== 'string' || value.length === 0) throw new Error('Connection metadata did not include an MCP endpoint.');
if (unsafeEndpointText(value)) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
let endpoint;
let origin;
try {
endpoint = new URL(value);
origin = new URL(pageOrigin);
} catch {
throw new Error('Connection metadata included an invalid MCP endpoint.');
}
if (unsafeEndpointText(endpoint.href)) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
const loopbackHttp = endpoint.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(endpoint.hostname);
if ((endpoint.protocol !== 'https:' && !loopbackHttp)
|| endpoint.origin !== origin.origin
|| endpoint.username || endpoint.password
|| endpoint.search || endpoint.hash) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
return endpoint.href;
}

function unsafeEndpointText(value) {
return value.includes("'") || value.includes('\\') || [...value].some(character => {
const codePoint = character.codePointAt(0);
return codePoint <= 32 || codePoint === 127;
});
}

function base64Utf8(value) {
// Endpoint validation and URL canonicalization constrain this JSON to ASCII.
return btoa(value);
}

export function connectionArtifacts(endpoint, pageOrigin, connectionName = DEFAULT_CONNECTION_NAME) {
const profile = hostedConnectionProfile(endpoint, pageOrigin, connectionName);
const safeEndpoint = profile.endpoint;
const cursorLinkConfig = JSON.stringify({ url: safeEndpoint });
const cursorConfig = JSON.stringify({ mcpServers: { [profile.connectionName]: { url: safeEndpoint } } }, null, 2);
return Object.freeze({
profile,
endpoint: safeEndpoint,
claudeAdd: `claude mcp add --transport http --scope user ${profile.connectionName} '${safeEndpoint}'`,
claudeLogin: `claude mcp login ${profile.connectionName}`,
codexAdd: `codex mcp add ${profile.connectionName} --url '${safeEndpoint}'`,
codexLogin: `codex mcp login ${profile.connectionName}`,
cursorLink: `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(profile.connectionName)}&config=${encodeURIComponent(base64Utf8(cursorLinkConfig))}`,
cursorConfig,
vscodeLink: `vscode:mcp/install?${encodeURIComponent(JSON.stringify({ name: profile.connectionName, type: 'http', url: safeEndpoint }))}`,
vscodeConfig: JSON.stringify({ servers: { [profile.connectionName]: { type: 'http', url: safeEndpoint } } }, null, 2),
});
}
6 changes: 6 additions & 0 deletions src/web-console/ui/connect.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
.connect-endpoint { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.connect-endpoint > span { font-weight: 700; }
.connect-endpoint code, .connect-value code { overflow-wrap: anywhere; }
.connect-name { display: grid; gap: .4rem; }
.connect-name label { font-weight: 700; }
.connect-name input { width: min(100%, 24rem); box-sizing: border-box; padding: .65rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink-950); background: var(--paper); font: inherit; }
.connect-name input:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.connect-name p { margin: 0; color: var(--ink-500); line-height: 1.5; }
.connect-name #connect-name-error { color: #b42318; }
.connect-client-tabs { display: flex; gap: .5rem; flex-wrap: wrap; }
.connect-client-tab { border: 1px solid var(--line); border-radius: 999px; background: var(--paper); color: var(--ink-700); padding: .65rem 1rem; cursor: pointer; font: inherit; }
.connect-client-tab.is-active { background: var(--ink-950); color: var(--paper); border-color: var(--ink-950); }
Expand Down
126 changes: 57 additions & 69 deletions src/web-console/ui/connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,16 @@

import { get } from './api.js';
import { escapeHtml, relAgo } from './ui-utils.js';
import { connectionArtifacts, DEFAULT_CONNECTION_NAME, validateConnectionName, validateHostedMcpEndpoint } from './connect-config.js';

const METADATA_PATH = '/.well-known/oauth-protected-resource';
const CONNECTION_NAME = 'dollhouse-beta';

export { connectionArtifacts, validateHostedMcpEndpoint } from './connect-config.js';

let host;
let notify = () => {};
let sessionsTabAvailable = false;

export function validateHostedMcpEndpoint(value, pageOrigin) {
if (typeof value !== 'string' || value.length === 0) throw new Error('Connection metadata did not include an MCP endpoint.');
if (unsafeEndpointText(value)) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
let endpoint;
let origin;
try {
endpoint = new URL(value);
origin = new URL(pageOrigin);
} catch {
throw new Error('Connection metadata included an invalid MCP endpoint.');
}
if (unsafeEndpointText(endpoint.href)) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
const loopbackHttp = endpoint.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(endpoint.hostname);
if ((endpoint.protocol !== 'https:' && !loopbackHttp)
|| endpoint.origin !== origin.origin
|| endpoint.username || endpoint.password
|| endpoint.search || endpoint.hash) {
throw new Error('Connection metadata did not provide a safe endpoint for this deployment.');
}
return endpoint.href;
}

function unsafeEndpointText(value) {
return value.includes("'") || value.includes('\\') || [...value].some(character => {
const codePoint = character.codePointAt(0);
return codePoint <= 32 || codePoint === 127;
});
}

function base64Utf8(value) {
// Endpoint validation and URL canonicalization constrain this JSON to ASCII.
return btoa(value);
}

export function connectionArtifacts(endpoint, pageOrigin) {
const safeEndpoint = validateHostedMcpEndpoint(endpoint, pageOrigin);
const cursorLinkConfig = JSON.stringify({ url: safeEndpoint });
const cursorConfig = JSON.stringify({ mcpServers: { [CONNECTION_NAME]: { url: safeEndpoint } } }, null, 2);
return Object.freeze({
endpoint: safeEndpoint,
claudeAdd: `claude mcp add --transport http --scope user ${CONNECTION_NAME} '${safeEndpoint}'`,
claudeLogin: `claude mcp login ${CONNECTION_NAME}`,
codexAdd: `codex mcp add ${CONNECTION_NAME} --url '${safeEndpoint}'`,
codexLogin: `codex mcp login ${CONNECTION_NAME}`,
cursorLink: `cursor://anysphere.cursor-deeplink/mcp/install?name=${encodeURIComponent(CONNECTION_NAME)}&config=${encodeURIComponent(base64Utf8(cursorLinkConfig))}`,
cursorConfig,
});
}

export function connectedAppsMarkup(sessions, failed = false) {
if (failed) return '<div class="connect-state connect-state--error"><strong>Could not check connected apps.</strong><span>Use Refresh to try again.</span></div>';
if (!Array.isArray(sessions) || sessions.length === 0) {
Expand Down Expand Up @@ -98,8 +47,14 @@ function pageShell() {
</header>
<div class="connect-notice"><strong>No local server is required for basic hosted access.</strong> Local permission hooks and host audit need separate local support and are not enabled by this setup.</div>
<div id="connect-endpoint" class="connect-endpoint" aria-live="polite">Loading the secure endpoint…</div>
<div class="connect-name">
<label for="connect-name">Connection name</label>
<input id="connect-name" value="${DEFAULT_CONNECTION_NAME}" maxlength="64" autocomplete="off" spellcheck="false" aria-describedby="connect-name-help connect-name-error">
<p id="connect-name-help">Use a name that is free in your client to preserve existing connections. This page cannot check your client's saved names.</p>
<p id="connect-name-error" role="status"></p>
</div>
<div class="connect-client-tabs" role="group" aria-label="Choose an AI client">
${clientTab('claude-code', 'Claude Code', true)}${clientTab('codex', 'Codex')}${clientTab('claude', 'Claude web / Desktop')}${clientTab('cursor', 'Cursor')}
${clientTab('claude-code', 'Claude Code', true)}${clientTab('codex', 'Codex')}${clientTab('claude', 'Claude web / Desktop')}${clientTab('cursor', 'Cursor')}${clientTab('vscode', 'VS Code / GitHub Copilot')}
</div>
<div id="connect-client-panel"></div>
<section class="connect-status" aria-labelledby="connect-status-title">
Expand All @@ -116,6 +71,9 @@ function clientTab(id, label, active = false) {

function bindStaticActions() {
host.querySelectorAll('[data-client]').forEach(button => button.addEventListener('click', () => selectClient(button.dataset.client)));
host.querySelector('#connect-name').addEventListener('input', () => selectClient(
host.querySelector('[data-client][aria-pressed="true"]').dataset.client,
));
host.querySelector('#connect-refresh').addEventListener('click', refreshSessions);
host.querySelector('#connect-open-sessions')?.addEventListener('click', () => {
document.querySelector('.console-tab[data-tab="sessions"]')?.click();
Expand All @@ -140,7 +98,7 @@ async function loadEndpoint() {
const code = document.createElement('code');
code.textContent = endpoint;
target.append(label, code, copyButton(endpoint, 'Copy endpoint'));
selectClient('claude-code');
selectClient(host.querySelector('[data-client][aria-pressed="true"]')?.dataset.client || 'claude-code');
} catch {
host.dataset.endpoint = '';
host.querySelector('#connect-endpoint').innerHTML = '<div class="connect-state connect-state--error"><strong>Connection setup is unavailable.</strong><span>The server did not provide a safe MCP endpoint. Try again later.</span></div>';
Expand All @@ -149,16 +107,28 @@ async function loadEndpoint() {
}

function selectClient(client) {
const endpoint = host.dataset.endpoint;
if (!endpoint) return;
host.querySelectorAll('[data-client]').forEach(button => {
const active = button.dataset.client === client;
button.classList.toggle('is-active', active);
button.setAttribute('aria-pressed', String(active));
});
host.querySelector('#connect-client-panel').replaceChildren(
renderClientPanel(client, connectionArtifacts(endpoint, globalThis.location.origin)),
);
const endpoint = host.dataset.endpoint;
if (!endpoint) return;
const nameInput = host.querySelector('#connect-name');
const nameError = host.querySelector('#connect-name-error');
const target = host.querySelector('#connect-client-panel');
let connectionName;
try {
connectionName = validateConnectionName(nameInput.value);
} catch (error) {
nameInput.setAttribute('aria-invalid', 'true');
nameError.textContent = error.message;
target.replaceChildren(instructions('Choose a valid connection name to show setup actions.'));
return;
}
nameInput.removeAttribute('aria-invalid');
nameError.textContent = '';
target.replaceChildren(renderClientPanel(client, connectionArtifacts(endpoint, globalThis.location.origin, connectionName)));
}

function renderClientPanel(client, artifacts) {
Expand All @@ -174,18 +144,36 @@ function renderClientPanel(client, artifacts) {
oauthNote(),
);
} else if (client === 'claude') {
panel.append(instructions('In Claude web or Desktop, open Customize → Connectors → + → Add custom connector. Enter a readable name such as “Dollhouse Beta,” paste this URL, then choose Connect and finish authorization in the browser.'), valueBlock(artifacts.endpoint, 'Copy connector URL'), oauthNote());
} else {
const link = document.createElement('a');
link.className = 'btn btn-primary';
link.href = artifacts.cursorLink;
link.textContent = 'Open in Cursor';
link.addEventListener('click', () => notify('Finish setup and OAuth in Cursor, then refresh connected apps.', 'info'));
panel.append(instructions('Use the install link, or open Cursor Settings → MCP and add the manual JSON below.'), link, valueBlock(artifacts.cursorConfig, 'Copy manual JSON'), oauthNote());
panel.append(instructions(`In Claude web or Desktop, open Customize → Connectors → + → Add custom connector. Use the name “${artifacts.profile.connectionName},” paste this URL, then choose Connect and finish authorization in the browser.`), valueBlock(artifacts.endpoint, 'Copy connector URL'), oauthNote());
} else if (client === 'cursor') {
panel.append(
instructions('Open Cursor from your browser, review the server configuration, then finish setup and OAuth in Cursor.'),
nativeInstallLink('Cursor', artifacts.cursorLink),
instructions('If Cursor is not installed, does not open, or you cancel, install or open Cursor and retry, or add this entry under mcpServers in Cursor Settings → MCP. Preserve your other entries.'),
valueBlock(artifacts.cursorConfig, 'Copy manual JSON'), oauthNote(),
);
} else if (client === 'vscode') {
panel.append(
instructions('Open the installed VS Code desktop app from your browser. Review the server URL and name, choose where to save it, then start the server and complete OAuth when prompted.'),
nativeInstallLink('VS Code', artifacts.vscodeLink),
instructions('If VS Code is not installed, does not open, or you cancel, install or open VS Code and retry, or run “MCP: Add Server” in its Command Palette, choose HTTP, and use the endpoint and connection name above. For manual configuration, merge this entry into your mcp.json without replacing other servers.'),
valueBlock(artifacts.vscodeConfig, 'Copy manual JSON'),
instructions('To remove this connection, remove its named entry from your MCP configuration. You can manage saved authentication separately in VS Code’s Accounts menu.'),
oauthNote(),
);
}
return panel;
}

function nativeInstallLink(clientName, href) {
const link = document.createElement('a');
link.className = 'btn btn-primary';
link.href = href;
link.textContent = `Open in ${clientName}`;
link.addEventListener('click', () => notify(`Finish setup and OAuth in ${clientName}, then refresh connected apps.`, 'info'));
return link;
}

function instructions(text) {
const p = document.createElement('p'); p.textContent = text; return p;
}
Expand Down
Loading
Loading