关于 Elixir MCP Server
Elixir MCP Server 是使用 Elixir、Bandit 和 Plug 编写的基础 MCP 服务示例,面向学习或构建 Elixir 服务的开发者。它以 SSE 为传输方式,包含文件列表、回显和天气工具。
主要功能
- 01基于 Elixir 实现 MCP 服务
- 02使用 SSE 传输
- 03提供文件列表工具
- 04提供消息回显工具
- 05提供天气查询工具
适用场景
- 01学习 Elixir MCP 服务实现
- 02测试 SSE 客户端连接
- 03查询天气信息
- 04扩展示例并添加自定义工具
MCP 相关
该服务通过 SSE 向 MCP 客户端提供 `list_files`、`echo` 和 `get_weather` 工具。客户端使用 SSE 连接,并通过消息端点发送请求。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Elixir MCP 服务
使用 Elixir、Bandit 和 Plug 实现的 Elixir 版 Model Context Protocol(MCP)服务。
Model Context Protocol(MCP)是一种开放协议,可通过标准化的服务实现,让 AI 模型安全地与本地和远程资源交互。 本项目是一个使用 SSE(Server-Sent Events)作为传输协议的 MCP 服务基础示例。它基于 https://modelcontextprotocol.io/quickstart/server 中的示例。
前置条件
-
Elixir 1.18 或更高版本
-
Erlang/OTP 27 或更高版本
-
可通过
WEATHER_API_KEY环境变量设置天气 API 密钥。 默认服务使用 https://www.weatherapi.com/ 的免费套餐。
开始使用
-
安装依赖:
mix deps.get -
启动服务:
WEATHER_API_KEY="1234567890abcdef" mix run --no-halt -
The server will be available at:
- SSE endpoint: http://localhost:4000/sse
- Message endpoint: http://localhost:4000/message
Available Tools
list_files: List files in a directoryecho: Echo a message backget_weather: Get weather information
Testing with MCP Client
Install the NXP Inspector client and follow the instructions to connect to the server.
Make sure to use SSE (Server-Sent Events) as the transport protocol, then you should be able to list available tools and call them. Also to ping/keepalive the connection, you can use the ping tool.
Adding Custom Tools
To add custom tools, update the handle_initialize/2 function to include your tool definitions and implement corresponding handle_call_tool/3 clauses.
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。