Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ playwright-report/
.history/

.iga/

# 临时中间结果
.tmp/
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pnpm-lock.yaml
src/tests/fixtures/
27 changes: 19 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Designed for **agent integration** — structured JSON output, MCP server suppor
- **Agent Skill** — `mpget init` injects a skill file into `.claude/skills/` with version sync
- **Multi-page search** — automatic pagination with configurable max pages and rate limiting
- **Article content extraction** — fetches and cleans WeChat article body text
- **Album article listing** — list all articles in an official account's album (with real mp.weixin.qq.com links)
- **Structured JSON output** — all results to stdout, errors to stderr with typed exit codes

## Install
Expand All @@ -38,25 +39,33 @@ mpget search "key" -a -m 5

# Fetch article content
mpget content "https://mp.weixin.qq.com/s/xxx"

# List articles in an account's album (needs __biz and album_id from an article page)
mpget album "MzkxMTY4NTAyNQ==" "4371775694981152789" -c 10

# Fetch the whole album
mpget album "MzkxMTY4NTAyNQ==" "4371775694981152789" --all
```

**Search options:**

| Option | Description | Default |
| ---------------- | ---------------------- | ------- |
| `-p, --page <n>` | Page number | `1` |
| `-a, --all` | Fetch all pages | `false` |
| `-m, --max <n>` | Max pages when `--all` | `10` |
| Option | Description | Default |
| ---------------- | ------------------------------------------ | ------- |
| `-p, --page <n>` | Page number | `1` |
| `-a, --all` | Fetch all pages | `false` |
| `-m, --max <n>` | Max pages when `--all` | `10` |
| `--no-resolve` | Skip resolving real mp.weixin.qq.com links | `false` |

### MCP Server

```bash
mpget mcp
```

Starts a stdio-based MCP server exposing two tools:
Starts a stdio-based MCP server exposing three tools:

- **`search`** — query, page, all, maxPages
- **`search`** — query, page, all, maxPages, resolve (default: resolve real links)
- **`album`** — biz, albumId, count, beginMsgid, beginItemidx
- **`content`** — url, referer

Compatible with any MCP-capable agent (Claude, Cursor, etc.).
Expand All @@ -81,7 +90,9 @@ All commands output JSON to stdout. Errors go to stderr as structured JSON.
{
"title": "Article Title",
"link": "https://weixin.sogou.com/link?url=...",
"publishTime": "2025-01-01"
"realUrl": "https://mp.weixin.qq.com/s?src=11&...",
"publishTime": "2025-01-01",
"account": "Account Name"
}
],
"total": 10,
Expand Down
27 changes: 19 additions & 8 deletions docs/README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CLI 工具与 MCP 服务,用于搜索和获取微信公众号文章(基于
- **Agent Skill** — `mpget init` 一键注入 Skill 到 `.claude/skills/`,带版本同步
- **多页搜索** — 自动分页,支持配置最大页数和请求间隔
- **文章内容提取** — 获取并清洗微信公众号文章正文
- **合集文章列表** — 拉取某公众号合集内全部文章(含真实 mp.weixin.qq.com 链接)
- **结构化 JSON 输出** — 结果输出到 stdout,错误输出到 stderr,带类型化退出码

## 安装
Expand All @@ -38,25 +39,33 @@ mpget search "关键词" -a -m 5

# 获取文章内容
mpget content "https://mp.weixin.qq.com/s/xxx"

# 获取某公众号合集内的文章列表(biz 与 album_id 取自文章页)
mpget album "MzkxMTY4NTAyNQ==" "4371775694981152789" -c 10

# 拉取整个合集
mpget album "MzkxMTY4NTAyNQ==" "4371775694981152789" --all
```

**搜索参数:**

| 参数 | 说明 | 默认值 |
| ---------------- | ------------------ | ------- |
| `-p, --page <n>` | 页码 | `1` |
| `-a, --all` | 获取全部页 | `false` |
| `-m, --max <n>` | `--all` 时最大页数 | `10` |
| 参数 | 说明 | 默认值 |
| ---------------- | -------------------------------- | ------- |
| `-p, --page <n>` | 页码 | `1` |
| `-a, --all` | 获取全部页 | `false` |
| `-m, --max <n>` | `--all` 时最大页数 | `10` |
| `--no-resolve` | 不解析真实 mp.weixin.qq.com 链接 | `false` |

### MCP Server

```bash
mpget mcp
```

启动基于 stdio 的 MCP Server,提供两个工具:
启动基于 stdio 的 MCP Server,提供三个工具:

- **`search`** — query, page, all, maxPages
- **`search`** — query, page, all, maxPages, resolve(默认解析真实链接)
- **`album`** — biz, albumId, count, beginMsgid, beginItemidx
- **`content`** — url, referer

兼容所有支持 MCP 协议的 Agent(Claude、Cursor 等)。
Expand All @@ -81,7 +90,9 @@ mpget init
{
"title": "文章标题",
"link": "https://weixin.sogou.com/link?url=...",
"publishTime": "2025-01-01"
"realUrl": "https://mp.weixin.qq.com/s?src=11&...",
"publishTime": "2025-01-01",
"account": "公众号名"
}
],
"total": 10,
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
"dependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",
"cheerio": "^1.0.0",
"commander": "^12.0.0",
"mpget": "link:"
"commander": "^12.0.0"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
Expand Down
Loading
Loading