MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / save_contract

Method save_contract

src/tool/context.py:1015–1031  ·  view source on GitHub ↗

Save the contract for a tool

(self, tool_names: Optional[List[str]] = None)

Source from the content-addressed store, hash-verified

1013 return restored_config
1014
1015 async def save_contract(self, tool_names: Optional[List[str]] = None):
1016 """Save the contract for a tool"""
1017 contract = []
1018 if tool_names is not None:
1019 for index, tool_name in enumerate(tool_names):
1020 tool_info = await self.get_info(tool_name)
1021 text = tool_info.text
1022 contract.append(f"{index + 1:04d}\n{text}\n")
1023 else:
1024 for index, tool_name in enumerate(self._tool_configs.keys()):
1025 tool_info = await self.get_info(tool_name)
1026 text = tool_info.text
1027 contract.append(f"{index + 1:04d}\n{text}\n")
1028 contract_text = "---\n".join(contract)
1029 with open(self.contract_path, "w", encoding="utf-8") as f:
1030 f.write(contract_text)
1031 logger.info(f"| 📝 Saved {len(contract)} tools contract to {self.contract_path}")
1032
1033 async def load_contract(self) -> str:
1034 """Load the contract for a tool"""

Callers 5

initializeMethod · 0.95
registerMethod · 0.95
updateMethod · 0.95
copyMethod · 0.95
unregisterMethod · 0.95

Calls 6

get_infoMethod · 0.95
joinMethod · 0.80
appendMethod · 0.45
keysMethod · 0.45
writeMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected