Packages

MCP server exposing live Elixir runtime introspection tools to AI agents.

Current section

Files

Jump to
extools lib extools.ex
Raw

lib/extools.ex

defmodule Extools do
@moduledoc """
MCP server exposing live Elixir runtime introspection tools to AI agents.
## Dual mode
**Phoenix** — add one line to your endpoint (dev only):
# lib/my_app_web/endpoint.ex
if Mix.env() == :dev do
plug Extools
end
The MCP endpoint is served at `http://localhost:4000/extools/mcp`.
Requests to any other path pass through untouched.
**Non-Phoenix** — configure a port and the application starts a
standalone Bandit server:
# config/dev.exs
config :extools, port: 4040
The MCP endpoint is served at `http://localhost:4040/extools/mcp`.
"""
@behaviour Plug
alias Hermes.Server.Transport.StreamableHTTP.Plug, as: MCPPlug
@mcp_path "/extools/mcp"
@impl Plug
def init(opts) do
MCPPlug.init(Keyword.merge([server: Extools.MCPServer], opts))
end
@impl Plug
def call(%Plug.Conn{request_path: path} = conn, mcp_opts) do
if path == @mcp_path or String.starts_with?(path, @mcp_path <> "/") do
MCPPlug.call(conn, mcp_opts)
else
conn
end
end
end