Skip to main content
Prompts and resources are MCP-B extension features, not part of the strict WebMCP core. Install @mcp-b/global, then explicitly narrow document.modelContext before using them. For background on this distinction, see Strict core vs MCP-B extensions.

Initialize the runtime

Install packages
main.ts

Register a prompt

A prompt is a reusable message template that AI clients can discover and invoke with arguments.
1

Register the prompt

main.ts
2

Unregister when done

main.ts

React

Use the useWebMCPPrompt hook from @mcp-b/react-webmcp. It handles registration and cleanup on unmount.
CodeReviewPrompt.tsx

Register a resource

A resource exposes readable data (configuration, documents, state) to AI clients.
1

Register the resource

main.ts
2

Unregister when done

main.ts

React

Use the useWebMCPResource hook from @mcp-b/react-webmcp.
AppSettingsResource.tsx