MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / FileConnectionsStorage

Class FileConnectionsStorage

uncommon_route/connections_store.py:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56
57
58class FileConnectionsStorage(ConnectionsStorage):
59 def __init__(self, path: Path | None = None) -> None:
60 self._path = path or (_DATA_DIR / "connections.json")
61
62 def load(self) -> dict[str, Any]:
63 try:
64 if self._path.exists():
65 data = json.loads(self._path.read_text())
66 if isinstance(data, dict):
67 return data
68 except Exception:
69 pass
70 return {}
71
72 def save(self, data: dict[str, Any]) -> None:
73 try:
74 self._path.parent.mkdir(parents=True, exist_ok=True, mode=0o700)
75 self._path.write_text(json.dumps(data, indent=2, sort_keys=True))
76 self._path.chmod(0o600)
77 except Exception:
78 pass
79
80
81class InMemoryConnectionsStorage(ConnectionsStorage):

Callers 2

__init__Method · 0.85

Calls

no outgoing calls

Tested by 1