nemo_gym.base_resources_server
nemo_gym.base_resources_server
Module Contents
Classes
Functions
Data
NEMO_GYM_MCP_SESSION_TOKEN_HEADER
API
Bases: BaseServer
Bases: BaseRunServerInstanceConfig
Bases: BaseModel
Bases: BaseModel
Bases: BaseModel
Bases: BaseRunRequest
Bases: BaseVerifyRequest
Bases: SimpleResourcesServer
SimpleResourcesServer variant that also exposes Gym-owned MCP tools.
Subclasses decorate tool methods with @gym_tool (the default register_mcp_tools
auto-registers them; override only for manual control) and call build_mcp_session_metadata
from seed_session to hand the agent a per-rollout token. A @gym_tool method receives the
Gym session by declaring a session_id parameter, which the base resolves from that token (a
stateless signed value) so tool calls share the session id used by /seed_session and /verify.
Register one bound @gym_tool method as an MCP tool.
Builds a wrapper whose signature mirrors the method’s parameters minus session_id (so the
session id stays out of the model-visible input schema) and injects the resolved Gym session id
at call time. Enforces the @gym_tool constraints.
Auto-register methods decorated with @gym_tool as MCP tools.
Subclasses can either rely on this default (just decorate tool methods with @gym_tool) or
override it for full manual control. To add manual @mcp.tool() functions on top of the
auto-registered ones, call super().register_mcp_tools(mcp) first.
Bases: BaseModel
Metadata returned from /seed_session for per-rollout Gym MCP access.
Bases: Exception
A Gym MCP tool call lacked a valid per-rollout session token.
Deliberately not an HTTP error: MCP runs over JSON-RPC, so FastMCP returns HTTP 200 and surfaces
this to the client as a tool error (isError: true). An HTTP status code raised here would
never reach the caller, so we raise a plain error with a clear message instead.
Bases: BaseResourcesServer, AggregateMetricsMixin, SimpleServer
Compute aggregate metrics from verify responses.
RewardProfiler provides baseline stats. Override compute_metrics() and/or get_key_metrics() for benchmark-specific customization.
Mark a resources-server method as a tool to auto-expose over MCP.
The method is registered as an MCP tool named after the method, and its MCP input schema is
derived from the method’s typed parameters. Declare a session_id: str parameter to receive
the per-rollout Gym session id; it is injected automatically (from the hidden session token) and
hidden from the tool’s input schema. The method must NOT take a request parameter — there is
no FastAPI Request on the MCP path; use session_id instead. Both sync and async methods
are supported.