diff --git a/.claude/settings.local.json b/.claude/settings.local.json index d98b508..11591a7 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -15,7 +15,11 @@ "Bash(chmod:*)", "Bash(true)", "Bash(go vet:*)", - "Bash(golangci-lint run:*)" + "Bash(golangci-lint run:*)", + "WebSearch", + "mcp__playwright__browser_navigate", + "mcp__playwright__browser_click", + "mcp__playwright__browser_tab_select" ], "deny": [] } diff --git a/MCP_README.md b/MCP_README.md index d95f53a..58bd0ea 100644 --- a/MCP_README.md +++ b/MCP_README.md @@ -29,20 +29,33 @@ 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": "npx", - "args": ["-y", "@modelcontextprotocol/client-stdio", "http://localhost:18060/mcp"], + "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 @@ -52,30 +65,62 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp ### Cursor -在 Cursor 设置中添加 MCP 配置: +#### 配置文件的方式 + +创建或编辑 MCP 配置文件: + +**项目级配置**(推荐): +在项目根目录创建 `.cursor/mcp.json`: ```json { - "mcp.servers": { - "xiaohongshu": { - "command": "node", - "args": ["-e", "/* HTTP proxy script */"], + "mcpServers": { + "xiaohongshu-mcp": { + "command": "curl", + "args": [ + "-X", + "POST", + "http://localhost:18060/mcp", + "-H", + "Content-Type: application/json", + "-d", + "@-" + ], "description": "小红书内容发布服务" } } } ``` +**全局配置**: +在用户目录创建 `~/.cursor/mcp.json` (同样内容) + +**Demo** + +![cursor_mcp_demo](./assets/cursor_mcp_01.png) + ### VSCode -安装 MCP 扩展并配置: +VSCode 从 1.102 版本开始原生支持 MCP,无需安装额外扩展。 -1. 安装 [MCP for VSCode](https://marketplace.visualstudio.com/search?term=mcp&target=VSCode) 扩展 -2. 在 VSCode 设置中添加配置(`Ctrl/Cmd + ,` → 搜索 "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 @-` + +#### 方法二:直接编辑配置文件 + +**工作区配置**(推荐): +在项目根目录创建 `.vscode/mcp.json`: ```json { - "mcp.servers": { + "servers": { "xiaohongshu-mcp": { "command": "curl", "args": [ @@ -90,18 +135,19 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp } ``` -或者在工作区的 `.vscode/settings.json` 中添加: +**全局配置**: +运行 `MCP: Open User Configuration` 命令,添加相同内容 -```json -{ - "mcp.servers": { - "xiaohongshu-mcp": { - "transport": "http", - "endpoint": "http://localhost:18060/mcp", - "description": "小红书 MCP 服务" - } - } -} +#### 使用 MCP 工具 + +1. 切换到 **Agent 模式**(聊天视图中选择 Agent) +2. 点击 **Tools** 按钮查看可用工具 +3. 在聊天中请求相关任务,VSCode 会自动调用相应的 MCP 工具 + +#### 验证连接 + +- 打开扩展视图,查看 **MCP SERVERS - INSTALLED** 部分 +- 成功的服务器会显示绿色状态指示器 ### 通用 MCP Inspector(调试用) @@ -110,7 +156,7 @@ claude mcp add --transport http xiaohongshu-mcp http://localhost:18060/mcp npx @modelcontextprotocol/inspector # 在浏览器中连接到:http://localhost:18060/mcp -``` +```` ## 🛠️ 可用工具 @@ -153,11 +199,13 @@ npx @modelcontextprotocol/inspector ## 🔧 故障排除 ### 连接失败 + - 检查服务是否运行:`curl http://localhost:18060/health` - 确认端口未被占用 - 检查防火墙设置 ### 工具调用失败 + - 确认已完成小红书登录 -- 检查图片URL或路径是否有效 +- 检查图片 URL 或路径是否有效 - 查看服务日志获取详细错误信息 diff --git a/assets/cursor_mcp_01.png b/assets/cursor_mcp_01.png new file mode 100644 index 0000000..d1ca581 Binary files /dev/null and b/assets/cursor_mcp_01.png differ diff --git a/assets/inspect_mcp.png b/assets/inspect_mcp.png index ccbbdbf..7743855 100644 Binary files a/assets/inspect_mcp.png and b/assets/inspect_mcp.png differ diff --git a/assets/publish_result.jpeg b/assets/publish_result.jpeg index 516cf29..1ee154c 100644 Binary files a/assets/publish_result.jpeg and b/assets/publish_result.jpeg differ diff --git a/assets/run_inspect.png b/assets/run_inspect.png index cd8b715..4509bd6 100644 Binary files a/assets/run_inspect.png and b/assets/run_inspect.png differ