datarobot_genai.drmcp.test_utils.mcp_utils_integration
mcp_utils_integration
integration_test_server_params_with_env
integration_test_server_params_with_env(extra_env: dict[str, str], use_stub: bool = True) -> StdioServerParameters
Return integration test server params with additional environment variables.
Useful for enabling specific tool groups (e.g. {"ENABLE_USE_CASE_TOOLS": "true"}).
Source code in datarobot_genai/drmcp/test_utils/mcp_utils_integration.py
aclose_shared_stdio_sessions
async
Close every shared session bound to the current event loop.
Source code in datarobot_genai/drmcp/test_utils/mcp_utils_integration.py
integration_test_mcp_session
async
integration_test_mcp_session(server_params: StdioServerParameters | None = None, timeout: int = 60, elicitation_callback: Any | None = None, use_stub: bool = True, shared: bool = True) -> AsyncGenerator[ClientSession, None]
Create and connect a client for the MCP server as a context manager.
By default the underlying stdio server subprocess and client session are shared
across tests with the same server configuration (see _SharedStdioSession); exiting
the context manager does not close them. Callers that need session-level isolation
(a custom elicitation_callback, or tests that mutate server state) get a fresh
server: pass shared=False, or any elicitation_callback implies it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_params
|
StdioServerParameters | None
|
Parameters for configuring the server connection |
None
|
timeout
|
int
|
Timeout |
60
|
elicitation_callback
|
Any | None
|
Optional callback for handling elicitation requests |
None
|
shared
|
bool
|
Reuse one server/session per configuration (default). False forces a fresh, test-scoped server subprocess. |
True
|
Yields
ClientSession: Connected MCP client session
Raises
ConnectionError: If session initialization fails
TimeoutError: If session initialization exceeds timeout