Back to the room

Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works

Code Observatory / Source

The MCP tool

Clamps its limits, then calls the same assemble_context as REST.

PINNED SOURCE Copied from the repository at this commit. Source, not an execution.

PHAROS at 975a38dMIT license

retrieve_contextbackend/app/modules/mcp/native_server.py, lines 88–126Open source
    @server.tool(        description=(            "Retrieve the code most relevant to a question about an indexed repository: "            "ranked functions/classes with verified source, their callers/callees, what PHAROS learned "            "about the repository (brief, conventions for these files, playbooks) and its coding rules, "            "plus a Markdown rendering with path:line citations. "            "Ask in plain words; optionally pass hints: identifiers or keywords you guess the code uses "            "(e.g. ['parse_url', 'redirect'])."        )    )    def retrieve_context(        query: str,        repository: str | None = None,        max_chunks: int = 8,        include_code: bool = True,        max_chars: int = 24000,        profile_id: str | None = None,        hints: list[str] | None = None,        include_memory: bool = True,    ) -> dict[str, Any]:        with session_scope() as db:            try:                return assemble_context(                    db,                    get_embedder(),                    ContextRequest(                        query=query,                        repository=repository,                        max_chunks=max(1, min(max_chunks, 50)),                        include_code=include_code,                        max_chars=max(1000, min(max_chars, 400_000)),                        profile_id=profile_id,                        hints=(hints or [])[:20] or None,                        include_memory=include_memory,                    ),                    fetch_token=secret(get_settings().GIT_CLONE_TOKEN),                )            except (ModeUnavailable, RepositoryNotFound) as exc:                return _error(exc)

Where this comes from

Commit
975a38d5d17839c26ee219295a5be6ac66b6d910
File
backend/app/modules/mcp/native_server.py
Lines
88–126
Git blob
0927865cd82a674fcaaa8c119faa660d8e20a47f
License
MIT, © 2024–2026 Pharos Contributors. Notice

Read it on GitHub at this commit

Check it yourself

From a clone of the repository, the first command prints the blob above and the second prints these lines.

git rev-parse 975a38d:backend/app/modules/mcp/native_server.py
git show 975a38d:backend/app/modules/mcp/native_server.py | sed -n '88,126p'