server_checks
Reusable helpers for server-oriented tests.
These functions bundle the common assertions and MCP inspection logic used by integration and end-to-end tests. They are intentionally path-based and free of pytest fixture assumptions so downstream extension packages can call them from their own tests or helper layers.
collect_server_tools(active_servers, expected_tools)
async
Collect tools exposed by each active server and optionally assert on them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
active_servers
|
dict[str, Any]
|
Active server objects keyed by server name. |
required |
expected_tools
|
dict[str, set[str]]
|
Optional expected tool-name sets keyed by server name. When a server name is present, the discovered tool set must match exactly. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Any]]
|
dict[str, dict[str, Any]]: Per-server connection information and the set |
dict[str, dict[str, Any]]
|
of discovered tool names. |
Source code in mada_tools/testing/server_checks.py
get_server_env_vars(config_path, server_key)
Return the environment-variable mapping for one configured server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to the server configuration JSON file. |
required |
server_key
|
str
|
Key identifying the server entry inside the |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Environment-variable mapping for the requested server, |
dict[str, Any]
|
or an empty dictionary when the server has no |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in mada_tools/testing/server_checks.py
load_server_config(config_path)
Load and parse a server configuration JSON file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_path
|
Path
|
Path to a JSON file containing a top-level |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Parsed configuration dictionary. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the configuration file does not exist. |
Source code in mada_tools/testing/server_checks.py
validate_server_state(expected_servers, active_servers)
Validate that active servers match the expected server configuration.
The checks cover presence, host, port, running status, and configured environment variables. The function raises assertion failures directly so it reads naturally inside tests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected_servers
|
dict[str, Any]
|
Expected server definitions from the config file. |
required |
active_servers
|
dict[str, Any]
|
Actual server objects returned by the server-state manager, keyed by server name. |
required |