Skip to content

Commit f820214

Browse files
committed
ifcmcp: fail early with clear message when mcp package is not installed
mcp is an optional dependency so that the embedded API (embedded.py) can be used from Pyodide without pulling in pydantic-core and the rest of the MCP protocol stack, which may not be available in all WASM environments.
1 parent dae913e commit f820214

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/ifcmcp/ifcmcp/__main__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ def main():
2727

2828
args = parser.parse_args()
2929

30+
try:
31+
from mcp.server.fastmcp import FastMCP # noqa: F401
32+
except ImportError:
33+
import sys
34+
print(
35+
"error: the 'mcp' package is required to run the server.\n"
36+
"Install it with: pip install mcp",
37+
file=sys.stderr,
38+
)
39+
sys.exit(1)
40+
3041
from ifcmcp.server import build_server
3142

3243
server = build_server()

0 commit comments

Comments
 (0)