Repository navigation
Description
Context
handle_mcp in src/ether/cli/commands/mcp.py:67-75 calls create_mcp_server(...) without passing data_dir=context.data_dir.
In src/ether/mcp/server.py:79,675,682,859, create_mcp_server defaults data_dir: Optional[str] = None and passes that parameter directly to read_action_log and ForensicLogManager.verify_session_audit without reading settings.paths.data_dir. When a user runs ether --data-dir <dir> mcp or sets ETHER_DATA_DIR=<dir>, those MCP tools inspect ~/.ether/logs instead of <dir>/logs.
Proof
Invoked handle_mcp with --data-dir set to a temporary directory against origin/dev@db5fc07:
PYTHONPATH=/tmp/ether-audit-A/src /home/harsh/Documents/ether/.venv/bin/python3 -c "
import asyncio, tempfile, types
from pathlib import Path
from unittest.mock import patch
from ether.cli.context import CliContext
from ether.cli.commands.mcp import handle_mcp
async def main():
with tempfile.TemporaryDirectory() as td:
p = Path(td)
data_dir = p / 'custom_data'
(data_dir / 'logs').mkdir(parents=True)
args = types.SimpleNamespace(
data_dir=str(data_dir), db=str(p / 'db.sqlite'), tools=None,
config=None, policy='safe', verbose=False, json=True,
transport='stdio', host='127.0.0.1', port=8080,
session_id=None, auth_token=None,
)
ctx = CliContext.from_args(args)
captured = {}
class FakeServer:
async def run_stdio_async(self): pass
def fake_create(**kwargs):
captured.update(kwargs)
return FakeServer()
with patch('ether.cli.commands.mcp.create_mcp_server', side_effect=fake_create):
await handle_mcp(args, ctx)
print('context.data_dir:', ctx.data_dir)
print('passed data_dir kwarg:', captured.get('data_dir', '<OMITTED>'))
asyncio.run(main())
"
# context.data_dir: /tmp/tmp.../custom_data
# passed data_dir kwarg: <OMITTED>Impact
Affects all ether mcp users who isolate state via --data-dir or ETHER_DATA_DIR, including the default GatePolicy.SAFE configuration: read_action_log and verify_session_audit fail to find logs in the configured workspace and read ~/.ether/logs instead.
Acceptance criteria
- Pass
data_dir=context.data_dirinsrc/ether/cli/commands/mcp.py:67 - Add a unit test verifying
handle_mcpforwardscontext.data_dirtocreate_mcp_server
Out of scope
Changing ForensicLogManager log directory layout.
Part of #24
audit:self · run 2026-12-03 · ref origin/dev@db5fc07 · cell interface×supply
Activity