Token导航 LogoToken导航TokenDH.com
beam MCP logo
AI代理未说明官方级别未说明来源级核验

beam MCP

MCP Server

一个Elixir项目,桥接模型上下文协议(MCP)与Erlang分布式C节点,使MCP客户端能够与远程Erlang节点上的服务交互。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
AI代理工作流自动化模型集成

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

V-Sekai-fire

提供方

V-Sekai-fire

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

Erlang节点的BeamMCP-MCP桥

一个Elixir项目,将模型上下文协议(MCP)与Erlang分布式cnode连接起来,使MCP客户端能够与远程Erlang节点上运行的服务进行交互。

特性

  • MCP C节点集成:使用分布式Erlang cnodes桥接MCP协议
  • 工具调用:将MCP客户端的工具调用转发到远程cnodes
  • 资源管理:从远程cnode服务中读取资源
  • 异步RPC通信:使用Erlang RPC进行节点间通信
  • 综合测试:带有Mox模拟框架的完整测试套件
  • 前MCP集成:基于最新的ex_mcp主分支构建

项目结构

beam-mcp/
├── lib/
│   └── beam_mcp/
│       ├── application.ex              # OTP Application entrypoint
│       ├── cnode_bridge.ex             # Main bridge interface
│       ├── cnode_handler.ex            # Behaviour for cnode handlers
│       └── cnode_bridge/
│           ├── server.ex               # GenServer managing bridge
│           └── supervisor.ex           # Supervision tree
├── test/
│   ├── test_helper.exs                 # Test setup with Mox
│   └── beam_mcp/
│       └── cnode_bridge_test.exs       # Bridge tests
├── mix.exs                             # Project configuration
└── README.md                           # This file

安装

先决条件

  • Elixir 1.14或更高版本
  • Erlang/OTP 25或更高版本

设置

  1. 克隆存储库:
git clone https://github.com/V-Sekai-fire/beam-mcp.git
cd beam-mcp
  1. 安装依赖项:
mix deps.get
  1. 编译:
mix compile
  1. 运行测试:
mix test

用法

架设通往节点的桥梁

# Start the bridge with connection details
{:ok, bridge_info} = BeamMcp.CnodeBridge.start_bridge(
  cnode_name: "my_cnode",
  cookie: "secret_erlang_cookie",
  cnode_host: "localhost",
  mcp_name: "my_bridge",
  tools: [
    %{name: "tool1", description: "First tool"},
    %{name: "tool2", description: "Second tool"}
  ],
  resources: [
    %{uri: "file://data", description: "Data resource"}
  ]
)

通过桥梁调用工具

# Call a tool on the remote cnode
{:ok, result} = BeamMcp.CnodeBridge.call_tool("my_bridge", "tool_name", %{
  arg1: "value1",
  arg2: "value2"
})

列出可用工具

# Get tools from the remote cnode
{:ok, tools} = BeamMcp.CnodeBridge.list_tools("my_bridge")

Enum.each(tools, fn tool ->
  IO.puts("Tool: #{tool["name"]}")
  IO.puts("Description: #{tool["description"]}")
end)

阅读资源

# Read a resource from the remote cnode
{:ok, content} = BeamMcp.CnodeBridge.read_resource("my_bridge", "file://data/resource.txt")

IO.puts(content)

停止桥

# Stop the bridge
BeamMcp.CnodeBridge.stop_bridge(bridge_info)

实现Cnode处理程序

在您的遥控器上,执行 BeamMcp.CnodeHandler 行为:

defmodule MyApp.CnodeHandler do
  @behaviour BeamMcp.CnodeHandler

  @impl true
  def handle_mcp_request(:list_tools) do
    [
      %{
        "name" => "my_tool",
        "description" => "A sample tool",
        "inputSchema" => %{
          "type" => "object",
          "properties" => %{
            "param" => %{"type" => "string"}
          }
        }
      }
    ]
  end

  @impl true
  def handle_mcp_request({:call_tool, "my_tool", %{"param" => value}}) do
    %{
      "content" => [
        %{
          "type" => "text",
          "text" => "Processed: #{value}"
        }
      ]
    }
  end

  @impl true
  def handle_mcp_request({:read_resource, uri}) do
    case uri do
      "file://data" -> %{"content" => "Resource content"}
      _ -> {:error, "Resource not found"}
    end
  end
end

测试

该项目包括使用Mox模拟框架的全面测试:

# Run all tests
mix test

# Run tests with verbose output
mix test -v

# Run specific test file
mix test test/beam_mcp/cnode_bridge_test.exs

测试结构

测试组织在 test/beam_mcp/cnode_bridge_test.exs 并涵盖:

  • 使用必需/可选参数进行网桥初始化
  • 工具调用功能
  • 工具列表
  • 资源阅读
  • 不可用cnode的错误处理

依赖项

  • ex_mcp (~>0.6.0):模型上下文协议实现
  • 莫克斯 (~>1.2):用于测试的模拟库

mix.exs 查看完整的依赖关系列表。

建筑

关键组件

  1. BeamMcp。应用:OTP应用程序监督树
  2. BeamMcp。CnodeBridge:桥梁运营的主要API
  3. BeamMcp。CnodeBridge。服务器:GenServer管理单个网桥实例
  4. BeamMcp。CnodeBridge。主管:网桥服务器的监督树
  5. BeamMcp。CnodeHandler:cnode请求处理程序的行为模块

通信流

MCP Client
    ↓
ExMCP.Client/Server
    ↓
BeamMcp.CnodeBridge (API)
    ↓
BeamMcp.CnodeBridge.Server (GenServer)
    ↓
:rpc.call() (Erlang RPC)
    ↓
Remote Cnode
    ↓
CnodeHandler (user-implemented)

配置

除了标准的Mix项目设置外,不需要额外的配置。

许可证

MIT许可证-有关详细信息,请参阅许可证文件

贡献

欢迎投稿!拜托:

  1. 分叉存储库
  2. 创建要素分支
  3. 提交您的更改
  4. 推到分支
  5. 创建拉取请求

参考文献

目录标签

目录标签

AI代理工作流自动化模型集成Elixir本地部署Erlang分布式MCP协议Elixir项目远程服务交互工具调用

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明session部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP