Skip to content

M1: Pass context.data_dir to create_mcp_server in handle_mcp #83

Backlog

Description

@h45sh

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_dir in src/ether/cli/commands/mcp.py:67
  • Add a unit test verifying handle_mcp forwards context.data_dir to create_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

  1. added this to the M1 Truth milestone on Dec 1, 2026
  2. added
    type:bug
    area:hygiene
    priority:P2
    on Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:hygienepriority:P2type:bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions