elixir_mcp_server
An example of how to implement an MCP server using Elixir and SSE transport
claude mcp add --transport stdio epinault-elixir_mcp_server mix run --no-halt \ --env WEATHER_API_KEY="your_weather_api_key_here"
How to use
This MCP server is an Elixir implementation of the Model Context Protocol (MCP). It exposes an SSE-based transport for server-sent events and a message endpoint to interact with a set of built-in tools. The available tools include list_files to enumerate directory contents, echo to return a message, and get_weather to fetch weather information using the weather API key provided via WEATHER_API_KEY. To use the server, run it and connect a compliant MCP client (e.g., the MCP Inspector) via the SSE transport to discover and call the tools. The server exposes two endpoints: /sse for streaming tool capabilities and /message for direct tool invocation and responses.
How to install
Prerequisites:
- Elixir 1.18 or higher
- Erlang/OTP 27 or higher
Installation steps:
-
Install dependencies
mix deps.get -
Set required environment variables (example):
WEATHER_API_KEY="your_weather_api_key_here" mix run --no-halt -
Start the server
WEATHER_API_KEY="your_weather_api_key_here" mix run --no-halt -
Verify endpoints are accessible:
- SSE endpoint: http://localhost:4000/sse
- Message endpoint: http://localhost:4000/message
Note: Ensure your WEATHER_API_KEY is valid for the configured weather service (default is WeatherAPI).
Additional notes
Tips: The WEATHER_API_KEY environment variable is required for the get_weather tool. If you modify or add tools, update handle_initialize/2 accordingly and implement corresponding handle_call_tool/3 clauses. If you experience port or endpoint issues, verify your firewall settings and ensure the application binds to the default port 4000. Common issues include missing dependencies or an invalid API key for the weather service. You can test tools via the MCP Inspector client by selecting SSE as the transport and then listing and invoking available tools. If you need to customize tools, you can extend the tool definitions in the Elixir server code and reload.
Related MCP Servers
hermes
Elixir Model Context Protocol (MCP) SDK
anubis
Elixir Model Context Protocol (MCP) SDK (hermes-mcp fork)
MCPhoenix
A simplified implementation of the Model Context Protocol (MCP) server using Elixir's Phoenix Framework.
vancouver
Simple MCP server library for Elixir.
excom
EXCOM is an MCP server for Elixir