The server fails to start when the optional fastmcp dependency is not installed. The MCP feature routes are imported unconditionally in multiple locations without a guard for ModuleNotFoundError, even though fastmcp is marked as an optional dependency in packaging metadata (confirmed on the Arch Linux AUR package, where fastmcp is listed under Optional Deps, not Depends On).
This differs from the handling of the AI Copilot feature in the same codebase, where the missing langchain_core dependency is caught and logged as a warning, allowing the server to continue running with that feature disabled. The MCP feature does not follow the same pattern.
To Reproduce
- Install
gns3-server 3.1.0a3 without the optional fastmcp / mcp package installed.
- Run
gns3server from the terminal.
- Server starts initializing, passes initial config and database migration steps, then crashes during the FastAPI lifespan startup phase.
Expected behavior
The server should start successfully with MCP routes disabled and log a warning, consistent with how the AI Copilot feature degrades gracefully.
Error output
First failure point, at import time in gns3server/api/server.py:
File "/usr/lib/python3.14/site-packages/gns3server/api/server.py", line 48, in <module>
from gns3server.api.routes import mcp
File "/usr/lib/python3.14/site-packages/gns3server/api/routes/mcp/__init__.py", line 42, in <module>
from mcp.server.fastmcp import FastMCP
ModuleNotFoundError: No module named 'mcp'
After patching the import in server.py (wrapping in try/except and guarding the two usages at router registration and Starlette route registration), a second unguarded import surfaces at runtime in gns3server/core/tasks.py, inside the startup() lifespan function:
File "/usr/lib/python3.14/site-packages/gns3server/core/tasks.py", line 88, in startup
from gns3server.api.routes.mcp import set_mcp_server_ready
File "/usr/lib/python3.14/site-packages/gns3server/api/routes/mcp/__init__.py", line 42, in <module>
from mcp.server.fastmcp import FastMCP
ModuleNotFoundError: No module named 'mcp'
Environment
- GNS3 server version: 3.1.0a3
- OS: CachyOS (Arch-based), installed via AUR (with paru) package
gns3-server
- Python: 3.14.6
Workaround
Manually wrapping all four unguarded references to the mcp module (one import and one router registration in server.py, one import and one function call in tasks.py) in try/except ModuleNotFoundError blocks allows the server to start normally with MCP routes disabled. Happy to share the exact patch if useful.
Suggested fix
Apply the same graceful-degradation pattern already used for the AI Copilot dependency check to the MCP feature imports, in both gns3server/api/server.py and gns3server/core/tasks.py.
The server fails to start when the optional
fastmcpdependency is not installed. The MCP feature routes are imported unconditionally in multiple locations without a guard forModuleNotFoundError, even thoughfastmcpis marked as an optional dependency in packaging metadata (confirmed on the Arch Linux AUR package, wherefastmcpis listed under Optional Deps, not Depends On).This differs from the handling of the AI Copilot feature in the same codebase, where the missing
langchain_coredependency is caught and logged as a warning, allowing the server to continue running with that feature disabled. The MCP feature does not follow the same pattern.To Reproduce
gns3-server3.1.0a3 without the optionalfastmcp/mcppackage installed.gns3serverfrom the terminal.Expected behavior
The server should start successfully with MCP routes disabled and log a warning, consistent with how the AI Copilot feature degrades gracefully.
Error output
First failure point, at import time in
gns3server/api/server.py:After patching the import in
server.py(wrapping in try/except and guarding the two usages at router registration and Starlette route registration), a second unguarded import surfaces at runtime ingns3server/core/tasks.py, inside thestartup()lifespan function:Environment
gns3-serverWorkaround
Manually wrapping all four unguarded references to the
mcpmodule (one import and one router registration inserver.py, one import and one function call intasks.py) in try/exceptModuleNotFoundErrorblocks allows the server to start normally with MCP routes disabled. Happy to share the exact patch if useful.Suggested fix
Apply the same graceful-degradation pattern already used for the AI Copilot dependency check to the MCP feature imports, in both
gns3server/api/server.pyandgns3server/core/tasks.py.