Token导航 LogoToken导航TokenDH.com
Project Brainsurgeon logo
开发工具未说明官方级别未说明来源级核验

Project Brainsurgeon

MCP Server

Opencode Bridge事件转发器,用于捕获Opencode Bridge API的事件并将其转发到后台代理进行处理,同时包含一个带有自定义工具的MCP服务器。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
Python开发工具API集成

安装说明

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

作者 / 组织

cloudwarriors-ai

提供方

cloudwarriors-ai

最后核验

2026/5/17 20:20

快速接入

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

详细介绍

Opencode Bridge事件转发器

该项目提供了从OpencodeBridgeneneneba API捕获事件并将其转发到后台代理进行处理的脚本。它还包括一个MCP(模型上下文协议)服务器,为AI助手提供定制工具。

文件

  • event-forwarder.js -事件转发器的基本实现(ES模块版本)
  • opencode-event-forwarder.js -具有事件缓冲和重试逻辑的更完整的实现
  • opencode-api-integration.js -显示如何与OpencodeBridge API集成的示例
  • test-event-forwarder.js -验证事件转发功能的测试脚本
  • mcp_server.py -具有事件转发功能的Opencode Bridge MCP服务器
  • opencode.json -定义了事件转发器代理的Opencode配置文件
  • .env -网桥和事件转发器的环境变量
  • start-bridge-with-agent.sh -启动MCP服务器和模拟代理的脚本
  • MCP_TOOLS.md -Opencode Bridge MCP工具的综合文档

如何使用

先决条件

  • Node.js(建议使用v14或更高版本)
  • npm或纱线
  • 访问开放代码桥API

安装

  1. 克隆此存储库
  2. 安装依赖项:
npm install axios

配置

设置以下环境变量以配置事件转发器:

  • AGENT_ENDPOINT -代理API终结点的URL(默认值: http://localhost:3000/agent)

运行事件转发器

# Run the basic event forwarder
node event-forwarder.js

# Run the more complete event forwarder
node opencode-event-forwarder.js

# Run the Opencode Bridge with event forwarding
./start-bridge-with-agent.sh

测试

# Run the test script
node test-event-forwarder.js

开放代码集成

该项目已配置为通过以下方式使用Opencode opencode.json 配置文件:

{
  "mcp": {
    "opencode-bridge": {
      "type": "local",
      "command": ["bash", "-c", "cd /root/code/project-brainsurgeon && . venv/bin/activate && python mcp_server.py"],
      "enabled": true,
      "description": "Provides custom MCP tools for TUI interaction and enhanced file operations. Tools use prefix 'opencode-bridge_'. See MCP_TOOLS.md for complete documentation."
    },
    "event-forwarder": {
      "type": "local",
      "command": ["node", "/root/code/project-brainsurgeon/opencode-event-forwarder.js"],
      "enabled": true,
      "env": {
        "AGENT_ENDPOINT": "http://localhost:3000/agent"
      }
    }
  }
}

此配置:

  1. 运行Opencode Bridge MCP服务器
  2. 运行事件转发器代理,该代理侦听事件并将其转发到指定的端点

与Opencode Bridge API集成

与OpencodeBridge API的实际集成将取决于API的公开方式。在当前实现中,我们使用的占位符函数需要替换为实际的API调用。

在实际实现中,您将:

  1. 导入或初始化Opencode Bridge客户端
  2. 设置事件侦听器或轮询机制
  3. 将事件转发给您的代理

opencode-api-integration.js 有关如何实现这一点的更多详细信息。

开放代码桥MCP工具

opencode-bridge MCP服务器提供定制工具,人工智能助手可以使用这些工具与TUI交互并执行各种操作。这些工具使用前缀 opencode-bridge_.

有关综合文档,请参阅 MCP_TOOLS.md.

AI助手中的示例用法

以下是如何在AI助手中使用开源桥接工具的示例:

获得TUI课程

// Example: Get all TUI sessions
const sessions = await opencode-bridge_tui_get_sessions();
// Returns a list of all TUI sessions

读取和写入文件

// Example: Read a file
const fileContent = await opencode-bridge_read_file({
  filePath: "/path/to/file.txt"
});

// Example: Write to a file
await opencode-bridge_write_file({
  filePath: "/path/to/new-file.txt",
  content: "This is the file content"
});

搜索文件

// Example: Find all Python files
const pythonFiles = await opencode-bridge_glob_files({
  pattern: "**/*.py"
});

// Example: Search for text in files
const searchResults = await opencode-bridge_grep_search({
  pattern: "function getUser",
  include: "*.js"
});

管理待办事项列表

// Example: Create a todo list
await opencode-bridge_todowrite({
  todos: [
    {
      content: "Task 1", 
      status: "pending", 
      priority: "high", 
      id: "1"
    },
    {
      content: "Task 2", 
      status: "completed", 
      priority: "medium", 
      id: "2"
    }
  ]
});

// Example: Read the todo list
const todos = await opencode-bridge_todoread();

后台代理

事件转发器将事件转发到后台代理API。代理可以是任何接受带有JSON有效载荷的HTTP POST请求的服务。有效载荷格式为:

{
  "event": {
    "type": "event.type",
    "properties": {
      "timestamp": 1758551400574,
      "data": { ... }
    }
  }
}

或者对于批量事件:

{
  "events": [
    {
      "type": "event.type",
      "properties": { ... }
    },
    ...
  ]
}

发展

添加新功能

要向事件转发器添加新功能,请执行以下操作:

  1. 分叉此存储库
  2. 实施您的更改
  3. 添加测试
  4. 提交拉取请求

建筑

事件转发器使用简单的架构:

  1. 事件捕获-从Opencode Bridge API捕获事件
  2. 事件缓冲-缓冲事件以优化转发
  3. 事件转发-将事件转发到后台代理
  4. 错误处理-处理错误和重试失败的请求

添加新的MCP工具

要向Opencode Bridge MCP服务器添加新工具,请执行以下操作:

  1. 打开 mcp_server.py
  2. 使用添加新功能 @app.tool() 装饰器
  3. 实现工具的功能
  4. 使用以下命令重新启动MCP服务器 ./start_mcp_server.sh
  5. 更新 MCP_TOOLS.md 带有新工具的文档

目录标签

目录标签

Python开发工具API集成事件转发本地部署MCP服务器后台处理

接入字段

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

未说明

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

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

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

0

权限和风险

未说明none部署方式未说明

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

安装前确认

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

仍需确认:installCommand

来源信息

继续浏览同类 MCP