PJUllrich
EMCP - A Model Context Protocol (MCP) Server for Elixir
Hey folks!
I built (yet another) MCP server implementation in Elixir yesterday: EMCP
I wanted to have something super simple that I can easily maintain and bugfix. It uses the official modelcontextprotocol/ruby-sdk library as inspiration and runs in a Plug, so it reuses Bandit’s/Cowboy’s connection handling for keeping the SSE connections alive (I think that’s the same way AnubisMCP, LiveView, and WebSockets do it)
Feedback is very welcome! I’m using this in production, but haven’t load tested it yet.
Most Liked
PJUllrich
PJUllrich
Release v0.3.1 and v0.3.2
I added three new configuration options to the StreamableHTTP plug:
allowed_origins + validate_origin- This allows you to restrict MCP calls to certain domains. CLI clients don’t send the
Originheader though, so shouldn’t be affected.
- This allows you to restrict MCP calls to certain domains. CLI clients don’t send the
recreate_missing_session- EMCP recreates expired or unknown sessions by default. This is a trade-off to UX which I’ve motivated further in the Readme. It is not spec-compliant though, so if you want to run in “strict” mode and reject unknown sessions or force clients to re-initialize a session if it expires, you can now do so by adding
recreate_missing_session: falseto yourplug.
- EMCP recreates expired or unknown sessions by default. This is a trade-off to UX which I’ve motivated further in the Readme. It is not spec-compliant though, so if you want to run in “strict” mode and reject unknown sessions or force clients to re-initialize a session if it expires, you can now do so by adding
See the Changelog here
https://github.com/PJUllrich/emcp/blob/main/CHANGELOG.md
And documentation of these configurations here
https://github.com/PJUllrich/emcp?tab=readme-ov-file#origin-validation
engineeringdept
This is great! Thanks for building it. It’s a much nicer, simpler implementation than other libraries I’ve seen and looks like it will be easy to extend and maintain. A couple of thoughts for feedback:
- A pluggable session store would be great - many Elixir deployments can’t use clustering, so can’t rely on ETS.
- It would be nice to have all the config for the server in its own module, rather than global config. This would allow multiple MCP servers to coexist, for example. Perhaps it could use the Ecto Repo pattern of
use EMCP.Server, tools: [...]?
(I might even get a chance to submit a PR for these…)
Popular in Announcing
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








