New in reflex-enterprise v0.9.4.
Extending the MCP Server
Beyond the built-in tools and reflex:// resources, you can register your own
tools, resources, and prompts on the underlying
server. There are two ways in, and
both hand you the same instance.
At build time — configure=
Pass MCPPlugin(configure=...) a callable (or a "module.function" import
path). It is invoked as configure(server) once the built-in tools and
resources are registered and before the server is mounted, so whatever you
add is serving from the first request:
A tool or resource that declares a Context-typed parameter has it injected by
FastMCP, giving you the active request and session — the same mechanism the
built-in tools use to resolve the caller's session from their bearer token.
At runtime — get_mcp_server()
To register from application code instead, grab the active server with
rxe.get_mcp_server(). The server is built when the app is compiled, so
this has to run after that — a
lifespan task is the natural home,
since it starts once the backend comes up:
If you register tools after the transport is already serving, connected clients
pick them up on their next tools/list.
Related
- Auto MCP: the built-in tools and resources your additions sit alongside.
- Custom MCP resources: the simpler path when all you want is a read-only view of session state.