> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes. # MCPService, MCPClient & MCPManager > Spawn, communicate with, and manage MCP server processes. [mcpclient-reference]: /docs/server-sdks/reference/python/agents/mcp-gateway/mcp-client [createclient]: /docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/create-client [getservicetools]: /docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/get-service-tools [validateservices]: /docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/validate-services [shutdown]: /docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/shutdown These classes handle the low-level lifecycle of MCP server processes: defining service configurations, spawning sandboxed subprocesses, communicating over JSON-RPC, and managing multiple services. ```python from signalwire.mcp_gateway import MCPService, MCPClient, MCPManager ``` --- ## MCPService A dataclass that holds the configuration for a single MCP service. Loaded automatically from the gateway configuration file by [`MCPManager`](#mcpmanager). ### Properties **`name`** `str` Unique name identifying this MCP service. --- **`command`** `list[str]` The command and arguments used to spawn the MCP server process (e.g., `["python3", "my_server.py"]`). --- **`description`** `str` Human-readable description of what this service provides. --- **`enabled`** `bool` — default: True Whether this service is enabled. Disabled services are skipped during loading. --- **`sandbox_config`** `dict[str, Any]` Sandbox configuration controlling process isolation. Defaults to: ```python {"enabled": True, "resource_limits": True, "restricted_env": True} ``` --- **`sandbox_config.enabled`** `bool` — default: True Enable process sandboxing. When `False`, the MCP server runs with full environment access. --- **`sandbox_config.resource_limits`** `bool` — default: True Apply CPU, memory, process count, and file size limits to the spawned process. --- **`sandbox_config.restricted_env`** `bool` — default: True Run with a minimal environment (PATH, HOME, TMPDIR only). When `False`, the full parent environment is inherited. --- **`sandbox_config.drop_privileges`** `bool` — default: False Drop to the `nobody` user when running as root. --- **`sandbox_config.working_dir`** `str` Working directory for the spawned process. Defaults to the current directory. --- --- ## MCPManager Manages multiple MCP services and their client lifecycles. Loads service definitions from the gateway configuration, creates clients on demand, and handles bulk shutdown. ### Properties **`services`** `dict[str, MCPService]` Dictionary mapping service names to their [`MCPService`](#mcpservice) definitions. --- ## **Methods** #### [create\_client](/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/create-client) Create and start a new MCP client for a service. #### [get\_service\_tools](/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/get-service-tools) Discover a service's available tools. #### [validate\_services](/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/validate-services) Validate that all configured services can start. #### [shutdown](/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/shutdown) Stop all active MCP clients. > **Info** > > For the MCPClient class (created by `create_client()`), see the > [MCPClient reference][mcpclient-reference]. > Spawn, communicate with, and manage MCP server processes. ## Docs - [create_client](https://signalwire.com/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/create-client.md): Create and start a new MCP client for a service. - [get_service_tools](https://signalwire.com/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/get-service-tools.md): Discover a service's available tools without maintaining a persistent session. - [shutdown](https://signalwire.com/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/shutdown.md): Stop all active MCP clients. - [validate_services](https://signalwire.com/docs/server-sdks/reference/python/agents/mcp-gateway/mcp-manager/validate-services.md): Validate that all configured services can be started successfully.