run_preanalysis
Analyze code repositories by running Trailmark preanalysis on the active engine. Optionally specify a session ID for targeted analysis.
Instructions
Run Trailmark preanalysis on the active engine.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/trailmark_mcp/mcp_app.py:135-138 (handler)MCP tool handler for 'run_preanalysis' — registered via @mcp.tool() decorator, delegates to app_runtime.run_preanalysis()
@mcp.tool() def run_preanalysis(session_id: str | None = None) -> dict[str, Any]: """Run Trailmark preanalysis on the active engine.""" return app_runtime.run_preanalysis(session_id=session_id) - Core logic of run_preanalysis: gets the scanned handle, calls engine.preanalysis(), marks preanalysis_ran=True, returns the result
def run_preanalysis(self, session_id: str | None = None) -> dict[str, Any]: handle = self._require_scanned_handle(session_id) result = handle.engine.preanalysis() handle.preanalysis_ran = True return result - src/trailmark_mcp/tool_catalog.py:158-163 (registration)ToolSpec registration for 'run_preanalysis' with category 'mutation', description, and session_id parameter
ToolSpec( name="run_preanalysis", category="mutation", description="Run Trailmark preanalysis on the active engine.", parameters={"session_id": SESSION_ID_PARAM}, ), - Internal _scan_handle that also invokes preanalysis during scan when run_preanalysis=True
def _scan_handle( self, handle: EngineHandle, *, language: str | None = None, run_preanalysis: bool = True, ) -> dict[str, Any]: if language is not None: handle.language = language handle.engine = QueryEngine.from_directory(str(handle.repo_path), language=handle.language) handle.last_scan_at = datetime.now(UTC) handle.preanalysis_ran = False handle.applied_augmentations.clear() preanalysis_summary: dict[str, Any] | None = None if run_preanalysis: preanalysis_summary = handle.engine.preanalysis() handle.preanalysis_ran = True return { "session": self._handle_to_dict(handle), "summary": handle.engine.summary(), "preanalysis": preanalysis_summary, } - src/trailmark_mcp/mcp_app.py:22-34 (helper)open_repository tool handler passes run_preanalysis parameter to app_runtime.open_repository, which can trigger preanalysis during scan
def open_repository( repo_path: str, language: str = "auto", rescan: bool = False, run_preanalysis: bool = True, ) -> dict[str, Any]: """Open a repository, loading latest snapshot or scanning source as needed.""" return app_runtime.open_repository( repo_path, language=language, rescan=rescan, run_preanalysis=run_preanalysis, )