Expand description
Minimal MCP (Model Context Protocol) server over stdio.
Reads line-delimited JSON-RPC 2.0 from stdin and writes responses to stdout. Exposes tools for par-term ACP integrations:
config_update: writes configuration changes to a file for the main app to pick upterminal_screenshot: requests a live terminal screenshot from the app via a file-based IPC handshake (with an optional fallback image path for non-GUI test harnesses)shader_diagnostics: requests live shader state and last compile/reload errors from the running app via file-based IPC
§Module layout
jsonrpc— JSON-RPC 2.0 wire types, response helpers, and stdout framingipc— IPC path resolution, atomic writes, and restricted-permission helperstools— tool registration, descriptors, and dispatchtools::config_update—config_updatetool handlertools::screenshot—terminal_screenshottool handlertools::diagnostics—shader_diagnosticstool handler
§SEC-008: Trust Boundary — stdin/stdout IPC Channel
This MCP server communicates over stdin and stdout using JSON-RPC 2.0.
There is no authentication, encryption, or integrity verification on
this IPC channel. Any process that can write to the MCP server’s stdin can
invoke any tool (including config_update, which writes to the user’s
configuration file on disk).
The stdin/stdout channel is a trust boundary. Only trusted MCP client processes (i.e., ACP agents that par-term itself has spawned) should be connected to this server. The caller is responsible for ensuring that:
- The MCP server process is only spawned by par-term’s ACP subsystem.
- The stdin pipe is not shared with or writable by untrusted processes.
- Agent TOML files (which define which agents are launched) are treated as a trust boundary — only install agents from sources you trust.
The file-based IPC paths used for screenshot and diagnostics requests use restrictive permissions (0o600) to prevent unauthorized reads or writes, but the stdin/stdout channel itself has no such protection.
Re-exports§
pub use ipc::screenshot_request_path;pub use ipc::screenshot_response_path;pub use ipc::shader_diagnostics_request_path;pub use ipc::shader_diagnostics_response_path;
Modules§
- ipc
- IPC file path resolution and file helpers.
- jsonrpc
- JSON-RPC 2.0 wire types and response helpers.
- tools
- Tool registration, descriptors, and dispatch for the MCP server.
Structs§
- Shader
Diagnostics - Live shader diagnostics returned by the GUI app.
- Shader
Diagnostics Entry - Per-shader diagnostics included in
ShaderDiagnosticsResponse. - Shader
Diagnostics Request - Shader diagnostics request written by the MCP server for the GUI app to fulfill.
- Shader
Diagnostics Response - Shader diagnostics response written by the GUI app for the MCP server to read.
- Terminal
Screenshot Request - Screenshot request written by the MCP server for the GUI app to fulfill.
- Terminal
Screenshot Response - Screenshot response written by the GUI app for the MCP server to read.
Constants§
- CONFIG_
UPDATE_ FILENAME - Default config update filename (relative to config dir).
- CONFIG_
UPDATE_ PATH_ ENV - Environment variable for overriding the config update file path.
- SCREENSHOT_
FALLBACK_ PATH_ ENV - Optional environment variable for a static fallback screenshot file path. Used by the ACP harness to test the screenshot tool flow without a GUI.
- SCREENSHOT_
REQUEST_ FILENAME - Default screenshot request filename (relative to config dir).
- SCREENSHOT_
REQUEST_ PATH_ ENV - Environment variable for screenshot request IPC file path.
- SCREENSHOT_
RESPONSE_ FILENAME - Default screenshot response filename (relative to config dir).
- SCREENSHOT_
RESPONSE_ PATH_ ENV - Environment variable for screenshot response IPC file path.
- SHADER_
DIAGNOSTICS_ REQUEST_ FILENAME - Default shader diagnostics request filename (relative to config dir).
- SHADER_
DIAGNOSTICS_ REQUEST_ PATH_ ENV - Environment variable for shader diagnostics request IPC file path.
- SHADER_
DIAGNOSTICS_ RESPONSE_ FILENAME - Default shader diagnostics response filename (relative to config dir).
- SHADER_
DIAGNOSTICS_ RESPONSE_ PATH_ ENV - Environment variable for shader diagnostics response IPC file path.
Functions§
- run_
mcp_ server - Run the MCP server loop. Reads JSON-RPC messages from stdin until the stream is closed or an I/O error occurs, then returns normally so that callers can run destructors and exit cleanly.
- set_
app_ version - Set the application version (should be called from the main crate with
the root crate’s
VERSIONconstant before running the MCP server).