Skip to main content
Glama
parsiya

Trailmark MCP Server

by parsiya

open_repository

Open a repository to load its latest snapshot or scan source code for analysis and querying.

Instructions

Open a repository, loading latest snapshot or scanning source as needed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
repo_pathYes
languageNoauto
rescanNo
run_preanalysisNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Main business logic for the open_repository tool. Creates an engine handle via the registry, checks for a latest snapshot, and either loads it or scans the repository (optionally running preanalysis), then returns session info, summary, and snapshot details.
    def open_repository(
        self,
        repo_path: str,
        language: str = "auto",
        rescan: bool = False,
        run_preanalysis: bool = True,
    ) -> dict[str, Any]:
        handle = self.registry.open_repository(repo_path, language=language)
        latest_snapshot = self._latest_snapshot_info(handle.repo_path)
        should_scan = rescan or latest_snapshot is None
        if latest_snapshot is not None:
            handle.last_snapshot_path = latest_snapshot["snapshot_dir"]
            handle.snapshot_metadata = latest_snapshot["metadata"]
            metadata_language = latest_snapshot["metadata"].get("language")
            if metadata_language and language == "auto":
                handle.language = metadata_language
            if not should_scan:
                handle.engine = self._load_snapshot_engine(latest_snapshot["snapshot_dir"])
                handle.last_scan_at = self._snapshot_created_at(latest_snapshot["metadata"])
                handle.preanalysis_ran = bool(latest_snapshot["metadata"].get("preanalysis_ran"))
                handle.applied_augmentations = list(latest_snapshot["metadata"].get("augmentations") or [])
        if should_scan:
            scan_result = self._scan_handle(handle, language=handle.language, run_preanalysis=run_preanalysis)
            snapshot_result = self.save_snapshot(session_id=handle.session_id)
            return {
                "session": self._handle_to_dict(handle),
                "summary": scan_result["summary"],
                "preanalysis": scan_result["preanalysis"],
                "snapshot_dir": snapshot_result["snapshot_dir"],
            }
        return {
            "session": self._handle_to_dict(handle),
            "latest_snapshot": latest_snapshot,
        }
  • Low-level registry method that creates a new EngineHandle with a session_id, resolves the path, and registers it as the default session.
    def open_repository(self, repo_path: str | Path, language: str = "auto") -> EngineHandle:
        path = Path(repo_path).resolve()
        session_id = uuid4().hex
        handle = EngineHandle(
            session_id=session_id,
            repo_path=path,
            language=language,
            created_at=datetime.now(UTC),
        )
        self._sessions[session_id] = handle
        self._default_session_id = session_id
        return handle
  • MCP tool registration via @mcp.tool() decorator. Defines the FastMCP tool named 'open_repository' with parameters repo_path, language, rescan, and run_preanalysis, delegating to app_runtime.open_repository().
    @mcp.tool()
    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,
        )
  • Tool spec definition in TOOL_SPECS catalog. Declares parameter types and defaults: repo_path (string, required), language (string, default 'auto'), rescan (boolean, default False), run_preanalysis (boolean, default True).
    ToolSpec(
        name="open_repository",
        category="lifecycle",
        description="Open a repository, loading the latest snapshot when present or scanning source when needed.",
        parameters={
            "repo_path": _param("string", required=True),
            "language": _param("string", default="auto"),
            "rescan": _param("boolean", default=False),
            "run_preanalysis": _param("boolean", default=True),
        },
    ),
  • EngineHandle dataclass used to represent the state of an open repository session, including session_id, repo_path, language, engine, timestamps, and snapshot metadata.
    @dataclass
    class EngineHandle:
        session_id: str
        repo_path: Path
        language: str
        engine: QueryEngine | None = None
        created_at: datetime | None = None
        last_scan_at: datetime | None = None
        preanalysis_ran: bool = False
        applied_augmentations: list[str] = field(default_factory=list)
        last_snapshot_path: Path | None = None
        snapshot_metadata: dict[str, Any] | None = None
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description should fully disclose behavioral traits. It mentions scanning source 'as needed' but gives no specifics about what triggers scanning, side effects, or required permissions. The tool might be destructive (e.g., overwriting data), but this is not clarified.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very short (one sentence) and front-loaded, but it lacks sufficient detail for a tool with four parameters. It is concise but at the expense of completeness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (4 parameters, 0% schema coverage) and existence of output schema, the description is woefully incomplete. It provides no information about parameter defaults, behavior under different conditions, or how the tool affects the system state.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate by explaining parameters. It fails to do so: it does not clarify the purpose of 'language', 'rescan', or 'run_preanalysis'. The only implicit hint is 'loading latest snapshot or scanning source' which vaguely relates to the rescan parameter but is insufficient.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action (open a repository) and the dual behavior (loading snapshot or scanning source), distinguishing it from sibling tools like close_repository or current_repository. However, it does not explicitly differentiate from other tools that might also interact with repositories.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not provide any guidance on when to use this tool versus alternatives. It does not mention prerequisites, such as the repository not being already open, or when the snapshot vs scanning behavior triggers.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/parsiya/trailmark-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server