自定义MCP客户端
我从API层开始,从零创建了一个MCP客户端,没有使用Claude的MCP库,这可能看起来有些反模式,但这仍然是值得的。学习MCP的底层工作原理。
主要原因是我正在构建一个MCP代理,我遇到了RuntimeError:尝试在与进入时不同的任务中退出取消范围。
在断开服务器连接时出现这个问题。
因此,我在GitHub上寻找解决方案,但不幸的是,没有一个有效。不过我想自己构建它,所以我开发了MCP-Client。
https://github.com/Jeomon/MCP-Client
查看原文
I created an MCP Client from scratch from the API layer, without using the MCP library from Claude, which might seem an anti-pattern, but it's still worth it. Learning how the MCP works under the hood.<p>The main reason is I'm building an MCP Agent, I'm getting RuntimeError: Attempted to exit cancel scope in a different task than it was entered in<p>While disconnecting the servers..<p>So looked for fixes from GitHub, but unfortunately none worked, but I wanted to build it, so I developed the MCP-Client.<p>https://github.com/Jeomon/MCP-Client