Back to the room

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

Code Observatory / function

build_mcp_server

modules.mcp.native_server.build_mcp_server

PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.

PHAROS at 975a38dMIT license

Around this symbol

Search all symbols

Loading

Calls (15)
SymbolFileResolved by
assemble_contextcontext.pythrough an import
ContextRequestcontext.pythrough an import
hit_to_dictcontext.pythrough an import
resolve_repositoriescontext.pythrough an import
get_embedderembeddings.pythrough an import
Filtersretrieval.pythrough an import
Retrieverretrieval.pythrough an import
secretruntime.pythrough an import
session_scoperuntime.pythrough an import
chunk_refsymbols.pythrough an import
find_symbolsymbols.pythrough an import
repository_summarysymbols.pythrough an import
symbol_graphsymbols.pythrough an import
_errornative_server.pysame file
_transport_securitynative_server.pysame file
Called by (1)
SymbolFileResolved by
get_streamable_http_appnative_server.pysame file
Inside (1)
SymbolFileResolved by
native_servernative_server.pysame file
modules.mcp.native_server.build_mcp_serverbackend/app/modules/mcp/native_server.py, lines 79–138Open source
def build_mcp_server() -> FastMCP:    server = FastMCP(        "pharos",        stateless_http=True,        json_response=True,        streamable_http_path="/",        transport_security=_transport_security(),    )    @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)    @server.tool(        description=(            "Search indexed code. mode: auto (default), keyword, dense, hybrid or graph. "            "Returns chunk pointers (path, lines, symbol) with retrieval evidence, no code. "            "Optionally pass hints: identifiers or keywords you guess the code uses."        )    )    def search_code(        query: str,        repository: str | None = None,        mode: str = "auto",

Shows the first 60 of 177 lines. The rest is on GitHub at this commit.

What the index recorded

Signature
def build_mcp_server() -> FastMCP:
File
backend/app/modules/mcp/native_server.py
Lines
79–255
Parser
python-ast
Git blob
0927865cd82a674fcaaa8c119faa660d8e20a47f
Call sites
33 named, 22 resolved, 11 left unlinked
Outside this subset
8 more edges reach code outside the graph shown here

Read it on GitHub at this commit