Skip to main content
Glama
qianwj

Dianping MCP Server

by qianwj
README.md
# Dianping MCP Server

这是一个通过本地浏览器登录会话搜索大众点评内容的 MCP server。大众点评的桌面端和移动端搜索会对匿名请求触发登录/安全验证,因此本项目不使用未经授权的接口,也不尝试绕过验证码或反爬机制;服务使用 Playwright 驱动本机 Chrome,并复用独立的持久化 profile。

## 快速开始

要求 Node.js 20+,并安装 Chrome、Edge 或 Chromium:

```bash
npm install
npm run login
```

登录命令会打开浏览器。请完成大众点评登录和安全验证,然后回到终端按 `Ctrl+C` 退出。登录资料默认保存到 `~/.dianping-mcp/browser-profile`。之后启动 MCP server:

```bash
npm run build
npm start
```

MCP 客户端使用 stdio 连接,提供三个工具:

- `search_places`:按城市、关键词、页码搜索商户,返回名称、评分、评价数、人均、地址和店铺 URL。
- `get_place_details`:按店铺 ID 或搜索结果里的 URL 获取店铺信息及精选评论。
- `check_session`:检查浏览器是否可用、是否需要登录或安全验证。

## MCP 客户端配置

把下面的命令配置到支持 stdio MCP 的客户端,路径替换成仓库的绝对路径:

```json
{
  "mcpServers": {
    "dianping": {
      "command": "npm",
      "args": ["--prefix", "/绝对路径/dp-mcp", "start"],
      "env": {
        "DP_CITY": "上海"
      }
    }
  }
}
```

也可以直接使用构建后的 `dist/index.js`:

```json
{
  "command": "node",
  "args": ["/绝对路径/dp-mcp/dist/index.js"],
  "env": { "DP_CITY": "上海" }
}
```

## 配置项

| 变量 | 默认值 | 作用 |
| --- | --- | --- |
| `DP_PROFILE_DIR` | `~/.dianping-mcp/browser-profile` | 浏览器登录资料目录 |
| `DP_BROWSER_EXECUTABLE_PATH` | 自动探测 | Chrome/Edge/Chromium 可执行文件 |
| `DP_CITY` | `上海` | `search_places` 未传城市时的默认城市 |
| `DP_HEADLESS` | `true` | MCP 搜索是否无头运行;登录请使用 `npm run login` |
| `DP_MIN_INTERVAL_MS` | `1500` | 两次页面请求的最小间隔 |
| `DP_CACHE_TTL_MS` | `300000` | 搜索和详情的内存缓存时间 |
| `DP_NAVIGATION_TIMEOUT_MS` | `25000` | 页面导航和选择器超时 |

当前内置常用城市包括上海、北京、杭州、广州、南京、苏州、深圳、成都、重庆、天津、宁波、扬州、无锡、福州、厦门、武汉、西安、沈阳、大连、长沙、青岛和济南;其他城市可传大众点评城市 ID。

## 开发与验证

```bash
npm test
npm run check
npm run build
```

页面结构或安全策略变化时,服务会返回明确的解析/验证错误。请降低调用频率,并遵守大众点评的服务条款、robots 规则和适用法律。

TDQS

A4/5.0

Scored across 3 tools

Disambiguation5/5

The three tools have clearly distinct purposes: searching for places, retrieving detailed info about a specific place, and checking session/authentication status. No overlap or ambiguity between them.

Naming Consistency5/5

All tool names follow a consistent verb_noun pattern in snake_case (search_places, get_place_details, check_session), making the naming predictable and easy to understand.

Tool Count4/5

With 3 tools, the server is concise but covers the core functionality of searching and retrieving details for a local services platform. The inclusion of a session-check tool is practical, and the count feels appropriate for the scope.

Completeness4/5

The tool surface covers the essential read operations—search and detail retrieval—along with session verification. For a read-oriented API, this is reasonably complete. Minor gaps like listing categories or handling pagination could exist but are not critical.

Maintenance

ActivitySlowing
ResponsivenessNo issues