Helps implement WebMCP (proposed W3C standard) in CrestApps.Core 2.0, exposing AI tools to browser agents via document.modelContext. Covers registration, page tools, AI chat as WebMCP agent, and troubleshooting.
Ships in crestapps-core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
WebMCP lets a page register tools with document.modelContext.registerTool() (name, description, JSON schema, annotations and a JavaScript execute). An agent lists them with getTools() and runs one with executeTool(). CrestApps uses only that standard API, in two directions:
| Part | What it does |
|---|---|
| Your AI tools as WebMCP tools | webmcp.js registers the AI tools and tool instances you select; calling one posts to your app, which runs it as the signed-in user |
| Page tools | webmcp-page-tools.js registers tools that read the page and what it shows (text, tables, form values), list its links, open another page of the site, and read and fill forms |
| The AI chat as a WebMCP agent | The AI Profile chat discovers and runs every WebMCP tool the tab exposes (yours, your own scripts', third-party scripts', shared frames'), only for profiles that allow it |
WebMcpOptions, render the scripts only for signed-in users, and allow page tools per profile.IWebMcpAccessEvaluator, WebMcpOptions and IAIToolAccessEvaluator on every list and call; the browser list only decides what gets registered.localhost). Load webmcp-polyfill.js first so browsers without native WebMCP get document.modelContext.AllowConsequentialPageTools off unless needed.AIChatHubCore) only, not Chat Interactions.using CrestApps.Core.AI.WebMcp;
using CrestApps.Core.AI.WebMcp.Endpoints;
using CrestApps.Core.AI.WebMcp.Models;
builder.Services.AddCrestAppsCore(crestApps => crestApps
.AddAISuite(ai => ai
.AddOpenAI()
.AddWebMcp(webMcp => webMcp
.AddPageTools<AIChatHub>())));
builder.Services.Configure<WebMcpOptions>(options =>
{
options.Tools = ["calculator"];
});
var app = builder.Build();
app.MapHub<AIChatHub>("/hubs/ai-chat");
app.MapWebMcpTools();
Without the suite builder: services.AddCoreAIWebMcp().AddCoreAIWebMcpPageTools<AIChatHub>();.
AddCoreAIWebMcp() registers WebMcpOptions, antiforgery, IWebMcpToolService and the default IWebMcpAccessEvaluator (all TryAdd).AddCoreAIWebMcpPageTools<THub>() registers WebMcpPageToolOptions, the in-memory IWebMcpPageToolRegistry, IWebMcpPageToolClient (HubWebMcpPageToolClient<THub>) and the page-tool IToolRegistryProvider.MaximumParallelInvocationsPerClient above 1; ConfigureCrestAppsChatHubOptions<THub>() sets 8.CrestApps.Core.AI.WebMcp. The scripts come from the CrestApps.AI.WebMcp.Resources Razor class library (served under _content/CrestApps.AI.WebMcp.Resources/scripts/; it is a project reference, not a NuGet package) or from the @crestapps/webmcp npm package (dist/webmcp.js, webmcp-page-tools.js, webmcp-polyfill.js, plus .min.js builds of the first two).WebMcpOptions | Default | Meaning |
|---|---|---|
ExposeAllTools | false | Every selectable tool and tool instance except Destructive and Security tools and tools that require an approval; system and hidden tools are never given |
Tools | empty | Names given, case-insensitive, also matched by a tool's aliases. With ExposeAllTools on, it only decides which destructive, security and approval tools are given |
A browser agent calls a tool directly and cannot approve a call, so a tool that requires an approval (.RequireApproval(), or .AsExternal() without .RequireApproval(false)) runs without one once Tools names it. Each tool in the endpoint's list has a kind value (read, write, destructive, external or security, WebMcpToolDescriptor.Kind) when its registration sets one. A tool is listed for a user only when IAIToolAccessEvaluator authorizes its name or an alias that carries access. The sample settings page stores an empty Tools list while Give all tools and tool instances is ticked; to give a destructive or security tool, untick it and pick tools by name.
WebMCP adds no tools of its own: the source is the same tool catalog (AddCoreAITool<T>()) and tool instances. DefaultWebMcpAccessEvaluator allows every signed-in user; replace it to require a role or permission:
using System.Security.Claims;
using CrestApps.Core.AI.WebMcp.Services;
public sealed class AdministratorsOnlyWebMcpAccessEvaluator : IWebMcpAccessEvaluator
{
public Task<bool> CanUseAsync(ClaimsPrincipal user, CancellationToken cancellationToken = default)
=> Task.FromResult(user?.IsInRole("Administrator") == true);
}
builder.Services.AddSingleton<IWebMcpAccessEvaluator, AdministratorsOnlyWebMcpAccessEvaluator>();
app.MapWebMcpTools(prefix) maps under WebMcpConstants.DefaultRoutePrefix (api/ai/webmcp) and returns the RouteGroupBuilder, so you can add rate limiting.
| Route | Result | Failures |
|---|---|---|
GET {prefix}/tools | { "tools": [{ "name", "title", "description", "inputSchema" }] } | 401 anonymous, 403 evaluator refused |
POST {prefix}/tools/{name}/invoke | Runs the tool in an AIInvocationScope with the JSON object body; answers { "content": [{ "type": "text", "text" }], "isError" } | 401, 403, 400 for a missing antiforgery header token, a non-object body or a body over 256 KB (WebMcpEndpoints.MaxRequestBodyLength), 404 for any tool not listed for the user |
A tool that throws answers isError: true with a generic message; the exception is only logged.
Render the configuration block and the scripts for signed-in users, before the chat scripts. The block's id is WebMcpConstants.ConfigurationElementId (crestapps-webmcp-config):
@using System.Text.Json
@using CrestApps.Core.AI.WebMcp
@using Microsoft.AspNetCore.Antiforgery
@inject IAntiforgery Antiforgery
@if (User.Identity?.IsAuthenticated == true)
{
var tokens = Antiforgery.GetAndStoreTokens(Context);
var configuration = new Dictionary<string, object>
{
["toolsUrl"] = Url.Content($"~/{WebMcpConstants.DefaultRoutePrefix}/tools"),
["invokeUrlTemplate"] = Url.Content($"~/{WebMcpConstants.DefaultRoutePrefix}/tools/") + "{name}/invoke",
["antiforgeryHeaderName"] = tokens.HeaderName,
["antiforgeryToken"] = tokens.RequestToken,
};
<script type="application/json" id="@WebMcpConstants.ConfigurationElementId">@Html.Raw(JsonSerializer.Serialize(configuration))</script>
<script src="~/_content/CrestApps.AI.WebMcp.Resources/scripts/webmcp-polyfill.js"></script>
<script src="~/_content/CrestApps.AI.WebMcp.Resources/scripts/webmcp.js"></script>
<script src="~/_content/CrestApps.AI.WebMcp.Resources/scripts/webmcp-page-tools.js"></script>
}
| Config key | Meaning |
|---|---|
toolsUrl, invokeUrlTemplate | Where webmcp.js lists and calls your AI tools ({name} is replaced). Omit to register no AI tools |
antiforgeryHeaderName, antiforgeryToken | Sent with every call |
isAdmin | Reported by page_get_info |
pageToolOrigins | Cross-origin frame origins whose shared tools the chat may use (getTools({ fromOrigins })) |
webmcp.js marks each AI tool untrustedContentHint, never sets exposedTo, and rejects execute when the tool fails. It publishes window.crestAppsWebMcp (config, ready promise of registered names, isSupported(), connectChat(connection)) and raises crestapps-webmcp-ready on document. Register your own tools with the plain standard API; the chat finds them like any other. See webmcp-examples.md.
Built-in page tools:
| Tool | Read-only | What it does |
|---|---|---|
page_get_info | Yes | Title, address, description, the first 20 h1/h2 headings, and isAdmin from the config |
page_read_content | Yes | What main (or [role="main"], else the body) shows: text one line per block, cut to 8,000 characters, plus up to 10 tables (caption, headers, first 50 rows, cells cut to 300 characters) marked [table N]. Form fields show their values next to their labels (chosen option, [x]/[ ], values cut to 500 characters); hidden, disabled, password, file and button fields and the antiforgery token show nothing. Menus, scripts, hidden parts, the chat and data-webmcp-ignore elements are skipped; truncated says whether something was cut |
page_list_links | Yes | Up to 200 same-origin links in nav, header, aside, [role="navigation"]; optional filter |
page_navigate | No | Opens a path starting with / or a full same-origin address. It first sends a HEAD request: a bare relative path such as ArticlesAdmin, a 404 or 410, other origins and script addresses are refused with a message telling the agent to call page_list_links (a 405 or a redirect is opened as asked). It answers first and opens the page 400 ms later (navigateDelayMs) |
page_list_form_fields | Yes | Up to 200 fields (name, id, label, type, value cut to 2,000 characters, required, choices); skips hidden, password, file, button and disabled fields and the antiforgery token |
page_set_form_field | No | Sets one listed field by name, id or label, raises input and change, never submits; answers the field as it is now and its previousValue so the agent can undo the change |
ai-chat.js reads getTools() and, when the list changed, calls the hub's SetPageTools(WebMcpPageToolDescriptor[]). It leaves out the AI tools webmcp.js registered, because the server already has those.IWebMcpPageToolRegistry keeps the tools per connection after WebMcpPageToolValidator checks them: at most 64, names matching ^[A-Za-z0-9_.-]{1,128}$, descriptions up to 2,000 characters, object schemas up to 16 KB. ClearPageTools() and a closed connection forget them.AIChatResponseHandler puts the connection id in AICompletionContextKeys.ChatConnectionId.WebMcpPageToolFunction per tool when the session's profile has WebMcpProfileSettings.AllowPageTools. A tool with consequentialHint is offered in an AG-UI run (the chat UI's default, see crestapps-core-ag-ui) as a tool that requires approval, so each call waits for the user's Allow or Deny; with AllowConsequentialPageTools it runs without asking. While that switch is off the tool has an approval floor (ToolRegistryEntry.ApprovalFloor), so no profile approval policy lets it run unasked. Other chat runs offer it only when AllowConsequentialPageTools is on.ExecutePageTool (WebMcpConstants.ExecutePageToolMethod) with SignalR client results and returns { text, isError } (WebMcpPageToolResult) within WebMcpPageToolOptions.ToolCallTimeout (60 s). For a page tool that webmcp-page-tools.js registered in the same window, the tab runs the tool's own execute (found with CrestAppsWebMcpPageTools.getRegisteredTool(modelContext, name)), so the model reads the tool's real failure message (for example a 404 from page_navigate) instead of WebMCP's generic "Tool execution failed". Every other tool (third-party, frames, a tool registered first under a page tool's name) runs through executeTool().In an AG-UI run on the chat hub, page_navigate ends the turn: the turn is saved with ChatTurnToolActivity.ContinuesOnNextPage, and the chat on the opened page continues it with that page's tools (forwardedProps.continueRun), up to five pages in a row. See crestapps-core-ag-ui.
using CrestApps.Core.AI.Models;
profile.AlterSettings<WebMcpProfileSettings>(settings =>
{
settings.AllowPageTools = true;
settings.AllowConsequentialPageTools = false;
});
. in function names, so WebMcpPageToolValidator.ToFunctionName maps characters other than letters, digits, _ and - to _ and hashes names over 64 characters. store.add_to_cart is offered as store_add_to_cart; the tab still runs store.add_to_cart.readOnlyHint is kept (WebMcpPageTool.ReadOnly); untrustedContentHint results are prefixed with WebMcpPageToolFunction.UntrustedContentNotice so the model treats them as data.exposedTo, the page allows it with <iframe allow="tools">, and its origin must be in pageToolOrigins.The MVC host renders the scripts in Views/Shared/_WebMcp.cshtml and the Blazor host in Components/App.razor. Both add a WebMCP card to the settings page (stored with SiteSettingsConfigureStoredOptions<WebMcpOptions>), Allow page tools and Allow consequential page tools to the profile editor, and a WebMCP Playground page (/webmcp/playground): a fake store whose wwwroot/js/webmcp-playground.js registers store.search_products, store.get_order, store.read_reviews (untrusted), store.add_to_cart and store.place_order (consequential) with the standard API only.
AllowPageTools, AddPageTools<THub>() names a different hub than the one mapped, the page loads the chat before webmcp.js, or the chat is a Chat Interaction.protocol: 'legacy', a hub without RunAgent); turn on AllowConsequentialPageTools, or use the default AG-UI chat so the tool waits for approval.page_navigate refuses bare relative paths and pages that answer 404/410; make sure the navigation links are in nav, header, aside or [role="navigation"] so page_list_links finds them.400 on invoke: the antiforgery header is missing or stale; render the config block per request.404 on invoke: the tool is not in WebMcpOptions, is a system or hidden tool, or IAIToolAccessEvaluator denies it for the user.document.modelContext: load webmcp-polyfill.js first and serve over HTTPS.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
webmcp, browser-ai-agents, crestapps, page-tools, model-context
/crestapps-core:crestapps-core-webmcpfrom crestapps-core
npx claudepluginhub crestapps/crestapps.agentskills --plugin crestapps-core51 skills in this plugin
/crestapps-core-a2aSkill for Agent-to-Agent (A2A) protocol support in CrestApps.Core on the A2A 1.0 SDK. Covers AddA2AClient and AddCoreAIA2AClient with Entity Framework Core or YesSql connection stores, A2AConnection and A2AConnectionMetadata authentication, AIProfileA2AMetadata, the agent card cache and A2AToolRegistryProvider, the listAvailableAgents, findAgentForTask and findToolsForTask tools, building an A2A host with IAgentHandler, A2AServer, ITaskStore and MapA2A, A2A 1.0 agent cards with supportedInterfaces published at /.well-known/agent-card.json, A2AHostOptions authentication and ExposeAgentsAsSkill, system agents exposed through the host, and upgrading from the 0.3 SDK./crestapps-core-ag-uiSkill for running the CrestApps.Core 2.0 AI chat as an AG-UI agent. Covers the CrestApps.Core.AI.AGUI package (AGUIRunEventWriter, AGUIRunRequest, AGUIJson), AIChatHubCore.RunAgent over SignalR and MapAGUIChat with Server-Sent Events, the RunAgentInput members and streamed events, tool approvals with RequireApproval or an approval tool kind, ApprovalRequiredAIFunction, interrupts and resume, approvals inside agents, page context with crestAppsAGUI.registerContextProvider, shared state with registerStateProvider and update_shared_state, frontend tools, stored tool calls (ChatTurnToolActivity), runs that continue on the next page, AGUIChatOptions.DisconnectedRunTimeout, the protocol and sendPageContext chat options, and the AICompletionContextKeys and ChatResponseHandlerContext members. Use it when showing tool calls in the chat, asking a person before a tool runs, sharing page state with the agent, connecting CopilotKit or another AG-UI client, or troubleshooting approvals and continued runs./crestapps-core-ai-agentsSkill for AI agents in CrestApps.Core 2.0, specialized AIProfile records of type Agent that the primary model invokes as tools. Covers creating agent profiles with AgentMetadata availability (OnDemand or AlwaysAvailable), linking them with AgentInvocationMetadata, how AgentProxyTool runs an agent with tools disabled or through the orchestrator when AllowToolInvocation is set, the AgentInvocationDepth recursion guard, never offering an agent to itself (RunningAgentName), tools of an agent that require an approval and pause the agent, deployment inheritance and the chat slot, code-defined and system agents through IAIProfileProvider including the Tabular Data, PDF, Presentation and Word agents, chat-specific agents that read AIInvocationScope, exposing agents to MCP clients with McpServerOptions Agents and ExposeAllAgents, and SubAgent usage labels. Use it when delegating work to sub-agents, adding a framework-managed agent, publishing an agent over MCP, or troubleshooting an agent the model does not call./crestapps-core-ai-markdownSkill for Markdig-backed Markdown normalization in CrestApps.Core 2.0 AI document, data source and RAG flows. Covers the CrestApps.Core.AI.Markdown package, AddMarkdown on the AI suite builder and AddCoreAIMarkdown on IServiceCollection, MarkdownAITextNormalizer replacing the default IAITextNormalizer, RagTextNormalizer content, chunk and title normalization with HTML stripping and Microsoft.Extensions.DataIngestion.Markdig parsing, the gpt-4o tokenizer chunker with 500 tokens per chunk and 50 tokens of overlap, the plain-text fallback for unsupported inline types, where the normalizer is used (data source indexing, preemptive retrieval, reference titles), and pairing it with document processing. Use it when indexing Markdown-heavy content for retrieval, replacing the text normalizer, or troubleshooting chunk sizes and leftover markup in retrieved text./crestapps-core-ai-memorySkill for AI memory in CrestApps.Core. Covers AddAIMemory, AddCoreAIMemory and AddCoreAIMemoryIndexing, Entity Framework Core and YesSql memory stores, the AIMemory index profile on the Elasticsearch, Azure AI Search and PostgreSQL backends, AIMemoryOptions, the store fallback when no index is usable, background memory indexing, the three kinds of memory (session memory with AIConversationMemory summaries and search_conversation, past conversations with search_past_conversations and list_recent_conversations, durable user memory) switched by MemoryMetadata and ChatInteractionMemoryOptions, preemptive memory retrieval and RunsWhenPreemptiveRagIsDisabled, owner-only chat sessions, the user memory tools, IAIMemorySafetyService validation, and custom IMemoryVectorSearchService implementations./crestapps-core-ai-model-capabilitiesSkill for metadata-driven deployment capabilities in CrestApps.Core 2.0. Covers trained model features such as textGeneration, toolCalling, streaming, reasoning, realtime, textEmbedding, speechToText and textToSpeech, model parameters such as reasoningEffort, declaring them with AIDeploymentMetadata or the Features and Parameters configuration shorthand for Azure App Service settings, registering custom features, parameters and slots with AddAIDeploymentFeature, AddAIDeploymentParameter, AddAIDeploymentSlot and AIDeploymentCapabilityOptions, IAIDeploymentCapabilityService, deployment slots and their resolution chain, AIDeploymentParametersMetadata chat and utility values, IAIDeploymentParameterBinder, UseModelParameters, capability enforcement, the ChatApi Responses routing for reasoning with tools, capability-aware chat UIs, and migrating from AIDeploymentPurpose. Use it when declaring what a model supports, adding a new knob, or fixing stripped tools, missing pickers, or reasoning-effort errors.Other plugins' skills for the same job