current_repository
Retrieve metadata for the active repository session, including session ID and related details.
Instructions
Return metadata for the active repository session.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "current_repository"
}
}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:36-39 (handler)MCP tool handler that delegates to TrailmarkRuntime.current_repository(). This is the entry point registered with the FastMCP server via @mcp.tool().
@mcp.tool() def current_repository(session_id: str | None = None) -> dict[str, Any]: """Return metadata for the active repository session.""" return app_runtime.current_repository(session_id=session_id) - Runtime layer: retrieves the EngineHandle from the registry and converts it to a dict via _handle_to_dict().
def current_repository(self, session_id: str | None = None) -> dict[str, Any]: return self._handle_to_dict(self.registry.current_repository(session_id)) - Core business logic: looks up the EngineHandle by session_id (or default session). Raises ValueError if no session is active.
def current_repository(self, session_id: str | None = None) -> EngineHandle: handle = self.get(session_id) if handle is None: raise ValueError("No active repository session") return handle - Tool schema definition specifying name, category, description, and parameters (optional session_id) for the 'current_repository' tool.
ToolSpec( name="current_repository", category="lifecycle", description="Return the active repository session and latest snapshot metadata.", parameters={"session_id": SESSION_ID_PARAM}, ), - Helper that serializes EngineHandle dataclass fields into a dictionary response (session_id, repo_path, language, timestamps, etc.).
def _handle_to_dict(self, handle: EngineHandle) -> dict[str, Any]: return { "session_id": handle.session_id, "repo_path": str(handle.repo_path), "language": handle.language, "created_at": handle.created_at.isoformat().replace("+00:00", "Z") if handle.created_at else None, "last_scan_at": handle.last_scan_at.isoformat().replace("+00:00", "Z") if handle.last_scan_at else None, "preanalysis_ran": handle.preanalysis_ran, "applied_augmentations": list(handle.applied_augmentations), "last_snapshot_path": str(handle.last_snapshot_path) if handle.last_snapshot_path else None, "snapshot_metadata": handle.snapshot_metadata, }