Merged
feat(mcp): mcp support macos #350
zhuyutong888Add on 29 days ago
feat(mcp): mcp support macos #350
Merged
Pull Request has been successfully merged by openJiuwen-bot.
(Thank you for zhuyutong888's contribution.)29 days ago Associated issue: [Feature] 增加 macOS 平台构建支持与 CI 覆盖,补齐跨平台能力短板
atomgit-bot
29 days ago Comments:
29 days ago Comments:
变更摘要
本 PR 为 MCP C++ SDK 增加 macOS 平台支持,核心思路是新增平台兼容层 platform_compat.h,将原先依赖 Linux 专有的线程 ID 获取、TCP keepalive 选项、线程命名及事件通知机制统一封装为跨平台接口。事件系统 EventSystem 改用抽象的通知通道 NotifyChannel(Linux 走 eventfd,macOS 走非阻塞 pipe 加软件计数器),并相应调整通知事件 ID 的记录与读取逻辑;构建、依赖安装与示例脚本也补充了 macOS 分支(sysctl、brew、dylib)。整体属于平台适配重构,不改变对外业务流程。
主要改动
- 新增平台兼容层
platform_compat.h: 提供GetThreadId、SetCurrentThreadName、SetKeepAliveIdle/Intvl/Cnt及通知通道NotifyChannel的CreateNotifyChannel/NotifyChannelNotify/NotifyChannelRead/CloseNotifyChannel等跨平台封装,按__linux__、__APPLE__分支给出不同实现。 - 事件通知机制抽象化:
EventSystem移除<sys/eventfd.h>、<fcntl.h>的直接依赖,CreateNotifyEventId、NotifyEventId、ReadEventFd、RemoveEventInternal及析构逻辑改为通过notifyChannel与平台封装完成创建、写入、读取和关闭,EventData新增notifyChannel字段。 ServerManager通知参数与重触发修正:NotifyEventArg新增并初始化eventId字段,Start中保存eventId,HandleQueueNotification由原先以fd调用NotifyEventId改为传入notifyEventArg->eventId。- 日志与网络代码迁移到兼容层:
mcp_log.h用McpGetCurrentThreadId()替换syscall(SYS_gettid),tcp_socket.cpp的 keepalive 设置改用Platform::SetKeepAliveIdle/Intvl/Cnt,thread_utils.h的线程命名委托给Platform::SetCurrentThreadName。 - 构建与依赖脚本适配 macOS:
ExampleCommon.cmake改用CMAKE_SHARED_LIBRARY_SUFFIX并设置BUILD_RPATH,build.sh在无nproc时回退sysctl -n hw.ncpu,install_deps.sh增加 macOS/Homebrew 依赖检查与安装分支,run_auth_example.sh按uname选择dylib/so扩展名。


Incorrect?
atomgit-bot
29 days ago Comments:
29 days ago Comments:
29 days ago Set YiyangShao,xinyu-jiuwen as approver
atomgit-bot
29 days ago Comments:
29 days ago Comments:
84 messages are collapsed here。 See more
maoqiming
20 days ago Comments:
20 days ago Comments:
/lgtm
/approve


20 days ago Added label: approvedlgtm-mingo007
openJiuwen-bot
20 days ago Comments:
20 days ago Comments:
20 days ago Merged pull request
20 days ago Removed label: ci-successful
Paired: GitHub #146 ↔ GitCode !350
What type of PR is this?
/kind
Self-checklist:(请自检,在[ ]内打上x,我们将检视你的完成情况,否则会导致pr无法合入)
Linked Closing Issues:
https://gitcode.com/openJiuwen/agent-protocol/issues/33
Linked Closing Issues: