# Frameworks `McpGtwProvider` has no framework dependency. The same class works in a bare HTML page and inside any framework — you own when to `connect()`, `registerTool()`, and `disconnect()`. ## Vanilla JavaScript Import the module directly in a page, no bundler required: ```html ``` With a bundler, `import { McpGtwProvider } from "mcp-gtw-provider"` works the same way. ## From the browser console Because it is a single dependency-free module, you can `import()` it straight into any open page's DevTools console, register tools that drive the DOM, and connect — turning any site into a provider. The gateway's [browser console guide](https://github.com/mcp-gtw/mcp-gtw/blob/main/docs/browser-console.md) walks through the whole recipe (minting a channel, allowing the origin, the paste-in snippet, and the CSP caveats). ## React Create the provider once, connect on mount, and disconnect on unmount. Register tools in effects so their handlers close over current state: ```jsx import { useEffect, useRef, useState } from "react"; import { McpGtwProvider } from "mcp-gtw-provider"; function useMcpProvider(url) { const providerRef = useRef(null); const [status, setStatus] = useState("disconnected"); if (providerRef.current === null) { providerRef.current = new McpGtwProvider({ url, onStatusChange: setStatus }); } useEffect(() => { const provider = providerRef.current; provider.connect().catch((error) => console.error(error)); return () => provider.disconnect(); }, []); return { provider: providerRef.current, status }; } function Board({ url }) { const { provider, status } = useMcpProvider(url); const [count, setCount] = useState(0); useEffect(() => { const unregister = provider.registerTool( { name: "increment", description: "Add to the counter" }, ({ by = 1 }) => { setCount((value) => value + by); return { count: count + by }; }, ); return unregister; }, [provider, count]); return

Gateway: {status} — count {count}

; } ``` ## Vue ```vue ``` ## Anything else The pattern is always the same: construct with a `url`, register capabilities (`registerTool`, `registerResource`, `registerResourceTemplate`, `registerPrompt`, plus the `onComplete` / `onSubscribe` callbacks), `connect()` when ready, and `disconnect()` to tear down. Handlers are plain functions, so any state management — signals, stores, plain variables — works.