Merge pull request #34 from xpzouying/update-vscode-mcp
修改 vscode 接入的方式
This commit is contained in:
9
.vscode/mcp.json
vendored
Normal file
9
.vscode/mcp.json
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"servers": {
|
||||
"xiaohongshu-mcp": {
|
||||
"url": "http://localhost:18060/mcp",
|
||||
"type": "http"
|
||||
}
|
||||
},
|
||||
"inputs": []
|
||||
}
|
||||
110
MCP_README.md
110
MCP_README.md
@@ -27,35 +27,6 @@ curl -X POST http://localhost:18060/mcp \
|
||||
|
||||
## 📱 客户端接入
|
||||
|
||||
### Claude Desktop
|
||||
|
||||
**重要提示**:Claude Desktop 主要支持 stdio 类型的 MCP 服务器,对于 HTTP 服务器的支持有限。建议使用其他客户端如 VSCode 或 Cursor 来连接 HTTP MCP 服务器。
|
||||
|
||||
如果要在 Claude Desktop 中使用,需要通过代理的方式:
|
||||
|
||||
在 `~/.config/claude-desktop/claude_desktop_config.json` 中添加:
|
||||
|
||||
```json
|
||||
{
|
||||
"mcpServers": {
|
||||
"xiaohongshu": {
|
||||
"command": "curl",
|
||||
"args": [
|
||||
"-X", "POST",
|
||||
"http://localhost:18060/mcp",
|
||||
"-H", "Content-Type: application/json",
|
||||
"-d", "@-"
|
||||
],
|
||||
"env": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**配置路径**:
|
||||
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
||||
- **Windows**: `%APPDATA%\\Claude\\claude_desktop_config.json`
|
||||
|
||||
### Claude Code CLI
|
||||
|
||||
```bash
|
||||
@@ -65,8 +36,6 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp
|
||||
|
||||
### Cursor
|
||||
|
||||
**重要提示**:Cursor 支持三种 MCP 传输方式:stdio、SSE 和 Streamable HTTP。对于 HTTP 服务器,应该使用 `url` 字段而不是 `command` 和 `args`。
|
||||
|
||||
#### 配置文件的方式
|
||||
|
||||
创建或编辑 MCP 配置文件:
|
||||
@@ -86,7 +55,7 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp
|
||||
```
|
||||
|
||||
**全局配置**:
|
||||
在用户目录创建 `~/.cursor/mcp.json` (同样内容)
|
||||
在用户目录创建 `~/.cursor/mcp.json` (同样内容)。
|
||||
|
||||
#### 使用步骤
|
||||
|
||||
@@ -97,21 +66,23 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp
|
||||
|
||||
**Demo**
|
||||
|
||||

|
||||
插件 MCP 接入:
|
||||
|
||||

|
||||
|
||||
调用 MCP 工具:(以检查登录状态为例)
|
||||
|
||||

|
||||
|
||||
### VSCode
|
||||
|
||||
VSCode 从 1.102 版本开始原生支持 MCP,无需安装额外扩展。
|
||||
|
||||
#### 方法一:使用命令面板配置
|
||||
|
||||
1. 按 `Ctrl/Cmd + Shift + P` 打开命令面板
|
||||
2. 运行 `MCP: Add Server` 命令
|
||||
3. 选择配置范围(Workspace 或 Global)
|
||||
4. 提供服务器信息:
|
||||
- **名称**: `xiaohongshu-mcp`
|
||||
- **命令**: `curl`
|
||||
- **参数**: `-X POST http://localhost:18060/mcp -H Content-Type:application/json -d @-`
|
||||
3. 选择 `HTTP` 方式。
|
||||
4. 输入地址: `http://localhost:18060/mcp`,或者修改成对应的 Server 地址。
|
||||
5. 输入 MCP 名字: `xiaohongshu-mcp`。
|
||||
|
||||
#### 方法二:直接编辑配置文件
|
||||
|
||||
@@ -122,32 +93,26 @@ VSCode 从 1.102 版本开始原生支持 MCP,无需安装额外扩展。
|
||||
{
|
||||
"servers": {
|
||||
"xiaohongshu-mcp": {
|
||||
"command": "curl",
|
||||
"args": [
|
||||
"-X", "POST",
|
||||
"http://localhost:18060/mcp",
|
||||
"-H", "Content-Type: application/json",
|
||||
"-d", "@-"
|
||||
],
|
||||
"description": "小红书内容发布和管理服务"
|
||||
"url": "http://localhost:18060/mcp",
|
||||
"type": "http"
|
||||
}
|
||||
}
|
||||
},
|
||||
"inputs": []
|
||||
}
|
||||
```
|
||||
|
||||
**全局配置**:
|
||||
运行 `MCP: Open User Configuration` 命令,添加相同内容
|
||||
**查看配置**:
|
||||
|
||||
#### 使用 MCP 工具
|
||||

|
||||
|
||||
1. 切换到 **Agent 模式**(聊天视图中选择 Agent)
|
||||
2. 点击 **Tools** 按钮查看可用工具
|
||||
3. 在聊天中请求相关任务,VSCode 会自动调用相应的 MCP 工具
|
||||
1. 确认运行状态。
|
||||
2. 查看 `tools` 是否正确检测。
|
||||
|
||||
#### 验证连接
|
||||
**Demo**
|
||||
|
||||
- 打开扩展视图,查看 **MCP SERVERS - INSTALLED** 部分
|
||||
- 成功的服务器会显示绿色状态指示器
|
||||
以搜索帖子内容为例:
|
||||
|
||||

|
||||
|
||||
### 通用 MCP Inspector(调试用)
|
||||
|
||||
@@ -156,7 +121,7 @@ VSCode 从 1.102 版本开始原生支持 MCP,无需安装额外扩展。
|
||||
npx @modelcontextprotocol/inspector
|
||||
|
||||
# 在浏览器中连接到:http://localhost:18060/mcp
|
||||
````
|
||||
```
|
||||
|
||||
## 🛠️ 可用工具
|
||||
|
||||
@@ -211,35 +176,8 @@ npx @modelcontextprotocol/inspector
|
||||
}
|
||||
```
|
||||
|
||||
## ⚠️ 注意事项
|
||||
|
||||
1. **首次使用需要登录**:运行 `go run cmd/login/main.go` 完成登录
|
||||
2. **网络要求**:确保客户端能访问 `localhost:18060`
|
||||
3. **权限验证**:某些操作需要有效的登录状态
|
||||
|
||||
## 🔧 故障排除
|
||||
|
||||
### 连接失败
|
||||
|
||||
- 检查服务是否运行:`curl http://localhost:18060/health`
|
||||
- 确认端口未被占用
|
||||
- 检查防火墙设置
|
||||
|
||||
### Cursor 连接问题
|
||||
|
||||
- 确保使用正确的配置格式:HTTP 服务器使用 `url` 字段,而不是 `command` + `args`
|
||||
- 重启 Cursor 应用以加载新的 MCP 配置
|
||||
- 检查是否有 "Available Tools" 显示在聊天界面中
|
||||
|
||||
### MCP Inspector 测试
|
||||
|
||||
- 使用 MCP Inspector 测试连接:`npx @modelcontextprotocol/inspector`
|
||||
- 测试 Ping Server 功能验证连接
|
||||
- 检查 List Tools 是否返回 4 个工具
|
||||
|
||||
### 工具调用失败
|
||||
|
||||
- 确认已完成小红书登录
|
||||
- 检查图片 URL 或路径是否有效
|
||||
- 查看服务日志获取详细错误信息
|
||||
- 确保工具参数格式正确(特别注意 `list_feeds` 不需要参数)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 288 KiB |
BIN
assets/cursor_mcp_check_login.png
Normal file
BIN
assets/cursor_mcp_check_login.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 217 KiB |
BIN
assets/cursor_mcp_settings.png
Normal file
BIN
assets/cursor_mcp_settings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 211 KiB |
BIN
assets/vscode_mcp_config.png
Normal file
BIN
assets/vscode_mcp_config.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 220 KiB |
BIN
assets/vscode_search_demo.png
Normal file
BIN
assets/vscode_search_demo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 585 KiB |
Reference in New Issue
Block a user