吕内特·麦克普塞
一个最小的MCP(模型上下文协议)服务器,演示了通过SSE传输进行Tavily网络搜索,该服务器基于 吕内 框架。
为什么是Lunet?
MCP服务器通常部署为sidecar进程或资源受限的环境中。该实施优先考虑:
- 占地面积最小 -7 MB运行时内存,而Node/Bun/Python为14-28 MB
- 图像尺寸小 -171 MB Docker镜像与367-420 MB的替代品
- 稳定的依赖关系 -libuv和LuaJIT是成熟的、经过实战测试的库,支持Debian LTS
- 无依赖关系变动 -没有npm/pip生态系统开销或持续的安全补丁
性能比较
跑 ./compare.sh 为了重现这些基准:
| 实现 | Docker镜像 | 运行时内存 |
|---|---|---|
| 吕内特·麦克普塞 | 171 MB | 7 MB |
| tavily mcp(Node.js) | 420 MB | 18 MB |
| 大容量微控制器 | 382 MB | 14 MB |
| FastMCP(Python) | 367 MB | 28 MB |
lunet mcp sse使用 内存减少2.5倍 与Node.js相比, 减少2倍 比本,以及 减少4倍 比Python。
特性
- MCP 2024-11-05 协议支持
- SSE运输 用于实时通信
- 塔维利搜索 整合
- 内存效率高 (Docker中约7 MB RSS,约2 MB原生RSS)
- 零成本追踪 用于调试(禁用时无开销)
- 跨平台 二进制文件(Linux amd64/arm64、macOS arm64、Windows amd64)
下载
预构建的二进制文件可从以下网址获得 GitHub发布:
| 平台 | 存档 |
|---|---|
| Linux(amd64) | lunet-mcp-sse-linux-amd64.tar.gz |
| Linux(arm64) | lunet-mcp-sse-linux-arm64.tar.gz |
| macOS(arm64) | lunet-mcp-sse-macos.tar.gz |
| Windows(amd64) | lunet-mcp-sse-windows-amd64.zip |
跑步
macOS(arm64)```bash
Download and extract
curl -L -o lunet-mcp-sse-macos.tar.gz \
https://github.com/lua-lunet/lunet-mcp-sse/releases/download/nightly/lunet-mcp-sse-macos.tar.gz
tar -xzf lunet-mcp-sse-macos.tar.gz
Set up API key
echo "TAVILY_API_KEY=your_key_here" > .env
Run
./run.sh
### Linux(Debian/Ubuntu)```bash
# Install dependencies
sudo apt-get update
sudo apt-get install -y libuv1 libluajit-5.1-2 curl
# Download and extract (use arm64 or amd64 as appropriate)
curl -L -o lunet-mcp-sse-linux-arm64.tar.gz \
https://github.com/lua-lunet/lunet-mcp-sse/releases/download/nightly/lunet-mcp-sse-linux-arm64.tar.gz
tar -xzf lunet-mcp-sse-linux-arm64.tar.gz
# Set up API key
echo "TAVILY_API_KEY=your_key_here" > .env
# Run
./run.sh
Windows(amd64)```powershell
Download and extract the zip from GitHub releases
Then in the extracted directory:
Set up API key
echo TAVILY_API_KEY=your_key_here > .env
Run
.\run.bat
## 使用Docker进行测试
您可以在Docker容器中运行Linux二进制文件。这对于在macOS或其他平台上进行测试非常有用。```bash
# Start a container with the binary mounted
docker run -d --name mcp-server -p 8080:8080 \
-v /path/to/extracted/linux-app:/app -w /app \
debian:trixie-slim \
/bin/bash -c 'apt-get update -qq && apt-get install -y -qq libuv1 libluajit-5.1-2 curl >/dev/null 2>&1 && export $(cat .env | xargs) && HOST=0.0.0.0 ./bin/lunet --dangerously-skip-loopback-restriction app/main.lua'
# Test
curl http://localhost:8080/
# Stop
docker stop mcp-server && docker rm mcp-server
macOS与Colima
在macOS上,使用 大肠杆菌 要运行Linux arm64容器:```bash
Start Colima
colima start
Download and extract the Linux arm64 build
curl -L -o lunet-mcp-sse-linux-arm64.tar.gz \
https://github.com/lua-lunet/lunet-mcp-sse/releases/download/nightly/lunet-mcp-sse-linux-arm64.tar.gz
mkdir -p linux-app
tar -xzf lunet-mcp-sse-linux-arm64.tar.gz -C linux-app
Copy into Colima VM
colima ssh -- mkdir -p /tmp/testapp
tar -czf - -C linux-app . | colima ssh -- tar -xzf - -C /tmp/testapp
Copy your .env
echo "TAVILY_API_KEY=your_key_here" | colima ssh -- tee /tmp/testapp/.env
Run the server
docker run -d --name mcp-server -p 8080:8080 \
-v /tmp/testapp:/app -w /app \
debian:trixie-slim \
/bin/bash -c 'apt-get update -qq && apt-get install -y -qq libuv1 libluajit-5.1-2 curl >/dev/null 2>&1 && export $(cat .env | xargs) && HOST=0.0.0.0 ./bin/lunet --dangerously-skip-loopback-restriction app/main.lua'
Test from macOS
curl http://localhost:8080/
./test_tavily.sh
Cleanup
docker stop mcp-server && docker rm mcp-server
colima stop
## 端点
|方法|路径|描述|
|--------|------|-------------|
|得到| `/` |服务器信息(JSON)|
|得到| `/sse` |SSE流(创建会话)|
|职位| `/message?session=` |发送JSON-RPC消息|
## 测试```bash
# Check server info
curl http://localhost:8080/
# Run Tavily search test
./test_tavily.sh
# Connect to SSE stream manually
curl -N http://localhost:8080/sse
MCP协议流
- 客户GET
/sse建立SSE连接 - 服务器发送
endpoint具有会话ID的事件 - 客户端POST JSON-RPC消息到
/message?session= - 服务器通过GET连接上的SSE事件进行响应
此存储库中没有HTTPS终止支持。
如果你想经营一家面向公众的MCP SSE,你可以轻而易举
将此代码与nginx一起部署为私有云上的sidecar else
云负载均衡器后面的网络。这就是Unix管道方式
专业工具之间的数据。它为您提供了“QMail安全模型”
其中交易协议攻击与任何
商业逻辑。
可用工具
艰难的搜索
使用Tavily AI搜索引擎搜索网络。```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "tavily-search",
"arguments": {
"query": "latest AI news",
"max_results": 5
}
}
}
## 环境变量
|变量|默认值|描述|
|----------|---------|-------------|
| `TAVILY_API_KEY` |-|Tavily API密钥(必需)|
| `PORT` |8080 |服务器端口|
| `HOST` |127.0.0.1 |绑定地址(Docker使用0.0.0.0)|
| `MCP_TRACE` |off |跟踪级别(关闭/错误/警告/信息/调试/跟踪)|
| `MCP_TRACE_FILE` |stderr |跟踪输出文件|
## 从源头构建
需要 xmake 以及Lunet v0.1.2+。看 XMAKE_INTEGRATION.md 查看规范集成指南。```bash
# Clone the lua-lunet org repos (lunet-mcp-sse requires sibling lunet repo)
mkdir lua-lunet && cd lua-lunet
git clone https://github.com/lua-lunet/lunet.git
git clone https://github.com/lua-lunet/lunet-mcp-sse.git
# Build lunet with xmake (canonical release profile)
cd lunet
xmake f -m release --lunet_trace=n --lunet_verbose_trace=n -y
xmake build
xmake build lunet-sqlite3
cd ..
# Run
cd lunet-mcp-sse
echo "TAVILY_API_KEY=your_key_here" > .env
make run
零成本追踪
该服务器包括一个零成本跟踪系统,该系统具有 禁用时无开销.```bash
No tracing (production, zero overhead)
./run.sh
Verbose startup - show server banner
./run.sh -v
or: ./run.sh --verbose
Info level - see sessions and tool calls
MCP_TRACE=info ./run.sh
Debug level - see HTTP requests and MCP methods
MCP_TRACE=debug ./run.sh
## 基准测试
将内存和映像大小与其他MCP实现进行比较:```bash
./compare.sh
该测试针对:
tavily-mcp(Node.js通过npx)tavily-mcp(Bun)- FastMCP(Python)
许可证
麻省理工学院
