You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84Lines changed: 84 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -330,6 +330,90 @@ Remote debugger has several limitations compared to local debugger:
330
330
331
331
ElixirLS debug adapter interprets modules with [`:int.ni/1`](https://www.erlang.org/doc/apps/debugger/int.html#ni/1) on all connected nodes. It attempts to uninterpret all modules on debug session end but that may not be possible due to loss of connectivity. This may affect production workloads. Use remote debugging with caution.
332
332
333
+
## MCP (Model Context Protocol) Server
334
+
335
+
ElixirLS includes a built-in MCP server that enables Large Language Models (LLMs) like Claude to interact with Elixir codebases through a standardized protocol. The MCP server provides tools for code intelligence, documentation retrieval, dependency analysis, and more.
336
+
337
+
### Overview
338
+
339
+
The MCP server exposes several tools that allow LLMs to:
340
+
341
+
-**Find definitions**: Locate and retrieve source code for modules, functions, types, and macros
342
+
-**Get environment info**: Analyze code context including aliases, imports, variables in scope, and module attributes
343
+
-**Retrieve documentation**: Access comprehensive documentation for modules, functions, types, and callbacks
344
+
-**Analyze dependencies**: Examine module dependency relationships and impact analysis
345
+
-**Find implementations**: Discover concrete implementations of behaviours, protocols, and callbacks
346
+
-**Get type information**: Extract type definitions, specs, and Dialyzer contracts
347
+
348
+
### Available MCP Tools
349
+
350
+
#### `find_definition`
351
+
Find and retrieve the source code definition of Elixir/Erlang symbols including modules, functions, types, and macros. Returns the actual source code with file location.
352
+
353
+
**Parameters:**
354
+
-`symbol`: The symbol to find (e.g., `MyModule`, `MyModule.function/2`, `:gen_server`, `String.split/2`)
355
+
356
+
#### `get_environment`
357
+
Get comprehensive environment information at a specific code location including current module/function context, available aliases, imports, requires, variables in scope with types, module attributes, implemented behaviours, and definitions in the file.
358
+
359
+
**Parameters:**
360
+
-`location`: Location in the code to analyze (e.g., `file.ex:line:column`, `lib/my_module.ex:25:10`)
361
+
362
+
#### `get_docs`
363
+
Aggregate and return comprehensive documentation for multiple Elixir modules, functions, types, callbacks, or attributes in a single request.
364
+
365
+
**Parameters:**
366
+
-`modules`: Array of symbols to get documentation for (e.g., `["Enum", "String.split/2", "GenServer.handle_call"]`)
367
+
368
+
#### `get_type_info`
369
+
Extract comprehensive type information from Elixir modules including @type definitions, @spec annotations, @callback specifications, and Dialyzer inferred contracts.
370
+
371
+
**Parameters:**
372
+
-`module`: The module name to analyze (e.g., `GenServer`, `MyApp.MyModule`, `:gen_server`)
373
+
374
+
#### `find_implementations`
375
+
Find all implementations of Elixir behaviours, protocols, callbacks, and delegated functions across the codebase.
376
+
377
+
**Parameters:**
378
+
-`symbol`: The symbol to find implementations for (e.g., `GenServer`, `Enumerable`, `GenServer.handle_call`)
379
+
380
+
#### `get_module_dependencies`
381
+
Analyze comprehensive module dependency relationships including direct/reverse dependencies, transitive dependencies, compile-time vs runtime dependencies, imports, aliases, requires, function calls, and struct expansions.
382
+
383
+
**Parameters:**
384
+
-`module`: The module name to analyze dependencies for (e.g., `MyApp.MyModule`, `GenServer`, `:gen_server`)
385
+
386
+
### Setup and Configuration
387
+
388
+
#### TCP-to-STDIO Bridge
389
+
390
+
ElixirLS includes a TCP-to-STDIO bridge script located at `scripts/tcp_to_stdio_bridge.exs`. This bridge enables LLMs like Claude to communicate with the ElixirLS MCP server by converting between STDIO (used by LLMs) and TCP (used by the MCP server).
391
+
392
+
The bridge:
393
+
- Connects to the ElixirLS MCP server running on TCP port 3798
394
+
- Forwards messages bidirectionally between STDIO and TCP
395
+
- Uses binary mode with latin1 encoding for proper communication
396
+
- Handles connection lifecycle and error conditions
397
+
398
+
#### MCP Configuration Example
399
+
400
+
To use ElixirLS with Claude Code or other MCP-compatible tools, create an `mcp.json` configuration file:
Replace `/absolute/path/to/elixir-ls/` with the actual path to your ElixirLS installation.
416
+
333
417
## Automatic builds and error reporting
334
418
335
419
ElixirLS provides automatic builds and error reporting. By default, builds are triggered automatically when files are saved, but you can also enable "autosave" in your IDE to trigger builds as you type. If you prefer to disable automatic builds, you can set the `elixirLS.autoBuild` configuration option to `false`.
0 commit comments