Coverage for mcpgateway / plugins / framework / external / unix / server / runtime.py: 100%
22 statements
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-11 07:10 +0000
« prev ^ index » next coverage.py v7.13.1, created at 2026-02-11 07:10 +0000
1# -*- coding: utf-8 -*-
2"""Location: ./mcpgateway/plugins/framework/external/unix/server/runtime.py
3Copyright 2025
4SPDX-License-Identifier: Apache-2.0
5Authors: Teryl Taylor
7Entry point for running the Unix socket plugin server.
9Usage:
10 python -m mcpgateway.plugins.framework.external.unix.server.runtime
12Environment variables:
13 PLUGINS_CONFIG_PATH: Path to plugin configuration file
14 UNIX_SOCKET_PATH: Path for Unix socket (default: /tmp/mcpgateway-plugins.sock)
16Examples:
17 Run with default settings:
19 $ PLUGINS_CONFIG_PATH=plugins/config.yaml python -m mcpgateway.plugins.framework.external.unix.server.runtime
21 Run with custom socket path:
23 $ UNIX_SOCKET_PATH=/tmp/my-plugins.sock python -m mcpgateway.plugins.framework.external.unix.server.runtime
24"""
26# Standard
27import asyncio
28import logging
29import os
30import sys
32# First-Party
33from mcpgateway.plugins.framework.external.unix.server.server import run_server
35# Configure logging
36logging.basicConfig(
37 level=logging.INFO,
38 format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
39 stream=sys.stderr, # Log to stderr to keep stdout clean for coordination
40)
42logger = logging.getLogger(__name__)
45async def run() -> None:
46 """Main entry point for the Unix socket server."""
47 config_path = os.environ.get(
48 "PLUGINS_CONFIG_PATH",
49 os.path.join(".", "resources", "plugins", "config.yaml"),
50 )
51 socket_path = os.environ.get(
52 "UNIX_SOCKET_PATH",
53 "/tmp/mcpgateway-plugins.sock", # nosec B108 - configurable via env var
54 )
56 logger.info("Starting Unix socket plugin server")
57 logger.info(" Config: %s", config_path)
58 logger.info(" Socket: %s", socket_path)
60 await run_server(config_path=config_path, socket_path=socket_path)
63def main() -> None:
64 """CLI entry point."""
65 try:
66 asyncio.run(run())
67 except KeyboardInterrupt:
68 logger.info("Server interrupted")
69 except Exception as e:
70 logger.exception("Server error: %s", e)
71 sys.exit(1)
74if __name__ == "__main__":
75 main()