Erlang implementation of the Model Context Protocol (MCP) SDK
Overview
Erlang implementation of the Model Context Protocol (MCP) SDK. MCP enables seamless communication between AI assistants and local services through a standardized protocol. This SDK provides both client and server implementations with full OTP compliance, allowing you to build robust, fault-tolerant integrations that expose resources, tools, and prompts to AI systems. See the examples directory for comprehensive examples: - - Full MCP server with resources, tools, and subscriptions - - Sophisticated client with connection management - - OTP application with supervision - Architecture Overview - System design and components - Protocol Guide - MCP protocol implementation details - OTP Patterns - Erlang/OTP best practices used - API Reference - Complete API documentation - ✅ Full MCP protocol support (resources, tools, prompts) - ✅ OTP-compliant with supervision trees - ✅ Multiple transport layers (stdio, TCP, HTTP) - ✅ JSON Schema validation for tools - ✅ Resource subscriptions with...
README
erlmcp
Erlang implementation of the Model Context Protocol (MCP) SDK.
MCP enables seamless communication between AI assistants and local services through a standardized protocol. This SDK provides both client and server implementations with full OTP compliance, allowing you to build robust, fault-tolerant integrations that expose resources, tools, and prompts to AI systems.
Installation
Requirements: Erlang/OTP 25 or later
%% rebar.config
{deps, [
{erlmcp, "0.5.1"}
]}.
rebar3 compile
Quick Start
Creating an MCP Server
%% Start a server that exposes resources
{ok, Server} = erlmcp_server:start_link({stdio, []}, Capabilities),
%% Add a resource
erlmcp_server:add_resource(Server, >,
fun(_Uri) -> > end),
%% Add a tool with JSON Schema validation
Schema = #{> => >,
> => #{> => #{> => >}}},
erlmcp_server:add_tool_with_schema(Server, >,
fun(#{> := Name}) ->
>
end, Schema).
Creating an MCP Client
%% Connect to an MCP server
{ok, Client} = erlmcp_client:start_link({stdio, []}, #{strict_mode => false}),
%% Initialize connection
{ok, _} = erlmcp_client:initialize(Client, Capabilities),
%% List available resources
{ok, #{> := Resources}} = erlmcp_client:list_resources(Client),
%% Call a tool
{ok, Result} = erlmcp_client:call_tool(Client, >,
#{> => >}).
Examples
See the examples directory for comprehensive examples:
- Weather Server - Full MCP server with resources, tools, and subscriptions
- Calculator Client - Sophisticated client with connection management
- Complete Application - OTP application with supervision
Documentation
- Architecture Overview - System design and components
- Protocol Guide - MCP protocol implementation details
- OTP Patterns - Erlang/OTP best practices used
- API Reference - Complete API documentation
Key Features
- ✅ Full MCP protocol support (resources, tools, prompts)
- ✅ OTP-compliant with supervision trees
- ✅ Multiple transport layers (stdio, TCP, HTTP)
- ✅ JSON Schema validation for tools
- ✅ Resource subscriptions with notifications
- ✅ Automatic reconnection with backoff
- ✅ Comprehensive error handling
- ✅ Production-ready logging and monitoring
License
Apache 2.0
External Resources
Install
This server does not publish a one-line install command.
Open the repository installation guide