diff --git a/clikernel/base.py b/clikernel/base.py index 0d92df7..fab4a90 100644 --- a/clikernel/base.py +++ b/clikernel/base.py @@ -223,7 +223,8 @@ def _shutdown(signum, frame): async def _serve(w, name, docs, instructions=None, eager=False): - from mcp.server.fastmcp import FastMCP + try: from mcp.server.mcpserver import MCPServer as FastMCP # mcp>=2 renamed FastMCP + except ImportError: from mcp.server.fastmcp import FastMCP # mcp 1.x # When `eager`, start the worker before building the server so its banner (including startup output) is # forwarded as the `instructions` field -- read once, at initialize; a later restart won't refresh what the # client sees. Otherwise the worker stays unlaunched until first use and `instructions` is the static text. diff --git a/pyproject.toml b/pyproject.toml index 68b7199..e4a0b2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ dependencies = [ "ipython>=9.15.0", "execnb>=0.2.9", "fastcore", - "mcp", + "mcp>=1.2", ] [project.optional-dependencies]