{"record":{"id":"8d95d9c43ddd0fd6","repo":"nicolargo/glances","slug":"the-mcp-package-is-required-for-mcp-support-ins","errorCode":null,"errorMessage":"The 'mcp' package is required for MCP support. Install it with: pip install 'glances[mcp]'","messagePattern":"The 'mcp' package is required for MCP support\\. Install it with: pip install 'glances\\[mcp\\]'","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"glances/outputs/glances_mcp.py","lineNumber":73,"sourceCode":"\n    MCP_DEFAULT_PATH = \"/mcp\"\n\n    def __init__(self, stats, args, config):\n        \"\"\"Initialize the MCP server.\n\n        Args:\n            stats: GlancesStats instance.  May be None at construction time if the\n                   stats manager has not been created yet; call set_stats() before\n                   the server receives its first request.\n            args:  Parsed command-line arguments (argparse.Namespace).\n            config: Glances configuration object (GlancesConfig).\n        \"\"\"\n        self._stats = stats\n        self._args = args\n        self._config = config\n\n        if not MCP_AVAILABLE:\n            raise RuntimeError(\n                \"The 'mcp' package is required for MCP support. Install it with: pip install 'glances[mcp]'\"\n            )\n\n        self._load_config(config)\n\n        self._mcp = FastMCP(\n            \"Glances\",\n            instructions=(\n                \"Glances is a cross-platform system monitoring tool. \"\n                \"Use resources to access real-time system metrics \"\n                \"(CPU, memory, disk, network, processes, containers, sensors, …). \"\n                \"Use prompts to generate structured analyses of the current system state.\"\n            ),\n            transport_security=self._build_transport_security(),\n        )\n\n        self._setup_resources()\n        self._setup_prompts()","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/nicolargo/glances/blob/a240d8dfb3105a38b5964357ec21768594b0e83e/glances/outputs/glances_mcp.py#L55-L91","documentation":"GlancesMcpServer.__init__ raises RuntimeError when the 'mcp' python package could not be imported (MCP_AVAILABLE is False). MCP support is an optional extra, so the constructor hard-fails rather than serving a broken server.","triggerScenarios":"Constructing GlancesMcpServer (directly or via the --mint MCP/REST-MCP output path) in an environment where 'import mcp' failed — typically because glances was installed without the [mcp] extra.","commonSituations":"Running the MCP server mode in a pip install glances environment without extras; slim Docker images; CI environments testing MCP tooling.","solutions":["Install the extra: pip install 'glances[mcp]'.","Verify with python -c 'import mcp' — resolve any ImportError it shows.","For Docker, use an image/requirements that includes the mcp extra."],"exampleFix":"# before\npip install glances\npython -m glances -s --mint\n# RuntimeError: The 'mcp' package is required...\n\n# after\npip install 'glances[mcp]'\npython -m glances -s --mint","handlingStrategy":"validation","validationCode":"try:\n    import mcp  # noqa\n    mcp_ok = True\nexcept ImportError:\n    mcp_ok = False\nif not mcp_ok:\n    raise SystemExit(\"pip install 'glances[mcp]' before enabling MCP\")","typeGuard":null,"tryCatchPattern":"try:\n    from glances.outputs.glances_mcp import GlancesMcpServer\n    server = GlancesMcpServer(stats, args, config)\nexcept (ImportError, RuntimeError):\n    # MCP unavailable: skip MCP serving","preventionTips":["Pin glances[mcp] in requirements for MCP deployments.","Smoke-test 'import mcp' in container entrypoints.","Keep the extra installed across image rebuilds."],"tags":["mcp","missing-dependency","optional-extra"],"backgroundTag":"missing-optional-dependency","analyzedSha":"a240d8dfb3105a38b5964357ec21768594b0e83e","analyzedAt":"2026-08-27T19:15:19.178Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}