|
|
import sys |
|
|
import os |
|
|
import logging |
|
|
|
|
|
|
|
|
project_root = os.path.join(os.path.dirname(__file__), "../../../") |
|
|
sys.path.insert(0, project_root) |
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) |
|
|
|
|
|
from shared_mcp.app import app |
|
|
from shared_mcp.registry import registry |
|
|
from shared_mcp.models import ToolSchema |
|
|
from server.parser import ifc_parser |
|
|
from server.rules_engine import engine |
|
|
from server.rag.standards_index import rag_engine |
|
|
from server import modal_parser |
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
registry.register( |
|
|
ToolSchema( |
|
|
name="parse_ifc", |
|
|
description="Parses an IFC file to extract metrics.", |
|
|
input_schema={ |
|
|
"type": "object", |
|
|
"properties": { |
|
|
"file_path": {"type": "string", "description": "Absolute path to the IFC file"} |
|
|
}, |
|
|
"required": ["file_path"] |
|
|
} |
|
|
), |
|
|
ifc_parser.parse_model |
|
|
) |
|
|
|
|
|
|
|
|
def evaluate_rules_wrapper(metrics: dict, rules_yaml: str): |
|
|
rules = engine.load_rules(rules_yaml) |
|
|
return engine.evaluate(metrics, rules) |
|
|
|
|
|
registry.register( |
|
|
ToolSchema( |
|
|
name="evaluate_rules", |
|
|
description="Evaluates building metrics against a set of rules.", |
|
|
input_schema={ |
|
|
"type": "object", |
|
|
"properties": { |
|
|
"metrics": {"type": "object", "description": "Metrics dictionary"}, |
|
|
"rules_yaml": {"type": "string", "description": "Rules in YAML format"} |
|
|
}, |
|
|
"required": ["metrics", "rules_yaml"] |
|
|
} |
|
|
), |
|
|
evaluate_rules_wrapper |
|
|
) |
|
|
|
|
|
|
|
|
registry.register( |
|
|
ToolSchema( |
|
|
name="query_standards", |
|
|
description="Queries building standards using RAG.", |
|
|
input_schema={ |
|
|
"type": "object", |
|
|
"properties": { |
|
|
"query": {"type": "string", "description": "Question about standards"} |
|
|
}, |
|
|
"required": ["query"] |
|
|
} |
|
|
), |
|
|
rag_engine.query |
|
|
) |
|
|
|
|
|
|
|
|
registry.register( |
|
|
ToolSchema( |
|
|
name="parse_ifc_cloud", |
|
|
description="Parses an IFC file using Modal cloud compute.", |
|
|
input_schema={ |
|
|
"type": "object", |
|
|
"properties": { |
|
|
"file_path": {"type": "string", "description": "Absolute path to the IFC file"} |
|
|
}, |
|
|
"required": ["file_path"] |
|
|
} |
|
|
), |
|
|
modal_parser.parse_model_remote |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
import uvicorn |
|
|
uvicorn.run(app, host="0.0.0.0", port=8003) |
|
|
|