The snippet (most sites)#
Paste this into every page of the websites you listed. The <head> or the end of <body> both work.
<script id="webmcp-embed-script" src="https://js.subcontext.com/webmcp-latest.js"
data-key="wmk_YOUR_KEY" async></script>
When it loads, the script reads your key, asks Subcontext (https://subcontext.com) which tools your
integration offers, and registers each one with the browser. It waits for the page to finish loading first
if it needs to.
- You can use
asyncordefer, or add the tag from your own JavaScript (for example through a tag manager). - Keep
id="webmcp-embed-script". It helps the script find its own tag in every case. webmcp-latest.jsalways gives you the latest version. Browsers cache it for up to 5 minutes. If you need a fixed version that never changes, ask Subcontext.
From your own JavaScript#
To decide when the tools are offered (for example only after a visitor agrees to it), load the script
without data-key. It then does nothing until you call init:
<script src="https://js.subcontext.com/webmcp-latest.js"></script>
<script>
SubcontextWebMCP.init({ key: 'wmk_YOUR_KEY' }).then(function (result) {
if (result.ok) console.log('Tools offered:', result.tools)
else console.log('Tools not offered:', result.status, result.error)
})
</script>
Use one or the other. If the tag has data-key and you call init, the one that runs last
wins, and the other reports cancelled.
Options#
On the script tag#
| Attribute | What it does | Default |
|---|---|---|
data-key |
Your integration's key (starts wmk_). The script starts by itself only when this is there. Without it, the script waits for you to call init. |
none |
data-debug |
Set to "true" to log extra detail in the console: the tool list request and what came back, each tool registered, and each tool call with its input and its result or error. These are debug messages, so set the console to show the Verbose level. Only the exact text "true" turns it on. |
off |
data-base-url |
Where to send requests. You don't normally need this. | https://subcontext.com |
id="webmcp-embed-script" |
Not an option. It helps the script find its own tag. Keep it. |
SubcontextWebMCP.init(options)#
| Option | Type | What it does | Default |
|---|---|---|---|
key |
string | Your integration's key. Required. | none |
debug |
boolean | Same as data-debug. |
false |
baseUrl |
string | Same as data-base-url. A trailing slash is ignored. You don't normally need this. |
https://subcontext.com |
There are no other options. Which tools are offered, and their names, descriptions and inputs, all come from the integration in the dashboard.