Skip to content

Add WebMCP support#62

Merged
nucliweb merged 5 commits into
mainfrom
feat/webmcp
Mar 3, 2026
Merged

Add WebMCP support#62
nucliweb merged 5 commits into
mainfrom
feat/webmcp

Conversation

@nucliweb
Copy link
Copy Markdown
Owner

@nucliweb nucliweb commented Mar 2, 2026

Summary

  • Registers three tools via the navigator.modelContext WebMCP API so AI agents can discover and use the snippets in a structured way
  • list_snippets — returns all snippet metadata (id, category, title, description, url) without code
  • get_snippet — returns the full JavaScript code for a snippet by ID
  • search_snippets — filters snippets by category and/or keyword

The snippets registry is loaded as a dynamic import, so it is only fetched when the browser supports WebMCP (navigator.modelContext exists). Browsers without support incur zero cost.

While validating the correct loading of the WebMCP registry chunk, cld-video-player.min.js (Cloudinary's video player library) was detected loading on every homepage visit. This has been addressed by lazy-loading CldVideoPlayer — the script only loads when the user explicitly clicks play.

Test plan

  • Open the site in Chrome 146+ Canary with WebMCP flags enabled
  • Verify navigator.modelContext is available
  • Call list_snippets and confirm all 31 snippets are returned
  • Call get_snippet with a valid ID (e.g. "LCP") and confirm code is returned
  • Call search_snippets with { category: "CoreWebVitals" } and confirm filtered results
  • Verify that in a standard browser (no WebMCP support) the registry chunk is never downloaded
  • Open the homepage → verify cld-video-player.min.js does NOT appear in the Network tab
  • Click the play button → verify cld-video-player.min.js loads and the video plays

Registers three tools via navigator.modelContext (WebMCP API):
- list_snippets: returns all snippet metadata without code
- get_snippet: returns full code for a snippet by ID
- search_snippets: filters by category and/or keyword

The snippets registry is loaded as a dynamic import so it is only
fetched when the browser supports WebMCP, with no cost for unsupported browsers.
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webperf-snippets Ready Ready Preview, Comment Mar 3, 2026 11:44am
webperf-snippets-u6am Ready Ready Preview, Comment Mar 3, 2026 11:44am

Adds a PostToolUse hook that lints JS/JSX files after Claude edits them.
The custom rule warns when a file has static non-framework imports alongside
a navigator feature guard, suggesting a dynamic import should be used instead.
@nucliweb nucliweb merged commit 3e1e2c5 into main Mar 3, 2026
3 checks passed
@nucliweb nucliweb deleted the feat/webmcp branch March 3, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant