update self-check & mook

This commit is contained in:
锦恢 2025-07-16 00:04:02 +08:00
parent c20cfa99f0
commit 22378bc57c
27 changed files with 217 additions and 34 deletions

View File

@ -1,37 +1,53 @@
# デバッグ tools、resources、prompts
# MCP 基本デバッグ
## 基本デバッグ
[[quick-debug.md|クイックデバッグ]]では、mcpのデバッグ方法について簡単に説明しました。この章では、openmcpにおけるデバッグモジュールの特徴と高度な機能に焦点を当てます。
## タブ
openmcpはタブをデバッグ項目の最小単位としており、ナビゲーションバーの+をクリックすると新しいタブを作成できます。OpenMCPのtools、resources、promptsの基本的な使用方法はInspectorとほぼ同じですが、OpenMCPは自動的に左側のリソースリストの初期化を行います。Inspectorではこの手順を手動で行う必要があります。
openmcpはタブをデバッグプロジェクトの最小単位としており、バーの+をクリックすると新しいタブを作成できます。OpenMCPのtools、resources、promptsの基本使用はInspectorとほぼ同じですが、OpenMCPは自動的に左側のリソースリストを初期化します。Inspectorではこの手順を手動で行う必要があります。
## デバッグ内容の自動保存
openmcpにはテスト結果を自動保存する機能があります。以下の動作が発生すると、openmcpはタブとその内容を保存します
- タブを作成し、有効なデバッグ項目を選択した場合
- デバッグページでデバッグ操作(ツールの選択、ツールの実行、大規模モデルへの質問など)を行った場合
- タブを作成し、有効なデバッグプロジェクトを選択する
- デバッグページでデバッグ操作を行う(ツールの選択、ツールの実行、大規模モデルへの質問など)
現在のmcpプロジェクトのテストデータは`.openmcp/tabs.{server-name}.json`に保存されます。ここで`{server-name}`はmcpサーバーが正常に接続されたサーバー名です。
:::warning
注意同じプロジェクト内で名前が完全に同じmcpサーバーを2つ持つべきではありません。これにより`.openmcp/tabs.{server-name}.json`の接続情報保存に競合が発生し、未知のエラーが発生する可能性があります。
注意:同じプロジェクト内で名前が完全に同じmcpサーバーバーを2つ持つべきではありません。これにより`.openmcp/tabs.{server-name}.json`の接続情報保存が衝突し、未知のエラーが発生する可能性があります。
:::
## クイックデバッグ
## インタラクティブテストでの迅速な再現
デバッグプロセス中に、大規模モデルの回答が不十分で、これが特定のツールのエラーによるものである場合、問題がツールにあるかどうかを迅速に特定するために、下部の小さな飛行機アイコンをクリックできます。
デバッグプロセスでは、大規模モデルの回答が不十分で、これがあるツールのエラーによるものである場合が避けられません。問題がツールにあるかどうかを迅速に特定するために、下部の小さな飛行機アイコンをクリックできます。
![](./images/llm-fast-debug.png)
クリックすると、OpenMCPは新しいテストツールプロジェクトを作成し、大規模モデルが使用したパラメータを自動的に右側のフォームに入します:
クリックすると、OpenMCPは新しいテストtoolプロジェクトを作成し、当時大規模モデルが使用したパラメータを自動的に右側のフォームに入します:
![](./images/llm-fast-debug-result.png)
あなたがするべきことは、実行をクリックしてエラーオプションを確認または除外することだけです。
あなたがする必要があるのは、実行をクリックしてエラーオプションを確認または排除することだけです。
## Mookデータ
一連のmcp toolの応答を迅速にテストするために、mook data機能を提供しています。これにより、mcp toolのschemaに基づいて使用可能なパラメータのセットを迅速に生成し、mcp toolの機能をテストできます。
2種類のmook方法を提供しています。1つ目はmookボタンで、クリックすると実際の意味はないがフォームを埋めることができるmookデータが自動生成されます。下図の`mook`ボタンがこの機能のトリガーポイントです。
![](./images/common-mook.png)
また、AI mook機能も提供しており、AIを使用してmookデータを生成できます。このデータはより現実的で信頼性がありますが、まず[[connect-llm|大規模モデルの接続]]で大規模モデルを設定する必要があります。下図の`AI`ボタンがこの機能のトリガーポイントで、mookデータを生成するpromptをカスタマイズすることもできます。
![](./images/ai-mook.png)
## pydanticサポート
Pythonのfastmcpを使用してtoolを作成する際、インターフェースのタイプを宣言する方法は2つあります。1つはPythonのデフォルトのtypingライブラリを使用して複雑なデータ構造を宣言する方法、もう1つはpydanticを使用して複雑な変数を宣言する方法です。以下は例です
pythonのfastmcpを使用してtoolを作成する場合、インターフェースのタイプを宣言する方法は2つあります。1つはpythonのデフォルトtypingライブラリを使用して複雑なデータ構造を宣言する方法、もう1つはpydanticを使用して複雑な変数を宣言する方法です。以下は例です
```python
from mcp.server.fastmcp import FastMCP
@ -54,14 +70,14 @@ def test(
return [test1, test2, test3, params]
```
これら2種類の宣言方法に対して内部変換を実装しているため、openmcpはどちらもサポートしています。特に、宣言した変数がオブジェクト上記の`PathParams`など)の場合、openmcpのtoolデバッグウィンドウは「オブジェクト入力ボックス」を生成します。この入力ボックスは基本的な形式チェックとオートコンプリートをサポートします
これら2種類の宣言方法に対して内部変換を実装しているため、openmcpはどちらもサポートしています。特に、宣言した変数がオブジェクトである場合(上記の`PathParams`など、openmcpのtoolデバッグウィンドウは「オブジェクト入力ボックス」を生成します。この入力ボックスは基本的な形式チェックとオートコンプリートをサポートしています:
![](./images/object-input.png)
:::info オブジェクトとは?
ここでの「オブジェクト」はJavaScriptの概念で、シリアライズ可能なデータ型の中で基本データ型を除いた部分を指します。例えば{ "name": "helloworld" }はオブジェクトです。Pythonでは、オブジェクトはdictやnamedTupleに似ています。
ここでの「オブジェクト」はjavascriptの概念で、シリアライズ可能なデータタイプの中で基本データタイプを除いた部分を指します。例えば{ "name": "helloworld" }はオブジェクトです。オブジェクトはpythonではdictやnamedTupleに似ています。
:::
:::warning
openmcpは可能な限り多くのケースをサポートしていますが、生産環境ではmcp toolのパラメータをオブジェクトとして定義することは推奨しません。シンプルなデータ型として定義することで、大規模モデルがツールを呼び出す際の安定性を向上させることができます。
openmcpは可能な限り多くの状況をサポートしていますが、生産環境ではmcp toolのパラメータをオブジェクトとして定義することは推奨しません。シンプルなデータタイプとして定義することで、大規模モデルがツールを呼び出す際の安定性をより高めることができます。
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -0,0 +1,46 @@
# MCPツール自己診断プログラム
デバッグ機能では、mookを使用してmcpツールのテストを補助する以外に、現在すべてのツールに対して迅速にクローズドループテストを行う方法があります。これはMCPサーバー開発の初期段階で非常に役立ちます。
MCPサーバーの開発を実践する場合、初めてプログラムを作成し、「インタラクティブテスト」に進む前に、自己診断プログラムを使用してインタラクティブテストで発生する可能性のある問題を回避することを強くお勧めします。
MCPツール自己診断プログラムの概要は、この動画で確認できます[OpenMCP 0.1.9 更新ログ | MCPツール自己診断 & カスタムトポロジーソートをサポート](https://www.youtube.com/watch?v=QoAhHv1IAuw)
## 基本的な使い方
「ツール」テストプロジェクトを作成後、下図の1の位置にあるボタンをクリックすると自己診断プログラムに入ります。
![](./images/click-self-check.png)
## 実行順序の定義 | プリセット
自動診断プログラムでは、テスト順序を定義する必要があります。これにより、自己診断プログラムは設定したテスト順序後で実行トポロジーと呼びますに従って自動実行します。これは、ほとんどの場合、MCPサーバーのツールには一定の依存関係があるためです。例えば、PPTを作成するMCPを開発した場合、「ページを追加」というツールは「PPTを作成」というツールの後に実行する必要があります。
提供されている2つのプリセットを使用して、実行トポロジーを迅速に設定できます。下図の1の場所に示されています
![](./images/preset-self-check.png)
最初のプリセットはシリアル実行を表し、宣言された順序に従ってMCPツールを1つずつ実行します。
2番目のプリセットは並列実行を表し、すべてのMCPツール間にトポロジー依存関係がなく、並列実行されます。
## 実行順序の定義 | クリック操作
高度にカスタマイズされたトポロジー依存関係が必要な場合は、以下の簡単な操作で実現できます:
1. ードAをクリックし、別のードBを選択すると、AからBへの接続を作成できます
2. AからBへの接続線をクリックすると、AからBへの接続を切断できます
これら2つの自由度の操作により、カスタム実行トポロジーを簡単に作成できます。
特筆すべきは、合法な操作を行うたびに、右下隅に次の実行ヒントが表示されることです:
![](./images/self-define-self-check.png)
## 自己診断プログラムの実行
自己診断プログラムを開始するには、クリックして実行します。ただし、先に[[connect-llm|大規模モデルの接続]]で大規模モデルを設定する必要があります。
テストが完了すると、テスト結果とパフォーマンス評価が表示されます。
![](./images/self-check-result.png)

View File

@ -1,40 +1,53 @@
# Debugging Tools, Resources, and Prompts
# MCP Basic Debugging
## Basic Debugging
In [[quick-debug.md|Quick Debugging]], we briefly introduced how to debug MCP. This chapter focuses on some features and advanced functionalities of the debugging module in OpenMCP.
## Tabs
OpenMCP uses tabs as the smallest unit for debugging items. Click the "+" button in the navigation bar to create a new tab. The basic usage of Tools, Resources, and Prompts in OpenMCP is similar to the Inspector, but OpenMCP automatically initializes the resource list on the left—a step that requires manual effort in the Inspector.
OpenMCP uses tabs as the smallest unit for debugging projects. Click the + in the toolbar to create a new tab. The basic usage of OpenMCP's tools, resources, and prompts is similar to the Inspector, but OpenMCP automatically initializes the resource list on the left, whereas this step requires manual completion in the Inspector.
## Auto-Saving Debug Content
OpenMCP features automatic saving of test results. The following actions will trigger OpenMCP to save the tab and its contents:
- Creating a tab and selecting a valid debugging item.
- Performing debugging actions on the debug page (selecting tools, executing tools, querying the large model, etc.).
- Creating a tab and selecting a valid debugging project
- Performing debugging actions on the debugging page (selecting tools, executing tools, querying large models, etc.)
The test data for the current MCP project is saved in `.openmcp/tabs.{server-name}.json`, where `{server-name}` corresponds to the successfully connected server's name.
The test data for the current MCP project is saved in `.openmcp/tabs.{server-name}.json`, where `{server-name}` is the name of the successfully connected MCP server.
:::warning
Note: Within the same project, you should not have two MCP servers with identical names. This will cause conflicts in the `.openmcp/tabs.{server-name}.json` connection information storage, leading to undefined errors.
Note: Within the same project, you should not have two MCP servers with identical names. This will cause connection information storage conflicts in `.openmcp/tabs.{server-name}.json`, leading to unknown errors.
:::
## Quick Debugging
## Quick Reproduction in Interactive Testing
During debugging, it's common for the large model to provide unsatisfactory responses due to tool errors. To quickly identify whether a tool is the culprit, click the small airplane icon at the bottom:
During debugging, it's inevitable that the large model may provide unsatisfactory answers due to a tool error. To quickly determine whether the issue lies with the tool, you can click the small airplane icon below.
![](./images/llm-fast-debug.png)
After clicking, OpenMCP will create a new test tool project and automatically populate the form on the right with the parameters the large model used:
After clicking, OpenMCP will create a new test tool project and automatically fill the form on the right with the parameters used by the large model at that time:
![](./images/llm-fast-debug-result.png)
All you need to do is click "Run" to confirm or rule out a potential error.
All you need to do is click "Run" to confirm or rule out an error.
## Mock Data
To quickly test the response of a set of MCP tools, we provide a mock data feature. It allows you to quickly generate usable parameters based on the MCP tool's schema to test the tool's functionality.
We offer two mock methods. The first is the mock button, which automatically generates mock data with no practical meaning but can fill the form. The `mock` button in the image below triggers this function.
![](./images/common-mook.png)
We also provide an AI mock feature, which uses AI to generate mock data. This data is more realistic and reliable, but you need to configure your large model in [[connect-llm|Connect Large Model]] first. The `AI` button in the image below triggers this function, and you can also customize the prompt for generating mock data.
![](./images/ai-mook.png)
## Pydantic Support
When creating tools using Python's `fastmcp`, you have two ways to declare interface types:
1. Using Python's built-in `typing` library for complex data structures.
2. Using `pydantic` to define complex variables. Here's an example:
When creating tools using Python's FastMCP, you have two methods to declare interface types. One is using Python's default typing library to declare complex data structures, and the other is using Pydantic to declare complex variables. Here's an example:
```python
from mcp.server.fastmcp import FastMCP
@ -47,7 +60,7 @@ class PathParams(BaseModel):
start: str
end: str
@mcp.tool(name="test", description="Test tool")
@mcp.tool(name="test",description="Used for testing")
def test(
params: PathParams,
test1: str,
@ -57,14 +70,14 @@ def test(
return [test1, test2, test3, params]
```
Since we've implemented internal conversion for both declaration methods, OpenMCP supports both. Notably, if you declare a variable as an object (e.g., `PathParams` above), OpenMCP's tool debug window will generate an "Object Input Field" with basic format validation and auto-completion:
Since we have implemented internal conversion for these two declaration methods, OpenMCP supports both. Notably, if the declared variable is an object, such as `PathParams` above, OpenMCP's tool debugging window will generate an "object input box," which supports basic format checks and auto-completion:
![](./images/object-input.png)
:::info What is an "object"?
Here, an "object" refers to the JavaScript concept—serializable data types excluding primitives. For example, `{ "name": "helloworld" }` is an object. In Python, this is more akin to a `dict` or `namedTuple`.
:::info What is an object?
Here, an "object" is a concept in JavaScript, referring to the part of serializable data types that excludes basic data types. For example, { "name": "helloworld" } is an object. In Python, objects are more similar to dicts or namedTuples.
:::
:::warning
Although OpenMCP supports most use cases, we still recommend avoiding object-type parameters for MCP tools in production. Using simple data types improves the stability of tool calls by the large model.
Although OpenMCP supports as many scenarios as possible, in production environments, we still do not recommend defining MCP tool parameters as objects. Defining them as simple data types can also improve the stability of large models when making tool calls.
:::

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -0,0 +1,46 @@
# MCP Tool Self-Check Procedure
In the debugging features, besides using mook to assist with MCP tool testing, there is another method to quickly perform a closed-loop test on all current tools. This is particularly useful during the early stages of MCP server development.
If you plan to practice MCP server development, after writing the initial program and before entering the "interactive testing" phase, we strongly recommend using the self-check procedure to avoid potential issues during interactive testing.
For an overview of the MCP tool self-check procedure, you can watch this video: [OpenMCP 0.1.9 Update Log: Supports self-checking of MCP tools & Custom topology sorting](https://www.youtube.com/watch?v=QoAhHv1IAuw)
## Basic Usage
After creating a "Tool" test project, click the button at position 1 in the image below to enter the self-check procedure.
![](./images/click-self-check.png)
## Defining Execution Order | Presets
For the automatic detection procedure, it's necessary to define the testing order. This way, the self-check procedure will execute automatically based on the order you set (referred to as the execution topology). This is because, in most cases, your MCP server tools have certain dependencies. For example, if you develop an MCP for creating a PPT, the "Add a Slide" tool must be executed after the "Create PPT" tool.
You can quickly set up your execution topology using the two presets we provide, as shown at position 1 in the image below:
![](./images/preset-self-check.png)
The first preset represents serial execution, where your MCP tools are executed one after another in the declared order.
The second preset represents parallel execution, where all MCP tools have no topological dependencies and will execute in parallel.
## Defining Execution Order | Clicking
For highly customized topological dependencies, you can achieve this through the following simple operations:
1. Click on node A, then select another node B to create a connection from A to B.
2. Click on the connection line between A and B to disconnect the link from A to B.
With these two degrees of freedom, you can easily create a custom execution topology.
It's worth noting that any valid operation you perform will trigger a prompt in the bottom-right corner indicating the next step:
![](./images/self-define-self-check.png)
## Executing the Self-Check Procedure
Click to start the self-check procedure, but remember to first configure your large model in [[connect-llm|Connect Large Model]].
After testing is complete, the test results and performance evaluation will be displayed.
![](./images/self-check-result.png)

View File

@ -1,4 +1,8 @@
# 调试 tools, resources 和 prompts
# MCP 基础调试
## 基本调试
在 [[quick-debug.md|快速调试]] 中,已经简单介绍过如何调试 mcp 了。本章节着重介绍openmcp 中,调试模块的一些特性和高级功能。
## 标签页
@ -17,7 +21,7 @@ openmcp 具备自动保存测试结果的功能。如下的行为会触发 openm
注意,同一个项目中,你不应该有两个名字完全相同的 mcp 服务器,这会导致 `.openmcp/tabs.{server-name}.json` 连接信息存储冲突,发生未知错误。
:::
## 快速调试
## 交互测试中快速复现
在我们调试的过程中,难免会出现大模型回答得不好,而且这是因为某个工具出错导致的,为了快速定位是不是工具的问题,可以点击下方的小飞机图标
@ -29,6 +33,18 @@ openmcp 具备自动保存测试结果的功能。如下的行为会触发 openm
你要做的,只是点击运行来确定或者排除一个错误选项。
## Mook 数据
为了快速测试一组 mcp tool 的响应,我们提供了 mook data 功能,它允许你快速根据 mcp tool 的 schema 来生成一组可用的参数,从而测试 mcp tool 的功能。
我们提供了两种 mook 方法,第一种就是 mook 按钮,点击后就会自动生成没有实际意义,但是可以填充表单的 mook 数据。下图的 `mook` 按钮就是改功能的触发点。
![](./images/common-mook.png)
我们还提供了 ai mook 功能,可以用 AI 来生成 mook 的数据,这个数据更加真实可靠,但是你需要先在 [[connect-llm|连接大模型]] 中配置好你的大模型。下图的 `AI` 按钮就是改功能的触发点,你还可以自定义生成 mook 数据的 prompt。
![](./images/ai-mook.png)
## pydantic 支持
使用 python 的 fastmcp 进行 tool 的创建时,你有两种方法来申明接口的类型,一种是通过 python 默认的 typing 库来申明复杂数据结构,或者通过 pydantic 来申明一个复杂的变量,下面是一个例子:

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@ -0,0 +1,46 @@
# MCP 工具自检程序
在调试功能中,除了使用 mook 来辅助您进行 mcp tool 的测试外,还有一种方法可以快速对当前所有的 tool 做一次闭环测试,这在 mcp 服务器开发初期会非常有用。
如果您打算实践一次 mcp 服务器的开发,在第一次编写好程序,并准备进入 「交互测试」 之前,我们都强烈推荐您使用自检程序来规避交互测试中可能遇到的问题。
MCP 工具自检程序的概览,可以查看这个视频: [OpenMCP 0.1.9 更新日志 | 支持 MCP 工具自检 & 自定义拓扑排序](https://www.bilibili.com/video/BV1YpGHzcEs4/?spm_id_from=333.1387.homepage.video_card.click&vd_source=3f248073d6ebdb61308992901b606f24)
## 基本使用
创建「工具」测试项目后,点击下图中 1 的位置的按钮即可进入自检程序。
![](./images/click-self-check.png)
## 定义执行顺序 | 预设
对于自动检测程序,您有必要来定义测试顺序,这样,自检程序才会根据你设置的测试顺序(我们后面会称为执行拓扑)来自动执行。这么做是因为大部分情况下,你的 mcp 服务器的工具往往存在一定的依赖关系,比如我们开发了一个创建 ppt 的 mcp那么「添加一页」这个工具一定需要在「创建 ppt」这个工具之后执行。
你可以通过我们提供的两组预设来快速布置你的执行拓扑,如下图 1 的地方所示:
![](./images/preset-self-check.png)
第一个预设代表串行执行,它会按照申明的顺序把你的 mcp 工具一个接着一个执行。
第二个预设代表并行执行,它会让所有的 mcp 工具之间不存在任何拓扑依赖,这样就会并行执行。
## 定义执行顺序 | 点击
需要高度自定义拓扑依赖,可以通过下面的简单操作来实现:
1. 点击一个节点 A然后选中另一个节点 B可以创建 A 到 B 的连接
2. 点击 A 到 B 之间的连接线,可以断开 A 到 B 的连接
通过这两个自由度的操作,你就可以轻松创建自定义的执行拓扑。
值得一提的是,你的任何合法操作,我们都会在右下角给出下一步的执行提示:
![](./images/self-define-self-check.png)
## 执行自检程序
点击开启自检程序,然后就可以进行自检程序,不过记得你需要先在 [[connect-llm|连接大模型]] 中配置好你的大模型。
测试完成后,会显示测试结果和性能评估。
![](./images/self-check-result.png)