feat: WebMCP polyfill — register skills tools with navigator.modelContext#150
Open
dfinityianblenke wants to merge 1 commit intomainfrom
Open
feat: WebMCP polyfill — register skills tools with navigator.modelContext#150dfinityianblenke wants to merge 1 commit intomainfrom
dfinityianblenke wants to merge 1 commit intomainfrom
Conversation
Registers list_skills, get_skill, and search_skills with navigator.modelContext so AI agents can call them as tools regardless of browser: Chrome 146+ uses the native WebMCP API, all others pick up the inline polyfill installed by this script. - public/webmcp-setup.js — self-contained polyfill + tool registration Uses the existing /.well-known/skills/ static API endpoints (no canister or @dfinity/webmcp dependency required). When PR #148 is deployed and @dfinity/webmcp is published, the execute() functions can be upgraded to use ICWebMCP for full Candid canister calls with certified responses. - src/layouts/BaseLayout.astro <link rel="modelcontext" href="/.well-known/webmcp.json"> — signals Chrome 146+ to load the manifest automatically. <script src="/webmcp-setup.js" defer> — loads the polyfill on every page. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Skill Validation ReportNo skill files were changed in this PR — validation skipped. |
This was referenced Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Registers
list_skills,get_skill, andsearch_skillswithnavigator.modelContextso AI agents can call them as tools from any browser — Chrome 146+ natively, all others via the inline polyfill.Two changes:
public/webmcp-setup.js— self-contained polyfill + tool registrationnavigator.modelContextshim if the native API is absent (non-Chrome-146+)/.well-known/skills/static endpoints — zero new dependencies, works right nowexecute()implementations use plainfetch(): no@dfinity/agent, no bundler, no CDN@dfinity/webmcpis published to npm, theexecute()bodies can be upgraded to fullICWebMCPcanister calls with certified responsessrc/layouts/BaseLayout.astro— two additions<link rel="modelcontext" href="/.well-known/webmcp.json">— tells Chrome 146+ where to find the manifest (from PR feat: serve /.well-known/webmcp.json — WebMCP manifest endpoint #149)<script src="/webmcp-setup.js" defer>— loads the polyfill on every pageHow the three tools work today (static API):
list_skillsGET /.well-known/skills/index.jsonget_skill(name)GET /.well-known/skills/{name}/SKILL.mdsearch_skills(query)Upgrade path (post PR #148 + npm publish):
Test plan
npm run buildpasses (verified locally)<link rel="modelcontext">and<script src="/webmcp-setup.js">present in built HTMLnavigator.modelContextis the native object;webmcp-setup.jsstill runs but polyfill install is skippednavigator.modelContext._registryhas three tools registered after page loadnavigator.modelContext._registry.get('list_skills').execute()returns the skills indexnavigator.modelContext._registry.get('get_skill').execute({name:'motoko'})returns SKILL.md contentThis optionally (but ideally) extends PR #149, and that should be merged first, which also depends on PR #148