diff --git a/.vitepress/config.mts b/.vitepress/config.mts index d63fb78..5941a47 100644 --- a/.vitepress/config.mts +++ b/.vitepress/config.mts @@ -1,4 +1,3 @@ -import { defineConfig } from 'vitepress'; import lightbox from "vitepress-plugin-lightbox"; import { GitChangelog, GitChangelogMarkdownSection } from '@nolebase/vitepress-plugin-git-changelog/vite'; @@ -185,6 +184,7 @@ export default withMermaid({ { text: '调试 tools, resources 和 prompts', link: '/plugin-tutorial/usage/debug' }, { text: '连接大模型', link: '/plugin-tutorial/usage/connect-llm' }, { text: '用大模型测试您的 mcp', link: '/plugin-tutorial/usage/test-with-llm' }, + { text: '连接多个 MCP 服务器', link: '/plugin-tutorial/usage/multi-server' }, { text: '分发您的实验结果', link: '/plugin-tutorial/usage/distribute-result' }, { text: 'SSE 在线部署的鉴权器实现', link: '/plugin-tutorial/usage/sse-oauth2' }, ] diff --git a/plugin-tutorial/examples/mcp-examples.md b/plugin-tutorial/examples/mcp-examples.md index c5160c3..56f4714 100644 --- a/plugin-tutorial/examples/mcp-examples.md +++ b/plugin-tutorial/examples/mcp-examples.md @@ -11,6 +11,9 @@ next: - [python 实现进行通用表单填充 的 mcp (STDIO)](./python-form-stdio) - [python 实现基于 blender 的 mcp (STDIO)](./python-blender-stdio) - [python 实现 cadence EDA 的 mcp (STDIO)](./python-cadence-stdio) +- 基于 ffmpeg mcp 实现通过对话的视频剪辑 +- 基于 rag mcp 实现知识库的注入 +- 实现 Stable Diffusion 的 MCP 服务器 ## Nodejs - [typescript 实现基于 crawl4ai 的超级网页爬虫 mcp (STDIO)](./typescript-crawl4ai-stdio) diff --git a/plugin-tutorial/quick-start/first-mcp.md b/plugin-tutorial/quick-start/first-mcp.md index 683e6c0..9510068 100644 --- a/plugin-tutorial/quick-start/first-mcp.md +++ b/plugin-tutorial/quick-start/first-mcp.md @@ -104,6 +104,7 @@ def translate(message: str) -> str: 恭喜您,万事开头难,您已经完成了最难的 mcp 连接! +有关 openmcp 进行 mcp 服务器连接的更多信息,可以参考手册里面的这一章 [[connect-mcp|连接到 MCP 服务器]]。 ## 附录:关于 uv 启动 mcp 你必须知道的 diff --git a/plugin-tutorial/quick-start/images/openmcp-home.png b/plugin-tutorial/quick-start/images/openmcp-home.png new file mode 100644 index 0000000..26ac6cc Binary files /dev/null and b/plugin-tutorial/quick-start/images/openmcp-home.png differ diff --git a/plugin-tutorial/quick-start/images/resource-desc.png b/plugin-tutorial/quick-start/images/resource-desc.png new file mode 100644 index 0000000..279f10e Binary files /dev/null and b/plugin-tutorial/quick-start/images/resource-desc.png differ diff --git a/plugin-tutorial/quick-start/images/resource-result.png b/plugin-tutorial/quick-start/images/resource-result.png new file mode 100644 index 0000000..7cbbd76 Binary files /dev/null and b/plugin-tutorial/quick-start/images/resource-result.png differ diff --git a/plugin-tutorial/quick-start/images/tool-add-test-project.png b/plugin-tutorial/quick-start/images/tool-add-test-project.png new file mode 100644 index 0000000..e7d5f06 Binary files /dev/null and b/plugin-tutorial/quick-start/images/tool-add-test-project.png differ diff --git a/plugin-tutorial/quick-start/images/tool-desc.png b/plugin-tutorial/quick-start/images/tool-desc.png new file mode 100644 index 0000000..2d134d7 Binary files /dev/null and b/plugin-tutorial/quick-start/images/tool-desc.png differ diff --git a/plugin-tutorial/quick-start/images/tool-result.png b/plugin-tutorial/quick-start/images/tool-result.png new file mode 100644 index 0000000..d1bee87 Binary files /dev/null and b/plugin-tutorial/quick-start/images/tool-result.png differ diff --git a/plugin-tutorial/quick-start/quick-debug.md b/plugin-tutorial/quick-start/quick-debug.md index 45cbf58..5d4cf20 100644 --- a/plugin-tutorial/quick-start/quick-debug.md +++ b/plugin-tutorial/quick-start/quick-debug.md @@ -1,2 +1,49 @@ # 快速调试 MCP +在 [[first-mcp|你的第一个 MCP]] 中,我们成功创建了一个 MCP 服务器的最小实例,并且成功使用 openmcp 连接了这个服务器。 + +接下来,我们可以来调试这个服务器的功能了,毕竟,不是所有人都是 Jeaf Dean,都能一次就写对所有代码。我们写的 MCP 服务器也不总是一开始就自信满满可以上线的,它总是存在着一些我们无法发现的问题。试想一下,如果后面我们把 mcp 连接到大模型进行全链路调试时出了问题,这个时候你就会发现,可能出错的环节非常多:MCP 服务器的问题?大模型厂商的问题?OpenMCP 的问题?把可能的错误进行分类,然后逐一排查,才是符合工程直觉 (Engineering Instuition) 的做法。 + +## 认识面板 + +首次进入 openmcp 时,会进入一个面板,上面一共四个按钮,代表四种调试项目: + +![](./images/openmcp-home.png) + +我们现在需要确认的是 tool,resource 和 prompt 这三个功能是否运行正常,因为在实际项目中,tool 是使用得最多的项目,因此,我们先调试 tool。 + +## 调试 Tool + +为了调试 tool,我们点击面板上的 「工具」 按钮,进入 tool 调试界面。tool 面板的基本介绍如下所示 + +![](./images/tool-desc.png) + +调试工具,我们需要先在「工具列表」中选择一个工具(如果没有展开需要先展开工具列表,点击右侧的按钮可以刷新),然后在右侧的「参数填写和执行」中,填写需要测试的参数,点击运行,就能看到结果了: + +![](./images/tool-result.png) + +比如我们这边运算最简单的 2 + 2,可以看到结果是 4,这说明我们的 mcp 连接正常还可以正常返回结果。大家未来可以通过简单测试来验证 mcp 服务器的可用性,这在复杂 agent 系统的调试过程中非常重要。可以编码成自检程序的一部分。 + +## 添加测试项目 + +测试完成一个项目后,我们可以通过点击上方的 + 来添加额外的测试项目: + +![](./images/tool-add-test-project.png) + +这里,我们选择「资源」来进行资源项目的调试工作,「资源」和另外两个项目有点不一样,MCP 协议中的资源访问有两种类型 + +- resources/templates/list: 模板资源,带有访问参数,比如文件系统 mcp 中的文件访问,输入文件路径,根据资源协议返回文件内容。 +- resources/list:普通资源,不带访问参数,比如浏览器 mcp 中的 console,直接返回控制台的 stdio,这种就不需要参数。 + +![](./images/resource-desc.png) + + +`resources/templates/list` 的使用方法和之前的 tool 一样,填入参数点击运行就能看到资源结果 + +![](./images/resource-result.png) + +而 `resources/list` 由于没有参数,直接点击左侧的资源就能直接看到内部的数据。 + +## 总结 + +在这一章节中,我们主要介绍了如何使用 openmcp 来调试 MCP 服务器,包括如何调试 tool 和 resource,prompt 的方法和这两个类似,大家可以自行尝试。下一章中,我们将开启最激动人心的一章,我们将把开发的 mcp 服务器扔到大模型中进行测试,这样你才知道你写的 mcp 是不是真的好玩,是不是有价值。 diff --git a/plugin-tutorial/usage/connect-llm.md b/plugin-tutorial/usage/connect-llm.md index e69de29..042c846 100644 --- a/plugin-tutorial/usage/connect-llm.md +++ b/plugin-tutorial/usage/connect-llm.md @@ -0,0 +1 @@ +# 连接大模型 \ No newline at end of file diff --git a/plugin-tutorial/usage/debug.md b/plugin-tutorial/usage/debug.md index e69de29..eb9c93d 100644 --- a/plugin-tutorial/usage/debug.md +++ b/plugin-tutorial/usage/debug.md @@ -0,0 +1 @@ +# 调试 tools, resources 和 prompts \ No newline at end of file diff --git a/plugin-tutorial/usage/distribute-result.md b/plugin-tutorial/usage/distribute-result.md index e69de29..1c33557 100644 --- a/plugin-tutorial/usage/distribute-result.md +++ b/plugin-tutorial/usage/distribute-result.md @@ -0,0 +1 @@ +# 分发您的实验结果 \ No newline at end of file diff --git a/plugin-tutorial/usage/multi-server.md b/plugin-tutorial/usage/multi-server.md new file mode 100644 index 0000000..e33a94b --- /dev/null +++ b/plugin-tutorial/usage/multi-server.md @@ -0,0 +1 @@ +# 连接多个 MCP 服务器 \ No newline at end of file diff --git a/plugin-tutorial/usage/sse-oauth2.md b/plugin-tutorial/usage/sse-oauth2.md index e69de29..7fb85f4 100644 --- a/plugin-tutorial/usage/sse-oauth2.md +++ b/plugin-tutorial/usage/sse-oauth2.md @@ -0,0 +1 @@ +# SSE 在线部署的鉴权器实现 \ No newline at end of file diff --git a/plugin-tutorial/usage/test-with-llm.md b/plugin-tutorial/usage/test-with-llm.md index e69de29..99a3d36 100644 --- a/plugin-tutorial/usage/test-with-llm.md +++ b/plugin-tutorial/usage/test-with-llm.md @@ -0,0 +1 @@ +# 用大模型测试您的 mcp \ No newline at end of file diff --git a/plugin-tutorial/what-is-mcp.md b/plugin-tutorial/what-is-mcp.md index 2e2bdbc..8afe97d 100644 --- a/plugin-tutorial/what-is-mcp.md +++ b/plugin-tutorial/what-is-mcp.md @@ -1,9 +1,7 @@ -# MCP 简介 +# 什么是 MCP? ![](https://picx.zhimg.com/70/v2-1a2df8a081a76f4e90431d8a2445f495_1440w.avis) -## 什么是 MCP? - MCP (Model Context Protocol)是一种开放协议,用于标准化应用程序如何向大型语言模型(LLMs)提供上下文。可以将 MCP 想象为 AI 应用的 typec 接口。正如 typec 提供了一种标准化的方式将您的设备连接到各种外设和配件,MCP 也提供了一种标准化的方式,将 AI 模型连接到不同的数据源和工具。 MCP 协议由 Anthropic 在 2024 年 11 月底推出: @@ -19,7 +17,7 @@ MCP 协议由 Anthropic 在 2024 年 11 月底推出: ``` mermaid graph LR -a(chatbot\n > deepseek, chatgpt) --> b(composer\n > cursor, copilot) --> c(agent\n > AutoGPT, Manus, Open Manus) +a(chatbot > deepseek, chatgpt) --> b(composer > cursor, copilot) --> c(agent > AutoGPT, Manus, Open Manus) ``` - chatbot @@ -178,6 +176,6 @@ C2 --> A5 ## 开源生态 -和 LSP 一样,LSP 在开源社区有非常多的客户端和服务端框架,MCP 也是一样的,目前 Anthropic 开源了一套 MCP 的服务端框架:https://github.com/modelcontextprotocol/servers,想要探索大模型效用的朋友可以尽情去使用这个框架。 +和 LSP 一样,LSP 在开源社区有非常多的客户端和服务端框架,MCP 也是一样的,目前 Anthropic 开源了一套 MCP 的服务端框架:https://github.com/modelcontextprotocol/servers ,想要探索大模型效用的朋友可以尽情去使用这个框架。这个仓库还收录了很多的官方认可的 MCP 服务器,可以作为学习的参考。 除此之外,pulsemcp 上也有很多开源社区开发的 MCP 客户端和服务端:https://www.pulsemcp.com/clients \ No newline at end of file