pharos
Headless LSP-MCP bridge for AI agents.
Hands the same language servers your IDE uses (rust-analyzer, gopls,
tsserver, pyright, jdtls, and 18 more) to any MCP-aware agent — Claude
Code, Cursor, ChatGPT Desktop, or your own SDK app — so the model can
ask about your codebase with type-aware navigation instead of grepping.
At a glance — Phase 5 v1.0 final benchmark
5 languages × 70 questions × 2 arms (grep/Read baseline vs. pharos tool surface) × 3 trials = 1986 cells, 8 hours wall, run on DeepSeek-v4-pro with thinking enabled. Both arms see the same questions; the only variable is whether the agent has pharos tools available.
| Lang | Acc grep → pharos | Δ pp | Wall Δ | Cost Δ | LSP |
|---|---|---|---|---|---|
| python | 78 % → 85 % | +7 | -40 % | -14 % | pyright + ruff |
| rust | 62 % → 91 % | +29 | -45 % | 0 % | rust-analyzer |
| typescript | 63 % → 88 % | +25 | -46 % | -33 % | typescript-language-server |
| go | 74 % → 90 % | +16 | -35 % | -7 % | gopls |
| java | 73 % → 91 % | +18 | -40 % | -25 % | jdtls |
Average across the four mid-difficulty langs (excluding python, which sits near accuracy ceiling under both arms): +22 pp accuracy, -42 % wall time, -17 % cost.
Methodology in 30 seconds: questions and ground truth are machine-generated by querying the LSP authoritatively against random symbols sampled from the workspace; both arms attempt the same questions; scoring is mechanical (no human judgment). Full methodology, per-question data, and per-kind drill-downs at Benchmark methodology.
Contents
- Install
- Quick start
- How it works
- Language support
- Tools (+ reading answers)
- CLI reference
- Configuration
- Benchmark methodology
- Tool reference
- More languages (+ adding your own)
- Troubleshooting
- Architecture
- Development
- License
Install
pharos ships per platform as a release: a small native pharos
front end plus the Erlang runtime it starts, unpacked. Nothing extracts
at run time. Each MCP session runs pharos, which connects to one
shared pharos daemon per version (started on demand, exiting when idle),
so sessions on the same project share language servers
(ADR-034,
ADR-035).
Linux needs glibc 2.35 or newer (Ubuntu 22.04, Debian 12, Fedora 36,
RHEL 10 or newer; RHEL 9's glibc is 2.34). pharos doesn't run on
Alpine/musl or older distros yet; pharos-mcp@0.1.4 still does.
1. install.sh (Linux, macOS)
curl -fsSL https://github.com/LoganBresnahan/pharos-mcp/releases/latest/download/install.sh | sh
curl -fsSL …/install.sh | sh -s -- --version 0.2.0 # a given version
It installs ~/.local/share/pharos/versions/<version>/ and links
~/.local/bin/pharos to it, checking the download's sha256 first and
failing closed. It keeps the current and previous version, removes
older ones once no running pharos uses them, and never edits shell or
MCP client config. No sudo. Overrides: PHAROS_INSTALL_DIR (the install
root, default ~/.local/share/pharos), PHAROS_BIN_DIR (where the
pharos link goes, default ~/.local/bin).
From then on pharos manages itself (ADR-036):
pharos self update # the latest release (or: --version 0.2.1)
pharos self rollback # back to the previous version
pharos self prune # remove versions no longer kept, and pharos 0.1.x leftovers
pharos self uninstall # remove pharos's versions and its link
self update runs that release's install.sh; the others run the
install.sh each version ships with. None of them starts the Erlang
runtime. self uninstall refuses while a pharos is running: stop the
daemons with pharos daemon stop --all and quit MCP clients that run
pharos first.
2. npm (Linux, macOS)
npm install -g pharos-mcp
npm installs the one platform package that fits the host, and the
postinstall points pharos straight at the native binary, so no node
process stays resident per session. npm owns these files: update with
npm install -g pharos-mcp@latest and remove with npm uninstall -g pharos-mcp. pharos self update, rollback and uninstall print the
npm command instead of acting; pharos self prune still removes what
pharos 0.1.x left behind.
Either way, add pharos to your MCP host's config:
{
"mcpServers": {
"pharos": { "command": "pharos" }
}
}
PHAROS_MODE=direct runs a session in its own process instead of the
shared daemon. If a session can't reach the daemon it falls back to
direct mode on its own, and pharos --doctor lists those fallbacks.
pharos runs on Linux and macOS. The macOS builds are made on macOS 15 and
need macOS 15 or later: Intel builds always have, and Apple silicon builds do
from the release after 0.2.2 (0.2.2 needs macOS 14). On Windows, install it inside WSL
(pharos-mcp@0.1.4 was the last native Windows build).
3. Build from source
Requires Erlang/OTP 28.1.1, Elixir 1.19.5, Gleam 1.17 and a Rust toolchain (for the native front end). See Development.
Quick start
Two-step setup:
1. Install at least one LSP for a language you'll use. See Language support for the full table; the shortest paths:
rustup component add rust-analyzer # Rust
go install golang.org/x/tools/gopls@latest # Go
npm install -g typescript-language-server typescript # TypeScript/JS
npm install -g pyright # Python
2. Point your MCP client at pharos.
Claude Code (~/.claude.json or per-project .mcp.json):
{
"mcpServers": {
"pharos": {
"command": "pharos"
}
}
}
Cursor (per-server config UI): command pharos, args [].
ChatGPT Desktop / Claude Desktop: same shape via their JSON config.
Restart the MCP client. The model now has tools named
mcp__pharos__hover, mcp__pharos__find_references, etc.
Optional — warm the LSPs once on a per-project basis:
cd /path/to/your/project
pharos warm --all # detects languages from workspace markers, pre-indexes each
pharos warm rust go # or name them explicitly — one or more languages
This makes the first MCP tool call ~3-5 s instead of ~30-60 s for heavy LSPs like rust-analyzer or jdtls by populating their on-disk indexes ahead of time.
How it works
The MCP client spawns pharos for each session. That process is a small
native front end: it connects the session's stdio to the shared pharos
daemon for this version over a Unix socket, starting the daemon if none
is running, and relays JSON-RPC lines both ways. The daemon is one
BEAM VM that serves every session of that version
(ADR-034).
Lifecycle of one LSP request from agent to language server:
- Agent calls an MCP tool over stdio:
find_references(uri, line, character); the front end hands the line to the daemon. - Pharos detects the language from the file URI (extension → registry lookup) and looks up the configured LSP for that language.
- If the LSP isn't already in pharos's pool for this
(language, workspace), pharos spawns it as a subprocess and runs the LSPinitializehandshake plus a readiness probe per ADR-024. Cold start is ~3-60 s depending on the LSP (gopls fast, jdtls/metals slow). - Pharos forwards the request as the corresponding LSP method
(
textDocument/references). - LSP responds; pharos shapes the response into the MCP tool's return schema and ships it back to the agent.
The LSP stays cached in the daemon's pool, shared by every session:
each later tool call against the same (language, workspace) reuses
it, from this session or another one. A language server with no request
for 30 minutes (2 hours for java, scala and haskell) stops, and restarts
on the next call; PHAROS_LSP_IDLE_SECS changes that. The pool also handles
multi-language workspaces (one pyright + one rust-analyzer running
side by side for the same project tree) and multi-server languages
(python uses pyright AND ruff with method routing — see
ADR-019).
The daemon is on demand. The first session of a version starts it
and it exits 30 minutes after its last session ends
(PHAROS_DAEMON_IDLE_SECS), sending shutdown/exit to each cached
LSP and removing its instance tracking dir (see
Troubleshooting). A new version gets its own daemon,
so an upgrade never mixes code; sessions already running stay on the
old one until they end. pharos daemon status shows what is running,
and pharos daemon stop stops it. In direct mode (PHAROS_MODE=direct
or pharos --direct) a session is instead its own VM, living exactly as
long as the client's stdio pipe.
Language support
Pharos does not bundle LSPs — you install them; pharos resolves
them via PATH at runtime and surfaces a clear error if a binary is
missing. If you keep an LSP outside PATH or want to pin a specific
version, point pharos at the absolute path via pharos.toml:
[languages.rust]
command = "/opt/custom-rust-analyzer"
See Adding your own language for the
full per-language schema. Run pharos --doctor after install to
verify every resolved binary.
The five benchmarked in Phase 5 — follow the LSP's own install instructions:
| Language | Server(s) |
|---|---|
| Rust | rust-analyzer |
| Go | gopls |
| TypeScript / JavaScript | typescript-language-server |
| Python | pyright (types/hover/goto) + ruff (format/lint/fixes) |
| Java | jdtls (Eclipse JDT) — JDK 17+ required |
More languages ↓ — also wired and ready: C/C++, Elixir, Erlang, Gleam, Scala, Clojure, Haskell, Ruby, Lua, Bash, Zig, Perl, HTML/CSS/JSON, YAML, Markdown, Terraform.
Per-tool support varies by LSP — not every LSP implements every LSP method. See doc/lsp-capability-matrix.md for the full 23-language × 16-tool grid (regenerated from each dogfood pass).
Don't see your language? Any language with an LSP-compliant server
can be wired in via pharos.toml — full worked example at
Adding your own language ↓. 23 languages
ship bundled today; the registry is just a default and is fully
overridable.
Multi-server routing is supported for languages that need it (Python; see ADR-019).
Tools
53 MCP tools across 5 categories + 2 filter presets. The 5
categories (read, write, memory, debug, raw) partition every tool
exactly once. The 2 presets (default, all) are filter aliases
that aggregate across categories — what your MCP host sees when you
set e.g. tools = ["default", "raw", "runtime_kill_lsp"] (preset +
category + literal tool name — mix freely) or tools = ["all"] in
pharos.toml; full per-tool detail at
Tool reference.
| Category | Count | Examples | When you'd toggle off |
|---|---|---|---|
| default (preset) | 37 | Aggregates read + write + memory plus 5 runtime essentials the LLM uses for tool-error recovery (echo, runtime_set_tool_timeout, runtime_effective_tool_config, runtime_language_config, runtime_server_capabilities) | This is the shipping preset. Replace with an explicit list (e.g. tools = ["read"]) for tighter surfaces. |
| read | 22 | hover, goto_definition, find_references, find_referencing_symbols, find_symbol, document_symbols, workspace_symbols, containing_symbol, call_hierarchy_*, type_hierarchy_*, signature_help, get_diagnostics, inlay_hints, semantic_tokens, fetch_uri_contents | Never — these are the core LSP queries that make pharos worth running. |
| write | 5 | rename_preview, format_document, code_actions, apply_workspace_edit, edit_at_symbol | When the agent should propose edits without authority to apply them. Set tools = ["read"] for query-only mode. |
| memory | 5 | memory_save, memory_get, memory_list, memory_prune, memory_audit | Project-memory store (ADR-027) — toggle off if the agent doesn't need persistent notes scoped to the workspace. |
| debug | 20 | runtime_processes, runtime_supervision_tree, runtime_log_tail, runtime_kill_lsp, runtime_lsp_state, runtime_pool_recon, runtime_trace_lsp, runtime_memory, echo, runtime_set_tool_timeout, full list ↓ | Off by default beyond the 5 essentials. Opt in (tools = ["default", "debug"]) for dogfood / power-user installs where pharos's BEAM internals should be reachable. |
| raw | 1 | lsp_request_raw | Off by default. Opt in only when the agent legitimately needs LSP methods pharos hasn't wrapped natively. |
| all (preset) | 53 | All tools available | The "expose everything" preset (tools = ["all"]) — dogfood / power-user installs that want both debug and raw exposed. |
Reading answers
What a uri must look like. Tools take a local file as a file://
URI with an absolute path: file:///home/me/proj/main.go.
file://localhost/abs and file:/abs are accepted too. Everything else
is refused with a message that says what to send instead: a relative or
bare path, a file:// URI naming another host (a relative
file://src/a.ts reads as the host src), a file: URI with a relative
path, and a path with a line on the end (main.go:12,
file:///abs/main.go:12), which gets the URI and the 0-based line to
pass. A URI of another scheme (untitled:, https://) is not a file on
disk; jdt:// and other schemes a language registers work with the
navigation tools and fetch_uri_contents, and get_diagnostics says it
covers files on disk only; for a file that isn't on disk it fails at once
("file not found", #61).
get_diagnostics. Answers are as of the file on disk, and an answer
the server may not have caught up with says so in a pharos member:
carried_over: the server hasn't published since the last change (or pharos couldn't wait for it): this is its last set, which may describe the text before the change. It still holds if the change left the diagnostics as they were.assumed_current: the server published nothing since the file was opened, and it publishes nothing for a file without problems (lua-language-server), so the set is taken as current.files_unchecked: pharos hadn't finished checking the tree for files changed on disk before this answer. (Other tools that pass a server's answer through carry the same note as a second text block.)not_reported: on a language with several servers (Python: pyright and ruff), these servers reported nothing in time; their diagnostics are unknown, not empty.- "No textDocument/publishDiagnostics notification was received for … within the timeout" means the server said nothing in time: the diagnostics are unknown, not empty.
find_symbol. At most 16 files are searched per call: scope_uri
first, then those whose symbols the workspace search named exactly like
the query;
files_not_searched says how many it named that weren't, and how to
narrow (a scope_uri in the defining file, or a fuller name_path). A
match found only in another case or by a partial name carries a note
("no exact match for the name asked; nearest by a partial name: X", or
"… nearest in another case: X"). On
servers whose workspace search finds modules only (elp, perlnavigator),
ask for module/function or Package/sub; a bare name not found says so.
Unsupported methods. When a server doesn't advertise a method, the tool says so ("this language server () doesn't support : it doesn't advertise , so pharos didn't send the request") instead of failing.
CLI reference
Pharos has no runtime-configuration CLI flags — every knob lives in
pharos.toml or PHAROS_* env vars. Flags are operational meta
commands.
| Command | Purpose |
|---|---|
pharos | MCP server (default — what your client invokes). Reads JSON-RPC from stdin, writes responses to stdout, logs to stderr. |
pharos warm <lang>... | Pre-warm the named languages' LSPs against cwd. Spawns each LSP, runs the readiness gate, exits. Subsequent MCP-server runs in the same workspace boot ~10-20× faster because the LSPs' on-disk indexes are now hot. |
pharos warm --all | Same as above but enumerates every language pharos knows about and warms whichever ones have project markers in cwd. Languages without markers (e.g. Cargo.toml for rust, go.mod for go) are skipped with a clear log line. |
pharos --doctor | Self-diagnostic. Resolves config the same way a normal boot does, probes each language server's binary on PATH, reports anything that would break a real run, and lists recent daemon fallbacks. |
pharos --cleanup | List orphan LSP children left behind by prior pharos sessions that exited uncleanly (host crash, SIGKILL, OOM-killer). Dry-run by default — adds nothing destructive without a flag. |
pharos --cleanup --yes | Reap the orphans listed by --cleanup: SIGTERM each, wait 5 s, SIGKILL survivors, remove their per-PID tracking directory. |
pharos daemon status [--all] | This version's shared daemon (or every daemon): its sessions and language servers. |
pharos daemon stop [--all] | Stop this version's daemon (or all). Returns once the daemon has exited (up to 10 s; past that it says the daemon is still stopping and exits 1). Sessions on it see their server exit; MCP clients restart it on reconnect. |
pharos --direct | Run this session in its own process instead of the shared daemon (also PHAROS_MODE=direct). |
pharos diagnostics [--json] [--timeout-ms N] FILE... | The files' diagnostics through the shared daemon, for hooks and scripts. Each file is ok, unsure (pharos marked the answer: say nothing) or failed; exit 0 once the daemon answered, 1 if pharos itself failed, 2 on bad usage. A captAInHook payload built on it ships in every release: integrations/captainhook/. |
pharos self update [--version V] | Install the latest release (or V) with its install.sh. An npm install prints the npm command instead. |
pharos self rollback | Switch back to the previous version. |
pharos self prune | Remove the versions install.sh no longer keeps (all but the current and previous, unless running), and what pharos 0.1.x unpacked under ~/.local/share/.burrito/pharos_* that no running process uses. |
pharos self uninstall | Remove pharos's versions and its link (refuses while a pharos runs). Keeps config, logs and memories. |
pharos --purge-cache | Deprecated alias of pharos self prune; goes in the next release. |
pharos --print-default-config | Print the canonical pharos.toml starter with comments. Pipe to ~/.config/pharos/pharos.toml to begin customising. |
pharos --print-language-config <id> | Print one language's resolved registry entry (after pharos.toml overlays). Useful for debugging "why isn't my custom binary path being used?". |
pharos --version / -V | Print version and exit. |
pharos --help / -h | Print usage and exit. |
Useful env vars
| Var | What it does | Default |
|---|---|---|
PHAROS_MODE | auto uses the shared daemon and falls back to direct mode if it can't be reached; daemon fails instead; direct runs the session in its own process. | auto |
PHAROS_WARM_LANGS | CSV; pharos pre-warms these languages when it boots. Direct mode only: the shared daemon doesn't warm per session, so use pharos warm there. | unset (off) |
PHAROS_LOG | RUST_LOG-style filter (info, info,pharos/lsp/pool=debug). | info |
PHAROS_LOG_FILE | Override the default log file location. | daemon: ~/.local/state/pharos/log/daemon-<build>-<key>-<pid>.log; direct mode: …/session-<pid>-<timestamp>.log ($XDG_STATE_HOME honoured) |
PHAROS_HEARTBEAT_INTERVAL_MS | Cadence of the idle-heartbeat log line (memory + LSP child count). | 60000 |
PHAROS_SHUTDOWN_DRAIN_MS | How long to wait for in-flight requests before initiating LSP shutdown on SIGTERM/stdin-EOF. | 2000 |
PHAROS_DAEMON_IDLE_SECS | How long the shared daemon stays up after its last session ends. | 1800 |
PHAROS_LSP_IDLE_SECS | Stop a language server after this many seconds with no request routed to it; it restarts on the next call. Overrides every language's idle_stop_secs. 0 never stops. | 1800 (java, scala, haskell: 7200) |
PHAROS_RUNTIME_DIR | Where the daemon's socket lives. A path too long for a Unix socket falls back to /tmp/pharos-<uid>/ under a name hashed from it, and an explicit one that doesn't fit is reported on stderr. | $XDG_RUNTIME_DIR/pharos (macOS: $TMPDIR/pharos), else /tmp/pharos-<uid> |
PHAROS_WATCH_BUDGET_MS | How long one scan for files changed on disk may walk before a question (ADR-043). Never more than what's left of the question's timeout. A tree scanned whole within half of it is scanned before every question; a larger one at most every 2 s, resuming where it stopped, with answers marked until it has covered the tree. | 200 |
Configuration
Pharos reads configuration in this precedence order (later wins):
- Compiled-in defaults (no config required)
~/.config/pharos/pharos.toml— global per-user./.pharos.tomlor./pharos.toml— per-project: the nearest directory up from cwd holding either. Where both are,.pharos.tomlis read andpharos.tomlis ignored, with a warningPHAROS_*environment variables — final override
To start customising, dump the canonical TOML with comments:
mkdir -p ~/.config/pharos
pharos --print-default-config > ~/.config/pharos/pharos.toml
$EDITOR ~/.config/pharos/pharos.toml
The full schema lives in doc/example-pharos.toml,
including the per-server tuning keys: settle windows for servers that
publish in phases, silence after an open, position encodings, file
watching and modules-only lookups. pharos --print-language-config <id>
shows the values in effect for a language.
pharos checks every config file it reads and warns, on stderr and in the
daemon log, about unknown keys (with the likely spelling), values of the
wrong type, unusable values, unknown tool or language names, missing
required keys and keys in the wrong table. A value that would do harm is
ignored: an unknown diagnostics_mode, an initialize_timeout_ms or a
[tool_config] default_timeout_ms of 0 or less, a negative
idle_stop_secs, and an empty file extension keep the default; a tools
list in which no entry names a tool, category or preset keeps the earlier
setting ("default" unless an earlier file set one), while an explicit
tools = [] exposes none.
Tool filter (tools = [...])
Pick presets, categories or literal tool names. Default: the default
preset (read + write + memory + the five recovery essentials).
tools = ["read"] # query-only agent
tools = ["read", "write"] # full LSP surface
tools = ["read", "runtime_log_tail"] # category + one extra
tools = ["hover", "goto_definition"] # fully explicit
Per-tool timeout overrides ([tool_config.<name>])
Every LSP-bound tool accepts an optional timeout_ms argument and has
a compile-time default: 30 s for most, 60 s for find_references, 20 s
for get_diagnostics.
Override globally or per-language:
[tool_config.format_document]
default_timeout_ms = 90000
[tool_config.find_references.java]
default_timeout_ms = 120000 # jdtls workspace-wide refs are slow
Resolution order (later wins):
- Compile-time tool default
[tool_config.<name>] default_timeout_ms(global per-tool)[tool_config.<name>.<lang>] default_timeout_ms(per-tool × per-lang)- Per-call
timeout_msargument
Recommended starting bumps for heavy LSPs:
| LSP | Tools that benefit | Suggested |
|---|---|---|
jdtls (java) | type_hierarchy_*, find_references, format_document | 90-120 s |
metals (scala) | workspace_symbols, inlay_hints, semantic_tokens, rename_preview | 60-90 s |
ruby-lsp | goto_*, call_hierarchy_prepare | 60 s |
perlnavigator (perl) | find_references, rename_preview | 120-240 s |
gopls (big mod) | workspace_symbols | 90 s |
rust-analyzer (monorepo) | format_document | 60 s |
When a tool times out the LLM sees tool timeout: LSP did not respond in time... with pointers to the runtime_set_tool_timeout and
per-call timeout_ms escape hatches — so most tuning ends up happening
in-conversation, not in TOML.
Multi-server languages (ADR-019)
A few languages route different LSP methods to different servers. Python is the prominent case:
| Server | Scope | Owns |
|---|---|---|
pyright | every method (no methods key) | hover, goto, references, types, signature_help, document_symbols, workspace_symbols |
ruff | methods = ["textDocument/formatting", "textDocument/codeAction", "textDocument/diagnostic"] | formatter, lint quick-fixes, import-sort, lint diagnostics |
Routing rule per ADR-019:
the first server declaring a method via Only wins; otherwise the
first All-scope server wins. Methods that produce array-shaped
results (codeAction, diagnostic) merge across every claiming
server.
Add a third server (e.g. mypy alongside pyright + ruff):
[[languages.python.servers]]
id = "mypy"
command = "mypy"
args = ["--strict"]
methods = ["textDocument/diagnostic"]
Benchmark methodology
Run shape
-
Corpora. One open-source workspace per language. Each picked for being moderately complex but small enough to fully index inside the WSL2 box used for the run:
Language Repository What it is python pallets/flask The Flask web framework rust tokio-rs/bytes Byte-buffer utilities crate (used across the tokio ecosystem) typescript colinhacks/zod TypeScript-first schema validation library go prometheus/prometheus The Prometheus monitoring server java spring-projects/spring-petclinic Reference Spring Boot application Fixtures were cloned in May 2026.
-
Questions. 60-70 per language, auto-generated by
bench/oracle.pyfrom random sampling ofdocument_symbolsoutput. No human curation. Seven question kinds spanning the navigation surface:find_definition,find_implementation,references_count,symbol_kind,hover_first_word,hover_signature,call_hierarchy_in,containing_symbol,collision_resolve. -
Arms. Same question, two tool surfaces:
- control — Bash, Glob, Grep, Read (no pharos).
- treatment — the same set PLUS the full pharos MCP tool surface.
-
Model. DeepSeek-v4-pro, thinking mode on.
-
Trials. 3 independent runs per (question, arm); per-arm n = base_questions × 3.
-
Run wall time. 8 hours, 5 languages in parallel (one pharos process per language, isolated workspaces).
Ground truth
Each question's ground truth is computed by bench/oracle.py calling
the LSP authoritatively before the run starts. The references_count
ground truth for "how many references does foo have" comes from
running textDocument/references on foo and counting. The
find_definition ground truth is the URI the LSP returned for
textDocument/definition.
This means the LSP is the oracle for ground truth, and the
benchmark measures whether an LLM equipped with pharos reaches the
LSP-correct answer more often than an LLM restricted to grep. That's
deliberate: the LSP IS the authoritative source for language
semantics (rust-analyzer knows whether two fn foos are the same
generic instantiation; grep can't), and the hypothesis under test is
exactly that giving the agent access to that authoritative source
helps.
Scoring
Mechanical, deterministic. No human judgment. Rules per kind in bench/score.py:
| Kind | Rule |
|---|---|
references_count | First integer in answer == ground_truth integer |
find_definition / find_implementation | Normalised file path equality |
symbol_kind | Case-insensitive SymbolKind name equality |
hover_first_word | Substring match on first word |
hover_signature | Substring match on type sig |
Rerunning the scorer against the same per-question JSONL yields the same numbers; the scoring is reproducible.
Cost — local estimate vs. billed
The per-cell cost_usd field is a local estimate using DeepSeek-v4-pro
promo rates (active through 2026-05-31). It underestimates the actual
DeepSeek-billed total by ~4.5× in this run (local sum $11.35 vs. actual
delta ~$50.60). The pricing constants in
bench/harness_deepseek.py may pre-date a
DeepSeek rate change or there's a cache-hit vs cache-miss classification
gap; per-arm relative deltas are unaffected (both arms use the same
constants). v1.1 reconciliation item.
Full data
bench/results/v1.0-final/phase5-final-report/summary.md— headline matrix + percentiles + per-kind drill-downbench/results/v1.0-final/phase5-final-report/per-question.md— every cell (1986 rows)bench/results/v1.0-final/phase5-final-report/pairs.csv— joined control/treatment per (qid, trial); hasflip_c_wrong_t_rightandflip_c_right_t_wrongcolumns for fine-grained diff analysis
What this bench does NOT measure
- Code-writing tasks (refactors, new feature implementation). Different methodology needed.
- Agent reasoning quality. A bad LLM with a good tool surface can still get the right answer mechanically. The control arm partially baselines this.
- Production traffic patterns. Phase 5 is synthetic by design — random symbol sampling, evenly distributed across kinds. Real agent workloads cluster heavily around a few question types.
Tool reference
Brief per-tool summaries below. All tools accept timeout_ms as an
optional argument; defaults are listed in
Configuration.
read (22 tools)
| Tool | What it returns | Backed by |
|---|---|---|
hover | Type info + docs for the symbol at (uri, line, character) | textDocument/hover |
goto_definition | URI + range of the symbol's definition | textDocument/definition |
goto_type_definition | URI + range of the symbol's type | textDocument/typeDefinition |
goto_implementation | URI + range list of implementations (trait impls, abstract overrides, etc.) | textDocument/implementation |
find_references | URI + range list of every reference site | textDocument/references |
find_referencing_symbols | One step deeper than find_references — returns the containing symbol of each reference (function name, class, etc.) | composed: references → documentSymbol per uri |
find_symbol | Locate a symbol by name_path (Type/member, module/function) across the workspace. Searches at most 16 files per call, the ones named exactly like the query first, and says so in files_not_searched when it left some out | workspace/symbol + documentSymbol |
document_symbols | Outline of every symbol in one file (hierarchical) | textDocument/documentSymbol |
workspace_symbols | Fuzzy-match symbol name across the workspace | workspace/symbol |
get_symbols_overview | Top-level outline only (no nesting) — cheaper than document_symbols for "what's in this file" probes | composed |
containing_symbol | The innermost named symbol covering a given line | composed: documentSymbol → tree walk |
signature_help | Function signature + active parameter for the call at cursor | textDocument/signatureHelp |
call_hierarchy_prepare | Anchor a call-hierarchy query at a symbol | textDocument/prepareCallHierarchy |
call_hierarchy_incoming_calls | Who calls this symbol | callHierarchy/incomingCalls |
call_hierarchy_outgoing_calls | What this symbol calls | callHierarchy/outgoingCalls |
type_hierarchy_prepare | Anchor a type-hierarchy query | textDocument/prepareTypeHierarchy |
type_hierarchy_supertypes | Parent classes/traits | typeHierarchy/supertypes |
type_hierarchy_subtypes | Child classes/implementations | typeHierarchy/subtypes |
get_diagnostics | Errors and warnings for one file (uri), as of the file on disk; see Reading answers for its markers | textDocument/diagnostic + cached publishDiagnostics |
inlay_hints | Inline type / parameter hints in a range | textDocument/inlayHint |
semantic_tokens | Token-level semantic classifications for syntax-aware operations | textDocument/semanticTokens/* |
fetch_uri_contents | Read raw text behind a custom URI scheme (e.g. jdt:// for jdtls class-file contents) — see ADR-029 | scheme-dependent |
write (5 tools)
| Tool | What it does | Authority model |
|---|---|---|
rename_preview | Compute a WorkspaceEdit for renaming a symbol — does NOT apply | Caller (LLM) inspects + applies via apply_workspace_edit |
format_document | Compute a WorkspaceEdit from the LSP formatter — does NOT apply | same |
code_actions | Enumerate available quick-fixes / refactors at a position, each as a WorkspaceEdit | same |
edit_at_symbol | Replace the source range of a named symbol with new text — convenience for "rewrite fn foo body" style edits | Returns a WorkspaceEdit; caller applies |
apply_workspace_edit | Write a WorkspaceEdit to disk. dry_run=true by default (returns the diff); flip to false to actually write. Per-file atomic writes. | This is the only tool that mutates source files. |
memory (5 tools)
Per-project key-value memory store (ADR-027).
Files live at .pharos/memories/ in the workspace root; safe to commit
to version control if the project's policy allows. Useful for agents
that benefit from durable notes across sessions ("the auth tests use
fixture X", "this module is being refactored").
| Tool | What it does |
|---|---|
memory_save | Write or update a memory entry by key |
memory_get | Read one memory entry |
memory_list | List all memory entries (paginated) |
memory_prune | Delete one or more entries by key |
memory_audit | Surface entries that have not been read in N days, suggest review |
debug (20 tools)
BEAM / pharos introspection. The first 5 ship under the default
preset because the read/write surface points at them in tool-error
recovery recipes; the remaining 15 are opt-in via tools = ["default", "debug"] or tools = ["all"].
| Tool | What it does | Exposed under |
|---|---|---|
echo | Round-trip an MCP message — smoke test for the transport before exercising any LSP-bound tool | default |
runtime_set_tool_timeout | Bump or lower one tool's timeout for the current session; the LLM uses this after a timeout to retry with a wider budget | default |
runtime_effective_tool_config | Inspect the resolved per-tool config (timeout, max bytes, etc.) after pharos.toml + env-var overlays | default |
runtime_language_config | Inspect one language's resolved LSP config — "is the binary path the override I set or the default?" | default |
runtime_server_capabilities | Report which LSP methods the spawned server advertised in its initialize response — useful when a tool returns "unsupported" | default |
runtime_processes | Snapshot of BEAM processes (memory, message-queue length, registered name) — pharos's view of "what's running" | debug |
runtime_pid_info | Drill into one pid: current function, links, monitors, trap_exit, dictionary | debug |
runtime_supervision_tree | Dump the live supervised tree as application_controller sees it | debug |
runtime_ets_tables | List ETS tables (size, memory, owner) — pharos uses ETS for the pool's subject bridge + diagnostics cache | debug |
runtime_memory | BEAM memory breakdown (atom, binary, processes, code, ETS) | debug |
runtime_applications | List running OTP applications with their start args | debug |
runtime_scheduler_util | Per-scheduler utilization snapshot over a short window | debug |
runtime_log_tail | Read the last N entries from the in-memory log ring (post-filter) | debug |
runtime_log_clear | Drop the in-memory ring's contents — useful before reproducing a bug | debug |
runtime_log_level | Get or set the current log filter spec (info, debug,pharos/lsp/pool=trace, etc.) without a restart | debug |
runtime_trace_lsp | Enable / disable per-LSP wire trace (every textDocument/* request + response logged) | debug |
runtime_trace_calls | Enable / disable per-MCP-tool call trace (every tools/call request + response logged) | debug |
runtime_kill_lsp | Graceful kill of one or all LSPs in a workspace; next request lazily respawns (see Architecture) | debug |
runtime_lsp_state | Inspect cached state of one LSP — initialize-time, advertised capabilities, request counters | debug |
runtime_pool_recon | Pool reconciliation stats: cache hit rate, leak count, ghost-subject count, top N hot keys | debug |
raw (1 tool)
| Tool | What it does |
|---|---|
lsp_request_raw | Escape hatch for any LSP method pharos hasn't wrapped natively (e.g. textDocument/foldingRange, server-specific extensions like rust-analyzer/inlayHints). Off by default in the tools = [...] filter; enable explicitly. |
More languages
The remaining 18 wired into pharos. Same MCP tool surface as the benchmarked five — follow each LSP's own install instructions.
| Language | Server(s) | Notes |
|---|---|---|
| C / C++ | clangd | Needs compile_commands.json for non-trivial projects |
| Elixir | next-ls (default) — alts: elixir-ls, start_expert | next-ls counts columns in code points; pharos converts them, so positions on lines with non-ASCII text are right. next-ls publishes nothing for a clean file, so get_diagnostics on one waits out its timeout and says no publish came (#59). It compiles only on a save and acts on no file-change event, so a file changed on disk and asked about for the first time gets no compile. It needs Hex where the session's MIX_HOME / MIX_ARCHIVES point, or it never starts its runtime (sessions that differ in them get separate servers, #62). After a change, get_diagnostics waits for the compile next-ls runs on save (#60) and for its indexing progress, so an answer after an edit can take several seconds (about 10 s on geex, more under load) although the new set is published sooner |
| Erlang | elp — alt: erlang_ls | elp's workspace search finds modules only: ask find_symbol for module/function (util/helper, or util/helper/1 with the arity); a bare function name is looked for in scope_uri only. elp publishes nothing for a file without problems, so get_diagnostics on a clean file waits out its timeout (20 s by default) and says no publish came; a shorter timeout_ms shortens the wait (#56). A first answer can be elp's compiler set before its lint set arrives, unmarked; asking again gets the whole set. A file asked about in the same step as files changed on disk reach elp can lose its set to elp re-reading those files, and then waits out its timeout too (#56). A module created on disk becomes known to elp after its project reload, which elp runs at its next event 500 ms or more after the change (ADR-043) |
| Gleam | gleam lsp (built into compiler) | Pharos dogfoods its own gleam tree against this |
| Scala | metals | First-run bootstraps Bloop (~2-3 min); pharos timeout config covers it |
| Clojure | clojure-lsp | Native binary, no JVM cold-start |
| Haskell | haskell-language-server (haskell-language-server-wrapper) | Use ghcup to keep GHC/cabal/HLS in sync |
| Ruby | ruby-lsp | Project needs Gemfile.lock (run bundle install first). Diagnostics are pulled; positions on lines with non-ASCII text are converted (ruby-lsp counts UTF-8 bytes). ruby-lsp never indexes a method defined outside a class or module, so its workspace search never returns a top-level def: definition and hover on a call to one answer nothing, and find_symbol finds it only with scope_uri set to the file that defines it (from another file it may answer a similarly named method instead); methods in classes and modules are found from anywhere |
| Lua | lua-language-server | lua-language-server publishes nothing for a clean file, so get_diagnostics answers [] marked assumed_current about 2 s after a file's open, once the workspace is loaded and diagnosed; before that (about 30 s on a large project) the answer waits, past the 20 s default timeout. Asked again with nothing changed, the answer is the same. After an edit, silence never counts: the answer waits as for any server; a file answered [] that way and edited, still clean, gets [] marked carried_over in about 2 s. Each answer after a publish waits 1 s for its later phases; on a heavily overloaded machine a partial set can still come back unmarked (#54) |
| Bash | bash-language-server | Diagnostics need shellcheck on PATH |
| Zig | zls | Match your zig version |
| Perl | perlnavigator | Its workspace search returns packages only (from the root lib/): ask find_symbol for Package/sub (My::App/run for lib/My/App.pm); a bare sub name is looked for in scope_uri only. perlnavigator publishes each check twice, first with the previous check's Perl::Critic findings, so get_diagnostics waits for the second: about 2.35 s after an edit, 2.5 s after an open (ADR-038) |
| HTML / CSS / JSON | vscode-langservers-extracted (one package) | |
| YAML | yaml-language-server | |
| Markdown | marksman | Single Rust binary |
| Terraform / HCL | terraform-ls | terraform-ls returns columns in code points; pharos converts them |
Adding your own language
Pharos's bundled language list is just a default — every entry can
be overridden and any language with an LSP-compliant server can be
added in pharos.toml (see Configuration for the
file's load order).
Override a bundled language's binary path (everything else inherited from defaults):
[languages.rust]
command = "/opt/custom-rust-analyzer"
Add a brand-new language pharos doesn't bundle — Fennel as a worked example:
[languages.fennel]
file_extensions = [".fnl"] # files ending in these belong to this language
root_markers = [".git", "fennel.fnl"] # filenames whose presence marks the project root
[[languages.fennel.servers]]
id = "fennel-ls"
command = "fennel-ls" # must resolve on PATH or be an absolute path
args = []
# One server and no `methods` key: it handles every LSP method.
Required keys (everything else has a sane default):
| Key | Purpose |
|---|---|
file_extensions | Suffixes (leading dot included) whose files belong to this language |
root_markers | Filenames whose presence marks the project root (used to pick the LSP workspace). Replaces the default list rather than merging. Note that markers a dependency also ships — e.g. package.json under node_modules/ — can root a session inside that dependency; see Wrong answers for queries anchored inside a dependency |
[[languages.<id>.servers]] (≥1) | At least one server with a command resolvable on PATH |
id (optional) is the languageId pharos sends in textDocument/didOpen;
it defaults to the table's name (fennel above). When one language covers
dialects its server parses differently, document_language_ids gives the
languageId per extension, and an extension it doesn't list gets id
(ADR-041). The bundled
typescript entry sets document_language_ids = { ".tsx" = "typescriptreact", ".js" = "javascript", ".mjs" = "javascript", ".cjs" = "javascript", ".jsx" = "javascriptreact" }; like the other list keys, setting it replaces the
bundled list. Per-server methods
takes a list of LSP methods and only matters when a language has
several servers (see Multi-server languages).
Optional dependency-location keys. Both default to empty, which
means "plain ascent, exactly as before" — set them only if this
ecosystem materialises dependencies into a directory that also carries
one of your root_markers. Like root_markers, each replaces the
bundled list rather than merging into it.
| Key | Purpose |
|---|---|
vendor_segments | Path segments naming in-tree dependency directories — materialised under the project root ("/node_modules/", "/site-packages/", "/vendor/bundle/"). Matched as an interior segment, leading and trailing / included. Answers rooted inside one get the dependency-scope warning; rooting itself is unchanged |
dependency_cache_fragments | Structural suffixes naming an out-of-tree dependency cache the project is not an ancestor of ("/registry/src/" for cargo, "/pkg/mod/" for go). These route: a query anchored here is served by the live workspace for the language instead of rooting at the dependency. Write the structural suffix, not a home-anchored prefix — "/registry/src/" survives a relocated CARGO_HOME where "/.cargo/registry/" would not |
Validate the new entry before booting an MCP client against it:
pharos --print-language-config fennel # resolved merged config
pharos --doctor # probes binary + reports any issue
pharos warm fennel # optional: spawn the LSP once to confirm initialize handshake
Multi-server routing (e.g. attaching a linter alongside the main
LSP) uses the same [[languages.<id>.servers]] block with method
scoping — see Multi-server languages
for the rules.
Troubleshooting
Orphan LSP children after a hard kill
If pharos is killed via SIGKILL, OOM, host shutdown, or a crash,
the LSP children it spawned may outlive it for seconds-to-minutes
before they notice the pipe is gone. Pharos tracks every LSP it
spawns under ~/.local/share/pharos/instances/<pharos-pid>/. To
reap:
pharos --cleanup # dry-run: lists orphan instance dirs + their LSP children
pharos --cleanup --yes # actually reap
It signals each recorded LSP's whole process group, so what an LSP started (a build it was running) goes too. Each record carries the LSP's start time, and a pid that now belongs to a different process is never signalled; records from before 0.2.2 carry none, so their processes are left alone and only the record is removed. A daemon also does this by itself when it starts, for pharos processes that died without stopping, and reaps an LSP's group whenever it stops one (ADR-037).
Wrong answers for queries anchored inside a dependency
Symptoms, all appearing only for calls anchored on a file inside
node_modules/, site-packages/, a cargo registry checkout, or the
Go module cache:
find_referenceson a library symbol returns a small result set confined to the dependency's own files, and zero project hits.get_diagnosticsreports parse errors that make no sense for the file — for TypeScript, JSX errors like'>' expectedorCannot find name 'div'.- The LSP reports the file as belonging to no project (tsserver:
No Project).
Cause. Pharos picks the workspace root by walking up from the file
and stopping at the first directory containing any configured
root_markers entry. Dependencies ship marker files of their own —
node_modules/@types/react/package.json is a package.json — so a
query anchored inside a dependency roots a second, separate LSP
session at the dependency directory, whose project graph is that one
file. Answers from it are plausible but scoped to nothing.
Follow goto_definition into a dependency and the next call anchored
there hits this.
find_references detects the case and appends a second content block
naming the root that answered — if you see a note mentioning a
dependency directory, the result set is not evidence about your
project. Other tools do not yet report it.
Mitigation. Where the dependency satisfies a secondary marker,
drop it in pharos.toml. root_markers replaces the default list
rather than merging, so restate the ones you want to keep:
[languages.typescript]
root_markers = ["tsconfig.json", "jsconfig.json"] # drops package.json
The cost is real: pure-JS projects whose only root marker is a
package.json stop rooting at all. Make this per-repo via
./.pharos.toml rather than globally if you work on both kinds.
This mitigation does not help Rust or Go, where the dependency
satisfies the language's primary marker (Cargo.toml, go.mod) and
there is nothing droppable. For those two, pharos instead routes a
query anchored inside the shared dependency cache (registry/src under
CARGO_HOME, pkg/mod under GOPATH) to the already-running project
session for that language, whose analysis graph includes the dependency
sources. Two residues remain, both falling back to today's
root-at-the-dependency behaviour (flagged by the note above, never a
hard error): the first call of a session has no project session to
route to yet, and so does any call while two or more workspaces for the
language are live, since pharos cannot tell which one owns the file.
One caveat that survives everything above: for a symbol declared by
a dependency, some language servers deliberately scope
find_references to the dependency's own files no matter how the
query is routed or anchored. A small result set for a library symbol
is not evidence it is unused in your project — a project-wide text
search is the reliable count.
Both the warning and the routing read per-language config, so an
ecosystem pharos does not bundle a list for — or one whose cache you
have relocated somewhere unusual — can be taught about it with
vendor_segments / dependency_cache_fragments; see Adding your own
language.
Reading dependency sources is unaffected — hover, goto_definition,
and fetch_uri_contents on a dependency file all work. The defect is
only in which session serves follow-up queries anchored there. Tracked
in ADR-032.
Cold-start latency on first MCP call
The first call to a tool that needs rust-analyzer / jdtls / metals can take 30-90 s while the LSP indexes the project. Two mitigations:
# Per-project: pre-warm once before launching the MCP client
cd /path/to/project
pharos warm --all
# Direct mode only: warm on every spawn
PHAROS_MODE=direct PHAROS_WARM_LANGS=rust,go,typescript pharos
Under the shared daemon, a warm language server stays warm for every
later session until it idles out (PHAROS_LSP_IDLE_SECS), so after the
first session the cold start is usually already paid.
Where are my logs?
In ~/.local/state/pharos/log/ ($XDG_STATE_HOME/pharos/log/ when
that is set):
daemon-<build>-<key>-<pid>.log— the shared daemon's log, every session it serves included;daemon-<build>-<key>.boot.logholds what the daemon printed while starting.session-<pid>-<YYYY-MM-DD-HHMMSS>.log— one per direct-mode session.fallbacks.log— each time a session couldn't reach the daemon and ran in direct mode instead (pharos --doctorshows the last few).
Daemon and session logs are LRU-rotated to keep the 10 most recent of
each. Override with
PHAROS_LOG_FILE. Versions before 0.2.0 wrote to
~/.cache/pharos/log/.
A stable-path ~/.local/state/pharos/log/last-crash.log always points
at the most recent crash dump (if any) — useful in incident reports.
The directory is 0700 and crash files are 0600: a dump holds
process state, environment included.
Pharos boot panic on closed stderr
If a parent process closes pharos's stderr (2>/dev/null patterns,
some MCP clients during teardown), older versions could panic before
main ran and write erl_crash.dump in cwd. Fixed via
ADR-030 — pharos installs a try/catch-wrapped logger handler that
silently drops events when fd 2 is gone. If you see a crash dump,
file an issue; the dump itself goes to ~/.local/state/pharos/log/, not
cwd.
Updating
pharos self update # installed by install.sh (0.2.1 and later)
npm install -g pharos-mcp@latest # installed by npm
# pharos 0.2.0, which has no `self` yet: run install.sh again
curl -fsSL https://github.com/LoganBresnahan/pharos-mcp/releases/latest/download/install.sh | sh
pharos --doctor # verify
pharos self prune # once, after upgrading from 0.1.x
Sessions already running keep their daemon (the old version) until they
end; it exits when idle, and a later pharos self prune (or update)
removes its files. New sessions start the new version's daemon.
Uninstalling
pharos daemon stop --all # ends every pharos session on this machine
pharos self prune # pharos 0.1.x unpacks, if any
pharos self uninstall # if installed by install.sh
npm uninstall -g pharos-mcp # if installed via npm
rm -rf ~/.local/share/pharos/ # instance tracking
rm -rf ~/.local/state/pharos/ # logs + crash dumps
rm -rf ~/.cache/pharos/ # logs from before 0.2.0
rm -rf ~/.config/pharos/ # user config (only if you want it gone)
Architecture
Pharos is a Gleam application running on the Erlang/OTP 28 BEAM, behind a small native front end that starts or joins a shared daemon (ADR-034) and ships per platform as an unpacked release (ADR-035). Key design choices live in doc/adr/:
| ADR | Topic |
|---|---|
| 001 | Gleam over Elixir |
| 002 | pollux for JSON-RPC |
| 004 | npm optional-deps + GitHub Releases |
| 013 | Supervisor tree shape |
| 017 | Stdio transport actor |
| 019 | Multi-server method routing |
| 021 | Timeout resolution |
| 024 | LSP readiness probe |
| 029 | jdt:// / jar:// virtual URIs |
| 030 | Boot / shutdown / cleanup hardening |
| 034 | Shared daemon + native front end |
| 035 | Per-target releases, install.sh, npm without a resident node |
| 036 | pharos self update / rollback / prune / uninstall |
Top-level supervision tree at runtime (per ADR-013/017):
pharos_root (one_for_one)
├─ log_subtree (rest_for_one)
│ ├─ ring_keeper (permanent)
│ └─ log_writer (permanent)
├─ pool_subtree (rest_for_one)
│ ├─ pool_actor (permanent)
│ └─ lsp_dyn_sup (permanent)
├─ sessions_actor (permanent) ◄── HTTP / Both transport
├─ http_listener_subtree (permanent) ◄── HTTP / Both transport
└─ stdio_worker (transient) ◄── Stdio / Both transport
The shared daemon runs the same tree with one daemon actor (a Unix
socket listener, one connection process per session) in place of the
transport children.
Full prose architecture overview at doc/architecture.md.
pharos is one of three tools built to work together, with geex (an editor that keeps a record of who changed what) and captAInHook (hooks on an agent's turn). How they connect (the disk as the meeting point, MCP as the only protocol between them, one shared pool of language servers) is written down in geex's doc/stack.md. Each repo's own decisions stay in its own ADRs.
Development
Requires Erlang/OTP 28.1.1, Elixir 1.19.5, Gleam 1.17, rebar3 3.27+,
and Rust (stable, for the native front end in shim/). Pinned versions in
.tool-versions — asdf install resolves all of
them.
mix archive.install --force github LoganBresnahan/mix_gleam # one-time
mix deps.get
mix compile
mix gleam.test
To run pharos against a real MCP client without rebuilding the binary, use the dev wrapper:
{
"mcpServers": {
"pharos": { "command": "/abs/path/to/pharos-mcp/bin/pharos-dev" }
}
}
bin/pharos-dev compiles silently (all output to stderr) and boots
Erlang directly so it picks up edits without a release build.
For a release binary:
MIX_ENV=prod mix release # this machine's target: _build/package/pharos-<vsn>-<os>-<arch>.tar.gz
It builds for the machine it runs on (cargo builds the front end), and
_build/prod/rel/pharos/bin/pharos runs it in place. Release builds
use the OTP that rel/build-runtime.sh builds,
one runner per target; with another OTP the native check only prints
notes.
The crash-repro suite at bench/crash-repro/run-all.sh exercises six lifecycle failure modes and is gating for release tags. Run it before pushing a tag:
MIX_ENV=prod mix release --overwrite
bench/crash-repro/run-all.sh
See CONTRIBUTING.md for the full PR flow, including DCO sign-off.
License
Apache License 2.0 © 2026 Logan Bresnahan. Use, modify, embed, and redistribute pharos freely — including inside closed-source and commercial products — provided you retain the license and attribution notices. The license carries an express patent grant.
Contributions are accepted under the same license via a
Developer Certificate of Origin sign-off (git commit -s);
see CONTRIBUTING.md.