useEnabledTools
Returns the catalog tool ids registered with WebMCP right now, sorted: the tools that are available and whose match fits this page, plus any a component enabled.
Returns the catalog tool ids registered with WebMCP right now, sorted: the tools that are available and whose match fits this page, plus any a component enabled. Use it to show which tools the agent can see on the current page.
Import
import { useEnabledTools } from "@webmcp-agents/react";
Example
A badge that lists the tools on the current page. It re-renders when the set changes, for example after a navigation.
import { useEnabledTools } from "@webmcp-agents/react";
// Which catalog tools can an agent see on this page right now?
export function ToolBadge() {
const ids = useEnabledTools();
return (
<p>
{ids.length > 0
? `Agent tools: ${ids.join(", ")}`
: "No agent tools on this page."}
</p>
);
}
Options
None. The hook takes no arguments.
Returns
readonly string[]: the provider registry’s enabled() snapshot. It is the same array until the set changes, and the component re-renders only when it does. During server rendering it is [].
Notes
- Needs a
<WebAgentsProvider>: it throws outside one. - Only catalog tools (the provider’s
tools) are listed. Tools registered withuseWebTool, declarative<form toolname>tools (the earlier form) and anything else ondocument.modelContextare not. - An id counts as registered once the registry has registered it, and stays listed until its deferred release runs. After a route change a tool can stay in the list for a macrotask, or longer while one of its calls is in flight.
- Without WebMCP on the page, the registry still records the (no-op) registrations, so ids can be listed even though the agent sees nothing. Check
supportedfromuseWebToolorisWebMCPAvailableif that matters.
See also
- Tools across your app, the page that teaches
matchandavailableTools WebAgentsProvideruseEnableTools/EnableToolscreateToolRegistry