Phoenix route introspection for Ectomancer.
This module requires Plug to be available at runtime for route execution.
Summary
Functions
Builds a tool name from a route.
Exposes Phoenix routes as MCP tools.
Filters routes based on options.
Extracts routes from a Phoenix router module.
Parses a Phoenix route path and extracts parameters.
Functions
Builds a tool name from a route.
Exposes Phoenix routes as MCP tools.
Authorization
Mutating routes (POST, PUT, PATCH, DELETE, and catch-all *) require
effective authorization. At compile time expose_routes/2 raises if a mutating
route is exposed without an :authorize option and without an explicit public
opt-out (authorize: :none/:public). Authorization inherited from
use Ectomancer, authorize: ... satisfies the guard. Read-only (GET) routes
are always allowed; restrict exposure to them with methods: ["GET"].
expose_routes MyAppWeb.Router, authorize: fn actor, _action -> actor.role == :admin end
# Explicit public opt-in (mutating routes allowed)
expose_routes MyAppWeb.Router, authorize: :noneOptions
:only- Only expose matching paths:except- Skip matching paths:methods- Only expose matching HTTP methods:namespace- Prefix tool names with a namespace:authorize- Authorization handler (function, policy module, or:none/:public)
@spec filter_routes( [{String.t(), String.t(), module(), atom()}], keyword() ) :: [{String.t(), String.t(), module(), atom()}]
Filters routes based on options.
Extracts routes from a Phoenix router module.
Parses a Phoenix route path and extracts parameters.