import os
import sys
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
SRC = os.path.join(ROOT, "src")
if SRC not in sys.path:
sys.path.insert(0, SRC)
# Provide lightweight stubs for runtime dependencies that aren't available in this test environment.
# This allows importing blender_mcp.server for wrapper/protocol tests without requiring FastMCP.
if "fastmcp" not in sys.modules:
import types
fastmcp = types.ModuleType("fastmcp")
class _DummyResource:
def __init__(self, uri, fn):
self.uri = uri
self._fn = fn
def read(self):
return self._fn()
class _DummyFastMCP:
def __init__(self, *args, **kwargs):
self._resources = {}
pass
def tool(self, fn):
return fn
def prompt(self, fn):
return fn
def resource(self, uri, **kwargs):
# Behave like a decorator factory: @mcp.resource("uri")
def _decorator(fn):
self._resources[uri] = _DummyResource(uri, fn)
return fn
return _decorator
def get_resources(self):
return dict(self._resources)
def get_resource(self, key):
return self._resources[key]
def run(self):
raise RuntimeError("FastMCP stub: run() not available in tests")
class _DummyContext:
pass
fastmcp.FastMCP = _DummyFastMCP
fastmcp.Context = _DummyContext
sys.modules["fastmcp"] = fastmcp
if "mcp" not in sys.modules:
import types
mcp = types.ModuleType("mcp")
mcp_types = types.ModuleType("mcp.types")
class ImageContent(dict):
pass
mcp_types.ImageContent = ImageContent
mcp.types = mcp_types
sys.modules["mcp"] = mcp
sys.modules["mcp.types"] = mcp_types