webmcp-context-provider
Implement the WebMCP provideContext API — bulk tool registration, contextual metadata, page state sharing, and dynamic context updates. Use when providing rich context and multiple tools to agents simultaneously.
Best use case
webmcp-context-provider is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Implement the WebMCP provideContext API — bulk tool registration, contextual metadata, page state sharing, and dynamic context updates. Use when providing rich context and multiple tools to agents simultaneously.
Teams using webmcp-context-provider should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/webmcp-context-provider/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How webmcp-context-provider Compares
| Feature / Agent | webmcp-context-provider | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Implement the WebMCP provideContext API — bulk tool registration, contextual metadata, page state sharing, and dynamic context updates. Use when providing rich context and multiple tools to agents simultaneously.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# WebMCP Context Provider
## Before writing code
**Fetch live docs**:
1. Fetch `https://webmachinelearning.github.io/webmcp/` for the `provideContext` method specification
2. Web-search `webmcp provideContext specification` for the API shape and options
3. Web-search `webmcp context metadata agent` for contextual data patterns
4. Web-search `site:developer.chrome.com webmcp context` for Chrome-specific context features
## Conceptual Architecture
### What provideContext Does
`navigator.modelContext.provideContext(options)` is a method for bulk registration of multiple tools and providing additional contextual metadata to agents. While `registerTool` adds one tool at a time, `provideContext` can set up an entire tool surface in a single call.
**Note:** This API is still being specified and may change. Always fetch the latest spec before implementing.
### Why Context Matters
Agents make better decisions when they understand the current page state:
- What page the user is on (product detail, cart, checkout)
- User's authentication state and preferences
- Current cart contents and totals
- Available promotions or special offers
- Site capabilities and limitations
### provideContext vs registerTool
| Aspect | registerTool | provideContext |
|--------|-------------|----------------|
| **Granularity** | One tool at a time | Multiple tools + metadata |
| **Metadata** | Tool-level only | Page-level context included |
| **Use case** | Dynamic, individual tools | Page initialization, bulk setup |
| **Lifecycle** | Register/unregister individually | Set/clear entire context |
### Contextual Metadata Patterns
Provide agents with situational awareness:
**Product page context:**
```js
navigator.modelContext.provideContext({
tools: [viewDetails, addToCart, compareProducts],
metadata: {
pageType: "product-detail",
productId: "sku-12345",
productName: "Wireless Headphones",
price: 79.99,
inStock: true,
userAuthenticated: true
}
});
```
**Cart page context:**
```js
navigator.modelContext.provideContext({
tools: [updateQuantity, removeItem, applyCoupon, checkout],
metadata: {
pageType: "shopping-cart",
itemCount: 3,
subtotal: 247.50,
currency: "USD",
hasShippingAddress: true,
hasSavedPayment: true
}
});
```
### Dynamic Context Updates
Update context as the page state changes:
```js
// Initial page load — browse tools
navigator.modelContext.provideContext({
tools: [searchProducts, viewDetails],
metadata: { pageType: "catalog", authenticated: false }
});
// User logs in — expand tools
navigator.modelContext.clearContext();
navigator.modelContext.provideContext({
tools: [searchProducts, viewDetails, addToCart, getCartContents, checkout],
metadata: { pageType: "catalog", authenticated: true, userName: "Alice" }
});
// Navigate to cart — switch tools
navigator.modelContext.clearContext();
navigator.modelContext.provideContext({
tools: [updateQuantity, removeItem, applyCoupon, checkout],
metadata: { pageType: "cart", itemCount: 3 }
});
```
### SPA Route-Based Context
In single-page applications, update context on route changes:
```js
router.on("routeChange", (route) => {
navigator.modelContext.clearContext();
switch (route.name) {
case "catalog":
provideCatalogContext();
break;
case "product":
provideProductContext(route.params.id);
break;
case "cart":
provideCartContext();
break;
case "checkout":
provideCheckoutContext();
break;
}
});
```
### Best Practices
- Use `provideContext` for initial page setup; use `registerTool` / `unregisterTool` for incremental changes
- Include page type and user state in metadata so agents understand the current context
- Clear context on navigation and re-provide for the new page
- Keep metadata lightweight — summaries, not full data dumps
- Avoid including sensitive user data (email, address) in metadata — agents don't need it
- Update context when significant state changes occur (login, cart update, page navigation)
Fetch the specification for the exact `provideContext` options shape, metadata fields, and any new features before implementing.Related Skills
webmcp-user-interaction
Implement human-in-the-loop flows with requestUserInteraction() — confirmation dialogs, approval workflows, and user prompts during tool execution. Use when building tools that require user consent before performing actions.
webmcp-tool-schemas
Design JSON Schemas for WebMCP tool inputs and outputs — proper types, constraints, nested objects, and agent-friendly documentation. Use when defining or refining tool schemas for agent consumption.
webmcp-tool-annotations
Implement WebMCP tool annotations — readOnlyHint, destructiveHint, idempotentHint safety hints that inform browser permission prompts and agent behavior. Use when marking tools with appropriate safety metadata.
webmcp-testing
Test WebMCP tools with AI agents — Chrome DevTools integration, agent testing workflows, tool discovery verification, and end-to-end commerce flow testing. Use when validating that tools work correctly with real AI agents.
webmcp-setup
Set up a WebMCP project — enable Chrome flags, install MCP-B polyfill, scaffold tool registration, and configure development environment. Use when starting a new WebMCP-enabled website from scratch.
webmcp-security
Implement WebMCP security best practices — permission model, data minimization, honest descriptions, input validation, fingerprinting prevention, and fraud mitigation. Use when auditing or hardening WebMCP tool implementations.
webmcp-register-tool
Implement the WebMCP Imperative API — register tools via navigator.modelContext.registerTool() with proper schemas, execute callbacks, and lifecycle management. Use when building dynamic tool registration in JavaScript.
webmcp-polyfill
Set up and use the MCP-B polyfill — vanilla JS and React packages that implement navigator.modelContext for browsers without native WebMCP. Use when developing for browsers that don't yet support WebMCP natively.
webmcp-mcp-bridge
Integrate WebMCP client-side tools with backend MCP servers and UCP endpoints — bridge browser-based agent interactions with server-to-server protocols. Use when connecting front-end WebMCP to existing backend API infrastructure.
webmcp-commerce-tools
Implement commerce-specific WebMCP tools — product search, cart management, checkout, returns, subscriptions, and support. Use when building agentic shopping experiences on e-commerce websites.
webmcp-authentication
Implement WebMCP authentication patterns — browser session inheritance, cookie-based auth, role-gated tool registration, and conditional tool exposure. Use when managing which tools are available based on user authentication state.
nlweb-llm-providers
Configure NLWeb LLM and embedding providers — OpenAI, Azure OpenAI (default), Anthropic, Google Gemini, DeepSeek on Azure, Llama on Azure, HuggingFace, Inception Labs, Snowflake Cortex, Ollama, Pi Labs. Covers `config_llm.yaml` high/low tier model selection, the ModelRouter cost/quality routing logic, `config_embedding.yaml`, and adding a custom provider. Use when picking models, tuning cost, or wiring a new LLM backend.