import sys
from pathlib import Path
import types
# Add src to path the same way conftest.py does
src_path = Path(__file__).parent / "src"
sys.path.insert(0, str(src_path.parent))
# Create blender_mcp module namespace pointing to src/
blender_mcp = types.ModuleType("blender_mcp")
blender_mcp.__file__ = str(src_path / "__init__.py")
blender_mcp.__path__ = [str(src_path)]
blender_mcp.__package__ = "blender_mcp"
sys.modules["blender_mcp"] = blender_mcp
# Load src/__init__.py into blender_mcp module
with open(src_path / "__init__.py") as f:
exec(f.read(), blender_mcp.__dict__)
try:
from blender_mcp.server import mcp
print("Successfully imported mcp")
print(f"MCP type: {type(mcp)}")
print(f"MCP attributes: {[a for a in dir(mcp) if not a.startswith('_')]}")
# Check different possible attribute names
for attr in ['_tools', 'tools', '_tool_registry', 'list_tools', '_resources', '_prompts']:
if hasattr(mcp, attr):
val = getattr(mcp, attr)
print(f"\nFound attribute '{attr}': {type(val)}")
if callable(val):
print(f" (callable)")
elif isinstance(val, dict):
print(f" Keys ({len(val)}): {list(val.keys())[:10]}")
# Use the public API
tools_result = mcp.list_tools()
print(f"\nRegistered Tools ({len(tools_result.tools) if hasattr(tools_result, 'tools') else 0}):")
if hasattr(tools_result, 'tools'):
for tool in tools_result.tools:
print(f" - {tool.name}")
resources_result = mcp.list_resources()
print(f"\nRegistered Resources ({len(resources_result.resources) if hasattr(resources_result, 'resources') else 0}):")
if hasattr(resources_result, 'resources'):
for resource in resources_result.resources:
print(f" - {resource.name}")
prompts_result = mcp.list_prompts()
print(f"\nRegistered Prompts ({len(prompts_result.prompts) if hasattr(prompts_result, 'prompts') else 0}):")
if hasattr(prompts_result, 'prompts'):
for prompt in prompts_result.prompts:
print(f" - {prompt.name}")
except Exception as e:
print(f"Error importing or checking mcp: {e}")
import traceback
traceback.print_exc()