suhail commited on
Commit
8294216
·
1 Parent(s): 3e97a63
Files changed (1) hide show
  1. src/mcp/__init__.py +17 -3
src/mcp/__init__.py CHANGED
@@ -20,13 +20,27 @@ logger = logging.getLogger(__name__)
20
 
21
 
22
  def load_tool_contract(tool_name: str) -> dict:
23
- project_root = Path("/app") # matches Docker WORKDIR
24
- contract_path = project_root / "specs" / "001-openai-agent-mcp-tools" / "contracts" / f"{tool_name}.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
  if not contract_path.exists():
27
  raise FileNotFoundError(f"Contract file not found: {contract_path}")
28
 
29
- with open(contract_path, "r") as f:
30
  return json.load(f)
31
 
32
 
 
20
 
21
 
22
  def load_tool_contract(tool_name: str) -> dict:
23
+ """
24
+ Load MCP tool contract in a deployment-safe way
25
+ (works on Windows, Docker, Linux, cloud)
26
+ """
27
+
28
+ # Always resolve from project root (/app in Docker)
29
+ project_root = Path(__file__).resolve().parents[2]
30
+ # parents[2] -> /app/src/mcp/__init__.py → /app
31
+
32
+ contract_path = (
33
+ project_root
34
+ / "specs"
35
+ / "001-openai-agent-mcp-tools"
36
+ / "contracts"
37
+ / f"{tool_name}.json"
38
+ )
39
 
40
  if not contract_path.exists():
41
  raise FileNotFoundError(f"Contract file not found: {contract_path}")
42
 
43
+ with contract_path.open("r", encoding="utf-8") as f:
44
  return json.load(f)
45
 
46