What it is
mcp-gtw is a generic, installable Model Context Protocol gateway. It publishes a real MCP endpoint over Streamable HTTP, but it never decides in advance what that endpoint can do. A connected provider — a browser app or any WebSocket client — registers its own tools, resources and prompts at runtime, and the gateway relays every call to it and streams the result back.
That inversion is the whole point: the capabilities live where your product already runs, so a web app can expose its own actions to any MCP client without shipping a separate server. You build a real application by subclassing the gateway, never by editing the package.
How it works
Two transports meet in the middle. MCP clients speak the standard
Streamable HTTP protocol at /mcp.
Providers open a private WebSocket at
/provider and publish their capabilities over a small, versioned relay protocol.
Each session is a channel holding two independent tokens — one for the client, one for the provider — so neither side can act as the other. When a client calls a tool, the gateway validates the input against that channel's schema, forwards the request to the provider, applies a timeout, and streams the result back. The provider can even call back into the client for sampling and elicitation.