Public API¶
What you'll learn here: the small set of Python modules that most users and integrators should treat as the adapter's public code surface.
What belongs here¶
These modules are the ones most likely to matter if you are:
- running the adapter from Python
- loading and validating config programmatically
- trying to understand the top-level contract without digging through storage and proxy internals
This is not a formal long-term compatibility promise, but it is the clearest public-facing surface in the current codebase.
remote_mcp_adapter.server¶
This is the main Python entry point for building the FastAPI application.
FastAPI app factory with multi-server FastMCP proxy mounts.
create_app ¶
create_app(config=None, config_path=None)
Create the adapter FastAPI app with one MCP proxy mount per server config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | AdapterConfig | None | Pre-built config object, used as-is when provided. | None |
config_path | str | None | Filesystem path to a YAML config file (used when config is None). | None |
Returns:
| Type | Description |
|---|---|
FastAPI | Fully-configured |
Source code in src/remote_mcp_adapter/server.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
remote_mcp_adapter.config.load¶
This module loads YAML config, expands environment placeholders, and returns a validated AdapterConfig.
YAML config loader with environment interpolation support.
load_config ¶
load_config(path)
Load YAML config and resolve ${ENV_VAR} placeholders.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path | str | Path | Filesystem path to the YAML configuration file. | required |
Returns:
| Type | Description |
|---|---|
AdapterConfig | Validated |
Raises:
| Type | Description |
|---|---|
ValueError | If a required environment variable is unset. |
FileNotFoundError | If the config file does not exist. |
Source code in src/remote_mcp_adapter/config/load.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
remote_mcp_adapter.config.schemas.root¶
This is the top-level config schema. If you want to understand what the fully validated config object looks like in Python, start here.
Top-level adapter config schema and helpers.
AdapterConfig ¶
Bases: BaseModel
Top-level adapter configuration.Source code in
src/remote_mcp_adapter/config/schemas/root.py18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
class AdapterConfig(BaseModel):
"""Top-level adapter configuration."""
model_config = ConfigDict(extra="forbid")
core: CoreConfig = Field(default_factory=CoreConfig)
state_persistence: StatePersistenceConfig = Field(default_factory=StatePersistenceConfig)
storage: StorageConfig = Field(default_factory=StorageConfig)
sessions: SessionsConfig = Field(default_factory=SessionsConfig)
uploads: UploadsConfig = Field(default_factory=UploadsConfig)
artifacts: ArtifactsConfig = Field(default_factory=ArtifactsConfig)
telemetry: TelemetryConfig = Field(default_factory=TelemetryConfig)
servers: list[ServerConfig] = Field(min_length=1)
@model_validator(mode="after")
def validate_state_persistence(self) -> "AdapterConfig":
"""Validate persistence/storage cross-field constraints.
Returns:
The validated config instance.
Raises:
ValueError: When Redis host is missing or lock mode conflicts.
"""
if self.state_persistence.type == "redis" and not self.state_persistence.redis.host:
raise ValueError("state_persistence.redis.host is required when state_persistence.type='redis'")
if self.storage.lock_mode == "redis" and self.state_persistence.type != "redis":
raise ValueError("storage.lock_mode='redis' requires state_persistence.type='redis'")
if self.state_persistence.disk.local_path is None:
default_path = Path(self.storage.root) / "state" / "adapter_state.sqlite3"
self.state_persistence.disk.local_path = str(default_path)
return self
@model_validator(mode="after")
def validate_unique_servers(self) -> "AdapterConfig":
"""Ensure all server IDs and mount paths are unique.
Returns:
The validated config instance.
Raises:
ValueError: On duplicate server IDs, mount paths, or invalid
legacy server ID references.
"""
ids: set[str] = set()
mounts: set[str] = set()
for server in self.servers:
if server.id in ids:
raise ValueError(f"Duplicate servers[].id: {server.id}")
ids.add(server.id)
if server.mount_path in mounts:
raise ValueError(f"Duplicate servers[].mount_path: {server.mount_path}")
mounts.add(server.mount_path)
legacy_server_id = self.state_persistence.reconciliation.legacy_server_id
if legacy_server_id is not None and legacy_server_id not in ids:
raise ValueError("state_persistence.reconciliation.legacy_server_id must match one configured servers[].id")
return self
validate_state_persistence ¶
validate_state_persistence()
Validate persistence/storage cross-field constraints.
Returns:
| Type | Description |
|---|---|
'AdapterConfig' | The validated config instance. |
Raises:
| Type | Description |
|---|---|
ValueError | When Redis host is missing or lock mode conflicts. |
Source code in src/remote_mcp_adapter/config/schemas/root.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
validate_unique_servers ¶
validate_unique_servers()
Ensure all server IDs and mount paths are unique.
Returns:
| Type | Description |
|---|---|
'AdapterConfig' | The validated config instance. |
Raises:
| Type | Description |
|---|---|
ValueError | On duplicate server IDs, mount paths, or invalid legacy server ID references. |
Source code in src/remote_mcp_adapter/config/schemas/root.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
config_to_dict ¶
config_to_dict(config)
Return a plain dict representation for debugging/logging.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | AdapterConfig | Top-level adapter configuration. | required |
Returns:
| Type | Description |
|---|---|
dict[str, Any] | Dict-serialized copy of the config. |
Source code in src/remote_mcp_adapter/config/schemas/root.py
105 106 107 108 109 110 111 112 113 114 | |
resolve_storage_lock_mode ¶
resolve_storage_lock_mode(config)
Resolve runtime lock mode, including auto behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | AdapterConfig | Top-level adapter configuration. | required |
Returns:
| Type | Description |
|---|---|
EffectiveStorageLockMode | Effective storage lock mode string. |
Source code in src/remote_mcp_adapter/config/schemas/root.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
resolve_write_policy_lock_mode ¶
resolve_write_policy_lock_mode(config)
Resolve lock mode for current local write-policy implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config | AdapterConfig | Top-level adapter configuration. | required |
Returns:
| Type | Description |
|---|---|
WritePolicyLockMode | Write policy lock mode string. |
Source code in src/remote_mcp_adapter/config/schemas/root.py
93 94 95 96 97 98 99 100 101 102 | |
Next steps¶
- Previous topic: API Reference - how this section is split and how to read it.
- Next: Internal API - implementation-oriented modules for contributors.