Code your agent checks with language servers

Your agent asks the project's language servers what is wrong in a file, where a name is defined and where it's used, instead of searching the text. Ask it to fix the errors in your Rust crate, or to find everything that calls a function before it renames it, and it asks rust-analyzer, as an editor would.

lnk agent start               # Link Harness, with code once a server is here
lnk agent tool list           # code, the project language servers

Ask it about a file

Ask it "what's wrong in work/app/src/main.rs?" and it calls code__diagnostics, which starts rust-analyzer in the crate, unless it runs there already, and answers with each error and its line.

What it needs

You need the agents plugins, which lnk up agents installs and which bring Link Code, and Link Harness. Your agent gets code at its start when a language server it may run is on your computer. Nothing costs anything: the servers run on your computer.

The servers

Link knows five, and gives your agent each one your computer has. Each is named by its language, as the spec's [tool.code.servers] names it.

rust

rust-analyzer, for .rs files, its project's root the folder holding Cargo.toml, its builds run with cargo and rustc.

go

gopls, for .go files, its project's root the folder holding go.mod, its builds run with go.

python

pyright-langserver --stdio, for .py and .pyi files, its project's root the folder holding pyproject.toml, setup.py or pyrightconfig.json.

typescript

typescript-language-server --stdio, for .ts, .tsx, .js, .jsx, .mjs and .cjs files, its project's root the folder holding tsconfig.json, jsconfig.json or package.json.

c

clangd, for .c, .h, .cc, .cpp, .cxx, .hpp and .hh files, its project's root the folder holding compile_commands.json or CMakeLists.txt.

Found on the PATH

A server is found on the system's PATH, as run's programs are, and only if your agent's sandbox file's [commands] allows it. Link's file allows these five, and the builds they run (cargo, rustc, go).

A server in your home folder

A server installed in your home folder (rustup's rust-analyzer, say) is used when you name it by path, in [commands] and in your agent's spec, and its sandbox file reads your home ([files] read = ["~"]).

Change one, or add a language

Change one, or add a language, in your agent's spec. Each key is its own: a spec that names only command keeps Link's files and roots.

# ~/.lnk/agents/main/spec.toml
[tool.code.servers.rust]
command = ["/home/me/.cargo/bin/rust-analyzer"]

[tool.code.servers.zig]
command = ["zls"]
files = ["zig"]
roots = ["build.zig"]

Turn one off

command = [] turns a language off. Two languages can't serve one extension: a spec that gives one extension to two is refused, naming both.

How your agent calls it

Your agent sees three tools. Each answers path:line:column: and the line, lines and columns counted from 1.

code__diagnostics

A file's errors and warnings, each with its line; without a file, every problem the servers started so far report.

code__definition and code__references

code__definition gives where a name is defined: its file, line and column, or its symbol (helper). code__references gives every place a name is used, its definition with them, found the same way.

When a server starts

A server starts the first time a file of its language is asked about, in the nearest folder above the file holding one of its root files, else the files folder; a project with two roots gets a server each. Each stays while your agent's session with the tool does, and sees a file as it is on disk when it's asked about.

How long a call waits

A call waits on its server at most [tool.code] timeout (your agent's [tools] timeout, 5 minutes), a tenth less: diagnostics wait until the server is quiet, and say so when the time ran out first.

Each server in a sandbox

A language server runs the project's code: build scripts, macros, plugins. So each runs as run runs a command, in a sandbox made from your agent's sandbox file: it reads the files folder, writes only the folders its [files] lets it write, starts only the programs of its [commands], and reaches no network. The tool reads only files in the files folder, and shows a line only from there, whatever a server names.

More about it

Agents Security has the guarantees and gaps. To work on its code, see Developing Link Code, and when your agent has no code or a server doesn't answer, Troubleshooting.

Docs

  • Developing: lnk-link-code is Link Code: an MCP server over stdio that asks a project's language servers for diagnostics, definitions and references, each server in a sandbox
  • Decisions: Why code asks language servers, and why each runs in a sandbox with no network
  • Troubleshooting: What to do when your agent has no code, or a language server doesn't start or answer (Link Code)