Excessibility.MCP.ClientContext (Excessibility v0.14.0)
View SourceHelpers for getting the MCP client's context (working directory, etc).
The MCP server runs from the excessibility project directory, but tools often need to operate in the client's project directory. This module provides helpers to determine the correct working directory.
The client's working directory is determined in this order:
MCP_CLIENT_CWDenvironment variable (set by the mcp-server wrapper script)- Explicit
cwdparameter passed to the tool (for backward compatibility) - Current working directory (fallback)
Summary
Functions
Builds a path relative to the client's working directory.
Returns command options for System.cmd with the correct working directory.
Gets the client's working directory.
Functions
Builds a path relative to the client's working directory.
Examples
iex> ClientContext.client_path("test/excessibility/timeline.json")
"/home/user/projects/my_app/test/excessibility/timeline.json"
Returns command options for System.cmd with the correct working directory.
Examples
iex> ClientContext.cmd_opts()
[cd: "/home/user/projects/my_app"]
iex> ClientContext.cmd_opts(stderr_to_stdout: true)
[cd: "/home/user/projects/my_app", stderr_to_stdout: true]
Gets the client's working directory.
Options
:cwd- Explicit working directory override (for backward compatibility)
Examples
iex> ClientContext.get_cwd()
"/home/user/projects/my_app"
iex> ClientContext.get_cwd(cwd: "/custom/path")
"/custom/path"