foliko 1.1.71 → 1.1.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,200 +1,200 @@
1
- ---
2
- name: mcp-usage
3
- description: How to use MCP (Model Context Protocol) tools. Available tools, calling patterns, and best practices.
4
- allowed-tools: mcp_call, mcp_list_servers, mcp_tool_schema, mcp_reload, Read, Write, Edit, Glob, Grep, execute_command
5
- ---
6
-
7
- # MCP Usage Guide
8
-
9
- > How to use MCP tools in this environment.
10
-
11
- ---
12
-
13
- ## 1. Available Tools
14
-
15
- ### mcp_list_servers
16
-
17
- 列出所有已连接的 MCP 服务器及其工具。
18
-
19
- ```
20
- mcp_list_servers()
21
- ```
22
-
23
- 返回示例:
24
-
25
- ```json
26
- {
27
- "success": true,
28
- "servers": [{ "name": "fetch", "tools": [{ "name": "fetch", "description": "..." }] }]
29
- }
30
- ```
31
-
32
- ### mcp_tool_schema
33
-
34
- 查询工具的完整参数结构,直接返回可复制的调用示例。
35
-
36
- ```
37
- mcp_tool_schema({ server: "服务器名", tool: "工具名" })
38
- ```
39
-
40
- 返回示例:
41
-
42
- ```json
43
- {
44
- "success": true,
45
- "result": {
46
- "name": "fetch",
47
- "description": "Fetches a URL from the internet...",
48
- "required": ["url"],
49
- "example": "{\"url\": \"https://example.com\"}",
50
- "fullExample": "mcp_call({ server: \"fetch\", tool: \"fetch\", args_json: '{\"url\": \"https://...\"}' })"
51
- }
52
- }
53
- ```
54
-
55
- ### mcp_call
56
-
57
- 调用 MCP 服务器的工具。
58
-
59
- ```
60
- mcp_call({
61
- server: "服务器名",
62
- tool: "工具名",
63
- args_json: '{"参数名": "参数值"}'
64
- })
65
- ```
66
-
67
- **重要**:
68
-
69
- - `args_json` 必须是有效的 JSON 字符串
70
- - 必填参数不能为空
71
- - 如果不知道参数结构,先用 `mcp_tool_schema` 查询
72
-
73
- ### mcp_reload
74
-
75
- 重新加载 MCP 配置。当 `.foliko/mcp_config.json` 修改后使用。
76
-
77
- ```
78
- mcp_reload()
79
- ```
80
-
81
- ---
82
-
83
- ## 2. Calling Patterns
84
-
85
- ### 简单参数调用
86
-
87
- ```javascript
88
- // 调用 fetch 工具获取网页
89
- mcp_call({
90
- server: 'fetch',
91
- tool: 'fetch',
92
- args_json: '{"url": "https://news.baidu.com"}',
93
- });
94
- ```
95
-
96
- ### 多个参数调用
97
-
98
- ```javascript
99
- // 调用搜索工具
100
- mcp_call({
101
- server: 'bing-cn-mcp-server',
102
- tool: 'bing_search',
103
- args_json: '{"query": "关键词", "count": 10}',
104
- });
105
- ```
106
-
107
- ### 复杂参数调用
108
-
109
- 对于复杂参数(嵌套对象、数组等):
110
-
111
- 1. 先查询参数结构:
112
-
113
- ```
114
- mcp_tool_schema({ server: "服务器", tool: "工具" })
115
- ```
116
-
117
- 2. 根据返回的 `example` 或 `fullExample` 构造调用
118
-
119
- ---
120
-
121
- ## 3. Error Handling
122
-
123
- ### 参数为空
124
-
125
- 如果忘记传参数,会返回错误:
126
-
127
- ```json
128
- {
129
- "success": false,
130
- "error": "参数为空!必须提供: url",
131
- "hint": "正确格式: {\"url\": \"具体值\"}"
132
- }
133
- ```
134
-
135
- ### 参数格式错误
136
-
137
- 如果 JSON 格式不正确:
138
-
139
- ```json
140
- {
141
- "success": false,
142
- "error": "args_json 格式错误,不是有效的 JSON"
143
- }
144
- ```
145
-
146
- ### 服务器不存在
147
-
148
- ```json
149
- {
150
- "success": false,
151
- "error": "MCP server 'xxx' not found"
152
- }
153
- ```
154
-
155
- ---
156
-
157
- ## 4. Configuration
158
-
159
- MCP 服务器配置在 `.foliko/mcp_config.json`:
160
-
161
- ```json
162
- {
163
- "mcpServers": {
164
- "服务器名": {
165
- "type": "sse",
166
- "url": "https://...",
167
- "headers": {
168
- "Authorization": "Bearer xxx"
169
- }
170
- }
171
- }
172
- }
173
- ```
174
-
175
- 添加或修改配置后,调用 `mcp_reload()` 重载。
176
-
177
- ---
178
-
179
- ## 5. Best Practices
180
-
181
- - [ ] 不知道参数时,先用 `mcp_tool_schema` 查询
182
- - [ ] `args_json` 必须是有效的 JSON 字符串(用单引号包裹整个 JSON)
183
- - [ ] 必填参数必须提供
184
- - [ ] 修改配置后用 `mcp_reload()` 重载
185
- - [ ] 使用前先 `mcp_list_servers` 查看可用服务器
186
-
187
- ---
188
-
189
- ## 6. Quick Reference
190
-
191
- | 场景 | 操作 |
192
- | -------------- | ------------------------------------------------------- |
193
- | 查看可用服务器 | `mcp_list_servers()` |
194
- | 查询参数结构 | `mcp_tool_schema({ server: "x", tool: "y" })` |
195
- | 调用工具 | `mcp_call({ server: "x", tool: "y", args_json: '{}' })` |
196
- | 重载配置 | `mcp_reload()` |
197
-
198
- ---
199
-
200
- > **Tip:** 当工具调用失败时,仔细阅读错误信息,它会告诉你缺少什么参数或格式问题。
1
+ ---
2
+ name: mcp-usage
3
+ description: How to use MCP (Model Context Protocol) tools. Available tools, calling patterns, and best practices.
4
+ allowed-tools: mcp_call, mcp_list_servers, mcp_tool_schema, mcp_reload, Read, Write, Edit, Glob, Grep, execute_command
5
+ ---
6
+
7
+ # MCP Usage Guide
8
+
9
+ > How to use MCP tools in this environment.
10
+
11
+ ---
12
+
13
+ ## 1. Available Tools
14
+
15
+ ### mcp_list_servers
16
+
17
+ 列出所有已连接的 MCP 服务器及其工具。
18
+
19
+ ```
20
+ mcp_list_servers()
21
+ ```
22
+
23
+ 返回示例:
24
+
25
+ ```json
26
+ {
27
+ "success": true,
28
+ "servers": [{ "name": "fetch", "tools": [{ "name": "fetch", "description": "..." }] }]
29
+ }
30
+ ```
31
+
32
+ ### mcp_tool_schema
33
+
34
+ 查询工具的完整参数结构,直接返回可复制的调用示例。
35
+
36
+ ```
37
+ mcp_tool_schema({ server: "服务器名", tool: "工具名" })
38
+ ```
39
+
40
+ 返回示例:
41
+
42
+ ```json
43
+ {
44
+ "success": true,
45
+ "result": {
46
+ "name": "fetch",
47
+ "description": "Fetches a URL from the internet...",
48
+ "required": ["url"],
49
+ "example": "{\"url\": \"https://example.com\"}",
50
+ "fullExample": "mcp_call({ server: \"fetch\", tool: \"fetch\", args_json: '{\"url\": \"https://...\"}' })"
51
+ }
52
+ }
53
+ ```
54
+
55
+ ### mcp_call
56
+
57
+ 调用 MCP 服务器的工具。
58
+
59
+ ```
60
+ mcp_call({
61
+ server: "服务器名",
62
+ tool: "工具名",
63
+ args_json: '{"参数名": "参数值"}'
64
+ })
65
+ ```
66
+
67
+ **重要**:
68
+
69
+ - `args_json` 必须是有效的 JSON 字符串
70
+ - 必填参数不能为空
71
+ - 如果不知道参数结构,先用 `mcp_tool_schema` 查询
72
+
73
+ ### mcp_reload
74
+
75
+ 重新加载 MCP 配置。当 `.foliko/mcp_config.json` 修改后使用。
76
+
77
+ ```
78
+ mcp_reload()
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 2. Calling Patterns
84
+
85
+ ### 简单参数调用
86
+
87
+ ```javascript
88
+ // 调用 fetch 工具获取网页
89
+ mcp_call({
90
+ server: 'fetch',
91
+ tool: 'fetch',
92
+ args_json: '{"url": "https://news.baidu.com"}',
93
+ });
94
+ ```
95
+
96
+ ### 多个参数调用
97
+
98
+ ```javascript
99
+ // 调用搜索工具
100
+ mcp_call({
101
+ server: 'bing-cn-mcp-server',
102
+ tool: 'bing_search',
103
+ args_json: '{"query": "关键词", "count": 10}',
104
+ });
105
+ ```
106
+
107
+ ### 复杂参数调用
108
+
109
+ 对于复杂参数(嵌套对象、数组等):
110
+
111
+ 1. 先查询参数结构:
112
+
113
+ ```
114
+ mcp_tool_schema({ server: "服务器", tool: "工具" })
115
+ ```
116
+
117
+ 2. 根据返回的 `example` 或 `fullExample` 构造调用
118
+
119
+ ---
120
+
121
+ ## 3. Error Handling
122
+
123
+ ### 参数为空
124
+
125
+ 如果忘记传参数,会返回错误:
126
+
127
+ ```json
128
+ {
129
+ "success": false,
130
+ "error": "参数为空!必须提供: url",
131
+ "hint": "正确格式: {\"url\": \"具体值\"}"
132
+ }
133
+ ```
134
+
135
+ ### 参数格式错误
136
+
137
+ 如果 JSON 格式不正确:
138
+
139
+ ```json
140
+ {
141
+ "success": false,
142
+ "error": "args_json 格式错误,不是有效的 JSON"
143
+ }
144
+ ```
145
+
146
+ ### 服务器不存在
147
+
148
+ ```json
149
+ {
150
+ "success": false,
151
+ "error": "MCP server 'xxx' not found"
152
+ }
153
+ ```
154
+
155
+ ---
156
+
157
+ ## 4. Configuration
158
+
159
+ MCP 服务器配置在 `.foliko/mcp_config.json`:
160
+
161
+ ```json
162
+ {
163
+ "mcpServers": {
164
+ "服务器名": {
165
+ "type": "sse",
166
+ "url": "https://...",
167
+ "headers": {
168
+ "Authorization": "Bearer xxx"
169
+ }
170
+ }
171
+ }
172
+ }
173
+ ```
174
+
175
+ 添加或修改配置后,调用 `mcp_reload()` 重载。
176
+
177
+ ---
178
+
179
+ ## 5. Best Practices
180
+
181
+ - [ ] 不知道参数时,先用 `mcp_tool_schema` 查询
182
+ - [ ] `args_json` 必须是有效的 JSON 字符串(用单引号包裹整个 JSON)
183
+ - [ ] 必填参数必须提供
184
+ - [ ] 修改配置后用 `mcp_reload()` 重载
185
+ - [ ] 使用前先 `mcp_list_servers` 查看可用服务器
186
+
187
+ ---
188
+
189
+ ## 6. Quick Reference
190
+
191
+ | 场景 | 操作 |
192
+ | -------------- | ------------------------------------------------------- |
193
+ | 查看可用服务器 | `mcp_list_servers()` |
194
+ | 查询参数结构 | `mcp_tool_schema({ server: "x", tool: "y" })` |
195
+ | 调用工具 | `mcp_call({ server: "x", tool: "y", args_json: '{}' })` |
196
+ | 重载配置 | `mcp_reload()` |
197
+
198
+ ---
199
+
200
+ > **Tip:** 当工具调用失败时,仔细阅读错误信息,它会告诉你缺少什么参数或格式问题。