Configuring gemini for erlang-mcp.
Summary:
Gemini CLI supports project-specific Model Context Protocol (MCP) server protocol, I've recently setup erlang-mcp. This document explains how to use erlmcp to aid in the development of your erlang code, not as an mcp tool for other mean.
Introduction
MCP's are the new hot thing for AI to interoperate with tooling running on either local or remote systems.
Most MCP's are things like reading files , writing files, executing programs, but you can use language-specific MCP's which allow the AI to verify its beliefs, executing with a real system immediately revealing syntax and hallucionations earlier in the progress, saving time and money.
Projects and System wide.
Gemini allows for MCP's to exist ia a 'per project' or 'system wide', This entry focuses on the 'per project' option,
Project setup:
As you would want to use MCP to write your erlang.
{deps, [
{erlmcp, {git, "https://github.com/erlsci/erlmcp.git", {branch, "main"}}}
]}.
Per Project
Create the .gemini directory: In the root directory of your project.
mkdir -p .gemini
Create a settings.json file, it may or may not already exist already:
This configuration 'stdin/stdout' as the communication mechanism between the gemini-cli and the erlang mcp. Gemini and the MCP standard allow for networked MCP servers however at this point its going to be local.
The "mcpServers" key for this json is a top level element in settings.json
{
"mcpServers": {
"erlang-mcp": {
"cwd": "/home/wmealing/Projects/erlmcp"
"env": {
"EMCP_DIR": "/home/wmealing/Prejects/erlmcp"
},
"command": "erl",
"args": [
"/home/wmealing/Projects/erlmcp/_build/simple/lib/erlmcp/ebin",
"/home/wmealing/Projects/erlmcp/_build/simple/lib/jesse/ebin",
"/home/wmealing/Projects/erlmcp/_build/simple/lib/jsx/ebin",
"-noshell",
"-eval",
"code:load_file(simple_server_stdio), simple_server_stdio:start()"]
}
}
}
- Note that this JSON commands are not executed in shell, things like wildcard matching or $VARiables in 'args' or 'command' do NOT work.
- Note if you have anything in the ~/.erlang file which creates output to stdout, you may need to work around this, you can do so by setting the "HOME" environment in the above example to a directory not containing the .erlang file.
If you need to use wildcard matching, you should make a shell script and wrap your MCP in this, or set up your requirements within the erlang code itself.
Wrapping MCP in shell script.
If you have a lot of setup to do around your project, it might be worthwhile wrapping your MCP in a shell script.
It is important that the shell script not output anything to stdout in the script. I'll show a demo if you want to use rebar as your erlang environment configuration.
#!env bash export ERL_FLAGS="-sname mynode -setcookie mycookie -noshell" rebar3 as simple shell --eval 'code:load_file(simple_server_stdio), simple_server_stdio:start()'
Conclusion
You likely already have of it or you wouldn't have come to this blog, I've given up trying to figure out why google wont index this, maybe it'll do it after I've already passed away. At the time of writing I can't find anything I've written on google.