Skip to content

Commit d1fd38a

Browse files
committed
Add default DB path for DuckDB
1 parent 1dfc118 commit d1fd38a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/mcpm/monitor/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ async def get_monitor(db_path: Optional[str] = None) -> AccessMonitor:
1717
Get a configured access monitor instance
1818
1919
Args:
20-
db_path: Optional custom path to the database file. Defaults to ~/.mcpm/monitor.duckdb
20+
db_path: Optional custom path to the database file. If None, uses the default
21+
config directory from ConfigManager.
2122
2223
Returns:
2324
Configured AccessMonitor instance
2425
"""
25-
monitor = DuckDBAccessMonitor(db_path) if db_path else DuckDBAccessMonitor()
26+
monitor = DuckDBAccessMonitor(db_path)
2627
await monitor.initialize_storage()
2728
return monitor
2829

src/mcpm/monitor/duckdb.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import duckdb
1212

1313
from mcpm.monitor.base import AccessEventType, AccessMonitor
14+
from mcpm.utils.config import ConfigManager
1415

1516

1617
class DuckDBAccessMonitor(AccessMonitor):
@@ -19,13 +20,18 @@ class DuckDBAccessMonitor(AccessMonitor):
1920
This uses a thread pool to execute DuckDB operations asynchronously.
2021
"""
2122

22-
def __init__(self, db_path: str = "~/.mcpm/monitor.duckdb"):
23+
def __init__(self, db_path: Optional[str] = None):
2324
"""
2425
Initialize the DuckDBAccessMonitor.
2526
2627
Args:
27-
db_path: Path to the DuckDB database file
28+
db_path: Path to the DuckDB database file. If None, uses the default config directory.
2829
"""
30+
if db_path is None:
31+
# Use ConfigManager to get the base config directory
32+
config_manager = ConfigManager()
33+
db_path = os.path.join(config_manager.config_dir, "monitor.duckdb")
34+
2935
self.db_path = os.path.expanduser(db_path)
3036
self.connection = None
3137
self._initialized = False

0 commit comments

Comments
 (0)