Unofficial CLI helpers and an optional Codex/agent skill for user-authorized Maimai web sessions.
maimai-cli is designed for interactive, low-volume reading of Maimai content that the signed-in user can already view in the browser. The repository contains two pieces:
maimai, a local command-line tool published on PyPI.skill/, a routing skill that teaches an agent when and how to use the CLI safely.
It does not provide login bypasses, QR login, browser-cookie extraction, CAPTCHA solving, anti-bot bypasses, or bulk scraping workflows.
maimai-cli 是一个非官方的脉脉本机命令行工具,用来读取当前登录用户本来就能在网页端看到的内容,例如推荐流、热榜、同事圈、搜索结果、帖子详情、评论、图片和资料卡。
这个仓库同时提供:
maimaiCLI:发布在 PyPI 上的命令行工具。skill/:给 Codex/Agent 使用的路由技能,帮助 Agent 在用户提到脉脉、同事圈、推荐流、评论、Cookie 等场景时正确调用 CLI。
安全边界:
- 不支持扫码登录。
- 不自动读取浏览器 Cookie。
- 不绕过登录、验证码、风控或权限控制。
- 只适合低频、交互式地查看用户自己有权限访问的内容。
- 不建议把完整 Cookie 发到聊天里,推荐在本机终端通过环境变量或标准输入导入。
快速开始:
pip install maimai-cli
maimai --help
maimai import-cookie-header
maimai status
maimai feed --limit 10
maimai company-feed --limit 10安装 Agent skill:
cp -R skill ~/.agents/skills/maimai-cli- You must provide your own valid Cookie header from a browser session you control.
- The CLI does not read browser cookie stores automatically.
- Cookies are stored locally under
~/.maimai-cli/cookies.jsonwith best-effort0600permissions. - The CLI only uses same-origin Maimai web endpoints and user-visible pages.
- Do not use this project to access accounts, companies, feeds, posts, comments, or profiles that you are not authorized to view.
- Respect Maimai's terms, privacy expectations, rate limits, and applicable law.
- Keep request volume low. This tool is designed for interactive use, not continuous crawling.
- If a Cookie header is exposed in chat, rotate it by logging out or refreshing the browser session.
From PyPI:
pip install maimai-cli
maimai --helpWith uvx:
uvx maimai-cli --helpFrom source:
git clone https://github.com/mariotong/maimai-cli.git
cd maimai-cli
uv run maimai --helpThe repository includes a Codex/agent skill at skill/. Install it into your local skill root if you want agents to route Maimai-related requests to this CLI:
cp -R skill ~/.agents/skills/maimai-cliThe skill is intended to trigger when a user mentions Maimai, maimai, 职言, 同事圈, 推荐流, 热榜, 帖子详情, 评论, Cookie, or related troubleshooting.
Skill references:
| User intent | Reference |
|---|---|
| Authentication, Cookie import, safety boundaries | skill/references/auth.md |
| Recommended feed, hot rank, company circle, pagination | skill/references/feeds.md |
| Search content and contacts | skill/references/search.md |
| Details, comments, images, profiles, short indexes | skill/references/detail.md |
| Troubleshooting and common workflows | skill/references/troubleshooting.md |
Agent usage principles from the skill:
- Verify
maimai --helpandmaimai statusbefore deeper workflows. - Start list reads with small limits, for example
maimai feed --limit 5. - Treat
1,2, and similar numeric values as short indexes only after checking recent list context. - Summarize output by default; use
--json,--yaml, or--rawonly when needed. - Never ask users to paste complete Cookie headers into chat.
Import a Cookie header explicitly:
maimai import-cookie-header --cookie '<paste your Cookie header here>'You can also use an environment variable or stdin:
MAIMAI_COOKIE='<paste your Cookie header here>' maimai import-cookie-headerCheck local authentication evidence:
maimai status
maimai me
maimai cookiesRemove saved cookies:
maimai logoutRead a visible community feed:
maimai feed --type recommended --limit 20
maimai feed --type gossip --offset 20 --limit 20
maimai feed --page 2 --page-size 10Read hot rank:
maimai hot-rank --limit 20Read the current account's visible company circle feed:
maimai company-feed --limit 20Read a specific company circle if you already know its webcid:
maimai company-feed <webcid> --limit 20If automatic company-circle discovery fails with an HTTP 406/404 or an empty result, open the company circle in the browser and copy the webcid from the URL:
https://maimai.cn/company/gossip_discuss?webcid=<webcid>
Then pass it explicitly:
maimai company-feed <webcid> --limit 20Search visible content and contacts:
maimai search "keyword" --limit 5
maimai search "keyword" --section gossips
maimai search "keyword" --section contactsAfter any listing command, entries are saved as short indexes. Use those indexes for details, comments, images, and profiles:
maimai refs
maimai detail 1 --kind gossip
maimai comments 1 --kind gossip --limit 20
maimai images 1 --kind gossip
maimai profile 1Use structured output for scripts:
maimai feed --type gossip --limit 5 --json
maimai hot-rank --yamlUse --raw only when you explicitly need the full parsed response:
maimai company-feed --rawList commands save a local reference table at ~/.maimai-cli/refs.json. Follow-up commands can use the latest list's 1-based indexes instead of copying raw IDs:
maimai feed --type gossip --limit 10
maimai refs
maimai detail 1 --kind gossip
maimai comments 1 --kind gossipIf a short index points to the wrong item, run maimai refs to inspect the current cache. A later list command replaces the short-index context.
Comments use a separate cache at ~/.maimai-cli/comment_refs.json, so reading comments no longer replaces the post indexes from feed, hot-rank, company-feed, or search. Inspect comment indexes explicitly when needed:
maimai comments 1 --kind gossip
maimai refs --scope comments
maimai comments 1 --kind gossip --cid 1Short indexes are not raw post IDs. They only refer to the latest local list cache. Running another post list command can replace that cache. If you use a raw gossip ID directly, pass its --egid; if you use a raw feed ID directly, pass its --efid:
maimai detail 36744330 --kind gossip --egid <egid>
maimai comments 36744330 --kind gossip --egid <egid>Some Maimai web features use Next.js server action IDs. The CLI ships with known defaults and keeps a local runtime cache at ~/.maimai-cli/actions.json. If an action fails, the client can scan currently visible pages for candidate action IDs, retry conservatively, and cache a working value.
This mechanism is for compatibility with normal web-page changes. It is not intended to bypass access controls or anti-abuse systems.
Check auth first:
maimai status
maimai cookies
maimai meIf auth looks stale:
maimai logout
MAIMAI_COOKIE='<paste your new Cookie header here>' maimai import-cookie-header
maimai statusIf list follow-up commands fail:
maimai refsIf search pagination appears unchanged, note that the current Maimai web search endpoint may ignore offset/page parameters.
If maimai company-feed fails during automatic company-circle discovery, pass the browser URL's webcid explicitly:
maimai company-feed <webcid> --limit 20Run local checks:
uv run python -m py_compile maimai_cli/*.py maimai_cli/commands/*.py
uv run python -m unittestBuild the package:
uv buildPublish to PyPI:
UV_PUBLISH_TOKEN='<your PyPI API token>' uv publishAlpha. Endpoints and page structures may change without notice. Expect breakage and treat output as best-effort.
This project is unofficial and is not affiliated with, endorsed by, or sponsored by Maimai. Use it only with accounts and data you are authorized to access.