Skip to content

codio_func_doc cross-env introspection

Problem

codio_func_doc uses in-process importlib.import_module(), so it can only introspect packages installed in the MCP server's conda env (rag). Project dependencies typically live in a different env (cogpy via CONDA_ENV in the Makefile).

Proposed fix

Add an optional env parameter. When set, shell out to the target env:

conda run -n {env} --no-banner python -c "import json, importlib, inspect; ..."

When omitted, use in-process importlib (current behavior — works for packages in the server env).

The conda binary path is available from runtime_conventions (CONDA var).

Tasks

  • [x] Add env: str | None = None param to codio_func_doc in mcp/codio.py
  • [x] When env is given, build a self-contained Python snippet that does the import + inspect and prints JSON to stdout
  • [x] Shell out via subprocess.run([conda, "run", "-n", env, "python", "-c", snippet])
  • [x] Parse stdout JSON, return as JsonDict
  • [x] Register env param in server.py tool wrapper
  • [x] Test with cogpy env