Skip to content

Commit bf934d5

Browse files
authored
bugfix(mcp) correctly slice claude url hash (tldraw#8186)
Bring the url of the domain anthropic will be hosting its widget on in line with the [docs](https://claude.com/docs/connectors/building/mcp-apps/cross-compatibility#domain-handling) ### Change type - [ ] `bugfix` - [ ] `improvement` - [ ] `feature` - [ ] `api` - [x] `other` <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Small, isolated change to Claude widget domain computation; main risk is miscomputing the domain and breaking widget loading in Claude. > > **Overview** > Fixes Claude widget domain generation to match Anthropic’s docs by truncating the SHA-256 hex digest to the first 32 characters before appending `.claudemcpcontent.com`. > > Also updates the inline documentation/example command in `getWidgetDomain` and slightly refactors the hash string construction for readability. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 9638410. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent fe0a82f commit bf934d5

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

apps/mcp-app/src/register-tools.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,14 @@ function injectBootstrapData(html: string, bootstrap: Record<string, unknown>):
6565
* Returns the widget domain for the given host, or `undefined` in dev mode.
6666
*
6767
* - ChatGPT: https://developers.openai.com/apps-sdk/build/mcp-server#widget-domains
68-
* "Set `_meta.ui.domain` on the widget resource template. This is required for app
68+
* Set `_meta.ui.domain` on the widget resource template. This is required for app
6969
* submission and must be unique per app. ChatGPT renders the widget under
70-
* `<domain>.web-sandbox.oaiusercontent.com`"
70+
* `<domain>.web-sandbox.oaiusercontent.com`
7171
*
7272
* - Claude: https://claude.com/docs/connectors/building/mcp-apps/cross-compatibility#domain-handling
73-
* "Compute the value by running:
74-
* `node -e 'const u = "https://example.com/mcp"; console.log(require("crypto").createHash("sha256").update(u).digest("hex"))'`"
73+
* Compute the value by running:
74+
* `node -e 'const yourServerUrl = "https://example.com/mcp"; console.log(require("crypto").createHash("sha256").update(yourServerUrl).digest("hex").slice(0,32) + ".claudemcpcontent.com")'`
75+
"
7576
*/
7677
async function getWidgetDomain(
7778
hostName: string | undefined,
@@ -83,9 +84,9 @@ async function getWidgetDomain(
8384
if (hostName === 'claude' && workerOrigin) {
8485
const mcpUrl = new URL('/mcp', workerOrigin).toString()
8586
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(mcpUrl))
86-
const hash = Array.from(new Uint8Array(digest), (byte) =>
87-
byte.toString(16).padStart(2, '0')
88-
).join('')
87+
const hash = Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0'))
88+
.join('')
89+
.slice(0, 32)
8990
return `${hash}.claudemcpcontent.com`
9091
}
9192
return undefined

0 commit comments

Comments
 (0)