flashid-auto 0.2.2__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/.env.example +0 -1
- {flashid_auto-0.2.2/src/flashid_auto.egg-info → flashid_auto-0.2.4}/PKG-INFO +1 -1
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/examples/linkedin-mcp-client.json +1 -2
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/examples/linkedin-mcp-server.template.json +3 -9
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/linkedin-mcp-release.md +25 -3
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/linkedin-mcp.md +41 -22
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/linkedin-people-search.md +1 -1
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/pyproject.toml +1 -1
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/mcp/__main__.py +1 -9
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/mcp/service.py +12 -11
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/mcp/tools.py +22 -4
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/linkedin_people_search.py +52 -5
- {flashid_auto-0.2.2 → flashid_auto-0.2.4/src/flashid_auto.egg-info}/PKG-INFO +1 -1
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_linkedin_mcp.py +135 -18
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_linkedin_people_search.py +25 -3
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/LICENSE +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/MANIFEST.in +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/flashid-api-reference.md +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/linkedin-sales-navigator.md +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/docs/package-readme.md +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/requirements-dev.lock +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/requirements-mcp.lock +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/setup.cfg +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/__init__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/__init__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/base.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/contracts.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/environment.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/plan.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/registry.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/runner.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/automation/worker.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/cli.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/flashid/__init__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/flashid/__main__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/flashid/client.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/flashid/config.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/flashid/errors.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/mcp/__init__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/mcp/server.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/__init__.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/_linkedin.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/duckduckgo.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/linkedin_sales_navigator.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/tocsv.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto.egg-info/SOURCES.txt +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto.egg-info/dependency_links.txt +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto.egg-info/entry_points.txt +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto.egg-info/requires.txt +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto.egg-info/top_level.txt +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_automation.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_automation_worker.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_duckduckgo_browser.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_flashid_client.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_flashid_config_cli.py +0 -0
- {flashid_auto-0.2.2 → flashid_auto-0.2.4}/tests/test_linkedin_sales_navigator.py +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "io.github.replace-owner/linkedin-mcp",
|
|
4
4
|
"title": "LinkedIn MCP for FlashID",
|
|
5
5
|
"description": "Search LinkedIn Sales Navigator companies and employees in your own FlashID browser.",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.4",
|
|
7
7
|
"repository": {
|
|
8
8
|
"url": "https://github.com/replace-owner/replace-repository",
|
|
9
9
|
"source": "github"
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"registryType": "pypi",
|
|
14
14
|
"registryBaseUrl": "https://pypi.org",
|
|
15
15
|
"identifier": "flashid-auto",
|
|
16
|
-
"version": "0.2.
|
|
16
|
+
"version": "0.2.4",
|
|
17
17
|
"runtimeHint": "uvx",
|
|
18
18
|
"runtimeArguments": [
|
|
19
|
-
{"type":"named","name":"--with","value":"flashid-auto[mcp]==0.2.
|
|
19
|
+
{"type":"named","name":"--with","value":"flashid-auto[mcp]==0.2.4"}
|
|
20
20
|
],
|
|
21
21
|
"packageArguments": [{"type":"positional","value":"mcp"}],
|
|
22
22
|
"transport": {"type":"stdio"},
|
|
@@ -32,12 +32,6 @@
|
|
|
32
32
|
"description":"Your own FlashID Local API key",
|
|
33
33
|
"isRequired":true,
|
|
34
34
|
"isSecret":true
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name":"LINKEDIN_MCP_PROFILE",
|
|
38
|
-
"description":"Name of your running FlashID environment",
|
|
39
|
-
"default":"Navigator",
|
|
40
|
-
"isRequired":true
|
|
41
35
|
}
|
|
42
36
|
]
|
|
43
37
|
}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
-
# LinkedIn MCP
|
|
1
|
+
# LinkedIn MCP 发布记录
|
|
2
2
|
|
|
3
3
|
日期:2026-10-20。此文为发布操作说明;构建完成不代表已上传 PyPI、GitHub 或 MCP Registry。
|
|
4
|
+
2026-10-26 更新:启动示例已移除环境参数;对话选择环境的接口需重新构建包含本次变更的发行包,
|
|
5
|
+
历史构建产物不包含该功能。迁移步骤见 [MCP 指南](linkedin-mcp.md#从启动参数迁移)。
|
|
6
|
+
|
|
7
|
+
## 0.2.4 发布
|
|
8
|
+
|
|
9
|
+
本版本增加逐次工具调用选择 FlashID 环境的必填 `profile`,移除 MCP 启动参数和环境变量中的环境选择。
|
|
10
|
+
更新后重启 MCP 服务,并按[迁移说明](linkedin-mcp.md#从启动参数迁移)更新客户端配置。
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
.venv/bin/python -m build
|
|
14
|
+
.venv/bin/python -m twine check --strict dist/flashid_auto-0.2.4.tar.gz dist/flashid_auto-0.2.4-py3-none-any.whl
|
|
15
|
+
.venv/bin/python -m twine upload dist/flashid_auto-0.2.4.tar.gz dist/flashid_auto-0.2.4-py3-none-any.whl
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
上传后验证 <https://pypi.org/project/flashid-auto/0.2.4/>,并运行:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
uvx --from 'flashid-auto[mcp]==0.2.4' linkedin-mcp --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
PyPI 凭据通过 Twine 的交互提示读取,不得写入命令参数、仓库或文档。
|
|
4
25
|
|
|
5
26
|
## 首次发布到正式 PyPI
|
|
6
27
|
|
|
@@ -91,7 +112,7 @@ GitHub 归属待仓库所有者给出,当前项目未配置远程仓库。
|
|
|
91
112
|
|
|
92
113
|
```bash
|
|
93
114
|
python -m pip install 'flashid-auto[mcp]==0.2.0'
|
|
94
|
-
linkedin-mcp --env-file /absolute/path/to/.env
|
|
115
|
+
linkedin-mcp --env-file /absolute/path/to/.env
|
|
95
116
|
```
|
|
96
117
|
|
|
97
118
|
使用 uvx 的等价方式(发行后):
|
|
@@ -104,10 +125,11 @@ uvx --with 'flashid-auto[mcp]==0.2.0' flashid-auto@0.2.0 mcp --env-file /absolut
|
|
|
104
125
|
发行后可提供面向 Codex 用户的一条命令(需预装 Codex CLI 和 uv):
|
|
105
126
|
|
|
106
127
|
```bash
|
|
107
|
-
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from 'flashid-auto[mcp]==0.2.0' linkedin-mcp
|
|
128
|
+
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from 'flashid-auto[mcp]==0.2.0' linkedin-mcp
|
|
108
129
|
```
|
|
109
130
|
|
|
110
131
|
这条命令注册启动配置,依赖在 Codex 首次连接时由 uvx 安装;不需要先登记 MCP Registry。
|
|
132
|
+
环境名由用户在对话中指定,Agent 在每次工具调用的 `profile` 参数中传入。
|
|
111
133
|
公开示例只使用占位 Key;每位用户填写自己的值。完整说明见 [接入指南](linkedin-mcp.md)。
|
|
112
134
|
|
|
113
135
|
## MCP Registry
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# LinkedIn MCP 使用与接口契约
|
|
2
2
|
|
|
3
|
-
日期:2026-10-
|
|
3
|
+
日期:2026-10-26。源码版本:flashid-auto 0.2.4。服务名和启动命令:`linkedin-mcp`。
|
|
4
4
|
公司模块复用 `linkedin_sales_navigator` 1.2.0,人员模块复用 `linkedin_people_search` 2.3.0。
|
|
5
5
|
|
|
6
6
|
## 1. 目标与安装
|
|
@@ -18,18 +18,20 @@ cp .env.example .env
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
填写根目录 `.env` 中的 `FLASHID_API_BASE_URL`、`FLASHID_API_KEY`。
|
|
21
|
-
|
|
21
|
+
先启动用户要使用的 FlashID 环境,并在其中登录英文版 Sales Navigator;项目调试使用 `Navigator`。
|
|
22
22
|
实际使用无需安装 Playwright Chromium;浏览器测试需要 `.venv/bin/playwright install chromium`。
|
|
23
23
|
Windows 使用 `.venv\Scripts\python.exe` 和 `.venv\Scripts\linkedin-mcp.exe`。
|
|
24
24
|
|
|
25
25
|
命令:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
.venv/bin/linkedin-mcp --env-file /absolute/path/to/project/.env
|
|
28
|
+
.venv/bin/linkedin-mcp --env-file /absolute/path/to/project/.env
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
该命令等待 MCP 客户端通过 stdio 连接。无额外 HTTP 端口。
|
|
32
|
-
|
|
32
|
+
环境名由用户在与 Agent 的对话中指定,例如“使用 Navigator 环境查找公司”。
|
|
33
|
+
Agent 在每次工具调用中传入必填参数 `profile`;服务没有默认环境,也不保存上次选择。
|
|
34
|
+
用户尚未指定时,Agent 必须先询问;用户更换环境后,后续调用使用新的环境名,无须重启服务。
|
|
33
35
|
`--env-file` 默认为工作目录的 `.env`,从其他目录启动时请显式传绝对路径。
|
|
34
36
|
进程环境变量优先于 `.env`。不从安装目录猜测配置文件。
|
|
35
37
|
本地启动可通过 `.env` 提供 Key;下面的 Codex 注册方式使用其官方 `--env` 参数。
|
|
@@ -39,21 +41,28 @@ Windows 使用 `.venv\Scripts\python.exe` 和 `.venv\Scripts\linkedin-mcp.exe`
|
|
|
39
41
|
通用 Agent 配置见 [示例](examples/linkedin-mcp-client.json),替换其中绝对路径。
|
|
40
42
|
各客户端采用自身的 MCP 配置入口;此配置表示标准 stdio command/args 语义。
|
|
41
43
|
|
|
44
|
+
### 从启动参数迁移
|
|
45
|
+
|
|
46
|
+
更新安装包后,从 MCP 客户端配置中删除 `--profile` 及其值,再重启 MCP 服务以刷新工具 Schema。
|
|
47
|
+
`LINKEDIN_MCP_PROFILE` 不再读取,可从 `.env` 或客户端环境变量配置中删除。
|
|
48
|
+
旧的 `--profile` 启动方式会报未知参数;直接调用工具的脚本须在每次请求中加入 `profile`。
|
|
49
|
+
以上变更仅影响 MCP;普通 `flashid-auto --profile ...` 自动化命令仍按原契约运行。
|
|
50
|
+
|
|
42
51
|
### Codex 一条命令接入
|
|
43
52
|
|
|
44
53
|
前提:用户已安装 Codex CLI 和 uv(提供 `uvx` 命令),运行 FlashID Local API,
|
|
45
|
-
|
|
54
|
+
并在所选环境登录 Sales Navigator。**以下公网命令需要先把本项目发布到 PyPI;
|
|
46
55
|
目前发行包仍为本地构建,尚未公开上传。**
|
|
47
56
|
|
|
48
57
|
```bash
|
|
49
|
-
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from 'flashid-auto[mcp]==0.2.
|
|
58
|
+
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from 'flashid-auto[mcp]==0.2.4' linkedin-mcp
|
|
50
59
|
```
|
|
51
60
|
|
|
52
61
|
将 `YOUR_FLASHID_API_KEY` 替换为用户自己的 Key。`codex mcp add` 保存 MCP 启动配置;
|
|
53
62
|
Codex 首次连接时,`uvx` 自动下载依赖、缓存独立环境并启动服务器。
|
|
54
63
|
用户无需克隆源码、手动创建 `.venv` 或编写 JSON。默认使用
|
|
55
64
|
`http://127.0.0.1:58931`;API 地址不同可在 `--` 之前添加
|
|
56
|
-
`--env FLASHID_API_BASE_URL=http
|
|
65
|
+
`--env FLASHID_API_BASE_URL=http://实际主机:端口`。在对话中告诉 Agent 要使用的环境名。
|
|
57
66
|
此流程不自动安装 FlashID 或登录领英。
|
|
58
67
|
|
|
59
68
|
注册后执行 `codex mcp list` 查看配置,在 Codex 中用 `/mcp` 查看连接状态。
|
|
@@ -62,7 +71,7 @@ Codex 首次连接时,`uvx` 自动下载依赖、缓存独立环境并启动
|
|
|
62
71
|
发布前可以直接用本地 wheel 验证:
|
|
63
72
|
|
|
64
73
|
```bash
|
|
65
|
-
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from '/absolute/path/to/flashid_auto-0.2.
|
|
74
|
+
codex mcp add linkedin-mcp --env FLASHID_API_KEY=YOUR_FLASHID_API_KEY -- uvx --from '/absolute/path/to/flashid_auto-0.2.4-py3-none-any.whl[mcp]' linkedin-mcp
|
|
66
75
|
```
|
|
67
76
|
|
|
68
77
|
命令中的 wheel 路径须替换为本机实际绝对路径。该方式不依赖 PyPI 上尚未发布的本项目。
|
|
@@ -71,18 +80,22 @@ Codex 格式依据:[官方 MCP 配置说明](https://developers.openai.com/cod
|
|
|
71
80
|
|
|
72
81
|
## 2. 工具契约(API-MCP-001)
|
|
73
82
|
|
|
83
|
+
五个工具都要求 `profile`:用户在当前对话中明确指定的、运行中的 FlashID 环境名称。
|
|
84
|
+
必须为非空、非纯空白字符串,按完整名称精确匹配;不匹配或重名时返回错误,不回退到其他环境。
|
|
85
|
+
下表列出各工具的其他参数。
|
|
86
|
+
|
|
74
87
|
| 工具 | 参数与用途 |
|
|
75
88
|
| --- | --- |
|
|
76
|
-
| `check_environment` |
|
|
89
|
+
| `check_environment` | 仅需 `profile`;解析运行中的目标环境,再检查公司人数筛选器所在的页面,验证 CDP 与 Sales Navigator 访问;返回检查结果,无搜索记录 |
|
|
77
90
|
| `inspect_company_filters` | `inspect_filter`、`suggestion`、`location_mode`、`timeout_ms`;省略筛选字段时检查全部公司筛选器 |
|
|
78
91
|
| `search_companies` | `search_key`、`filters`、`result_count`、`start_position`、`require_result_count`、`max_pages`、`timeout_ms` |
|
|
79
92
|
| `inspect_people_filters` | 同公司 inspect,但使用人员筛选器;Current company 候选额外返回页面公开的 `company_id`,缺失则为 null |
|
|
80
93
|
| `search_people` | `search_key`、`company_name`、`company_id`、`filters`、`result_count`、`require_result_count`、`max_pages`、`timeout_ms` |
|
|
81
94
|
|
|
82
|
-
MCP inputSchema 从现有模块 Schema
|
|
95
|
+
MCP inputSchema 从现有模块 Schema 派生并增加必填的 `profile`,未知参数拒绝。完整筛选含义见
|
|
83
96
|
[公司契约](linkedin-sales-navigator.md)和[人员契约](linkedin-people-search.md)。
|
|
84
97
|
search 工具不接受 `action` 或 inspect 专用参数;inspect 不接受搜索参数。
|
|
85
|
-
|
|
98
|
+
参数校验完成后才查询 FlashID 和访问浏览器;`profile` 不传入底层业务模块。
|
|
86
99
|
|
|
87
100
|
MCP 人员搜索要求 `company_name`、`company_id` 同时提供,同时不接受
|
|
88
101
|
`filters.current_company`。这是 MCP 接口的明确约束,防止旧模块的“首个候选”行为查错公司;
|
|
@@ -91,7 +104,7 @@ MCP 人员搜索要求 `company_name`、`company_id` 同时提供,同时不接
|
|
|
91
104
|
查询公司候选:
|
|
92
105
|
|
|
93
106
|
```json
|
|
94
|
-
{"inspect_filter":"current_company","suggestion":"目标公司名称"}
|
|
107
|
+
{"profile":"Navigator","inspect_filter":"current_company","suggestion":"目标公司名称"}
|
|
95
108
|
```
|
|
96
109
|
|
|
97
110
|
从 `output.data.filters.current_company.options` 读取 `value` 与 `company_id`。
|
|
@@ -100,15 +113,16 @@ MCP 人员搜索要求 `company_name`、`company_id` 同时提供,同时不接
|
|
|
100
113
|
|
|
101
114
|
## 3. 自然语言调用流程
|
|
102
115
|
|
|
103
|
-
1.
|
|
104
|
-
2.
|
|
105
|
-
3.
|
|
106
|
-
4.
|
|
107
|
-
5.
|
|
108
|
-
6.
|
|
109
|
-
7.
|
|
116
|
+
1. 从当前对话中取得用户明确指定的环境名;未指定时先询问。每次调用携带 `profile`,直到用户切换环境前沿用其选择。
|
|
117
|
+
2. 不把 `check_environment` 作为例行前置步骤;仅在用户明确要求检查环境,或搜索出现环境/登录故障时调用。
|
|
118
|
+
3. 从用户请求提取关键词和条件,不添加用户未指定的 Persona、活跃度或业务画像。
|
|
119
|
+
4. 对请求中无法从已有结果核实的动态地区、行业、职位、列表等调用 inspect;使用页面候选原文,不为例行探测调用 inspect。
|
|
120
|
+
5. 区分公司总部与员工所在地;人数档位无法精确表达、币种不明时先澄清。
|
|
121
|
+
6. 按已核实条件搜索;“最多 N 条”使用 `require_result_count=false`,“需要 N 条”保留 true。
|
|
122
|
+
7. 公司→人员场景按公司顺序调用 `search_people`,携带相同的 `profile`、公司名称和 ID,保留来源公司关联。
|
|
123
|
+
8. 核对 `status`、`output_complete`、`output.data.complete`、实际应用条件和数量。
|
|
110
124
|
|
|
111
|
-
|
|
125
|
+
例如:“使用 Navigator 环境,找最多 5 家美国总部的 substation 相关公司,再找每家公司最多 3 位采购经理”。
|
|
112
126
|
Agent 先发现总部地区和职位候选,再搜索公司,随后按已验证公司名称、ID 和职位顺序搜索人员。
|
|
113
127
|
“采购经理”应通过职位候选核实,不直接当作未经页面核验的英文枚举。
|
|
114
128
|
公司无匹配可正常返回空列表;公司搜索失败的部分结果不能自动进入后续人员搜索。
|
|
@@ -136,6 +150,7 @@ Agent 先发现总部地区和职位候选,再搜索公司,随后按已验
|
|
|
136
150
|
```
|
|
137
151
|
|
|
138
152
|
上例展示外层字段,`data` 的实际必填字段遵循对应模块契约。
|
|
153
|
+
`profile` 回显本次请求中的环境名;缺失或非字符串时返回空字符串。
|
|
139
154
|
失败时 MCP `isError=true`,`status=failed`,`error={code,message,details}`;
|
|
140
155
|
若模块提供已验证的部分记录,保留在 `output`,并标记 `output_complete=false`。
|
|
141
156
|
模块错误细分码沿用 `error.details.module_code`。
|
|
@@ -143,7 +158,7 @@ Agent 先发现总部地区和职位候选,再搜索公司,随后按已验
|
|
|
143
158
|
|
|
144
159
|
| 错误 | 处理 |
|
|
145
160
|
| --- | --- |
|
|
146
|
-
| `INVALID_PARAMS` |
|
|
161
|
+
| `INVALID_PARAMS` | 补齐用户指定的非空 `profile` 或修正其他参数;公司查询补齐已经验证的名称和 ID |
|
|
147
162
|
| `ENV_NOT_RUNNING` / `ENV_AMBIGUOUS` | 启动指定环境或消除同名环境,不自动选择其他浏览器 |
|
|
148
163
|
| `FLASHID_API_ERROR` / `CDP_CONNECT_FAILED` | 检查本机 API 配置、权限、运行状态 |
|
|
149
164
|
| `ENV_BUSY` | 等待当前操作与清理完成,再提交搜索 |
|
|
@@ -163,6 +178,7 @@ SDK 同时支持旧版 initialize 握手和新版发现流程,均有真实 SDK
|
|
|
163
178
|
|
|
164
179
|
MCP 适配器直接复用 `automation.worker.execute_step` 的异步执行、参数/输出校验、
|
|
165
180
|
页面管理和超时逻辑。MCP 请求通过独立 asyncio Task 执行,以便响应取消并等待清理。
|
|
181
|
+
环境名来自各次请求的 `profile`,环境解析仍复用 `resolve_environment`,按名称唯一匹配运行记录。
|
|
166
182
|
原 CLI 的 Runner 与子进程执行方式保持兼容。公司和人员页面逻辑没有复制。
|
|
167
183
|
|
|
168
184
|
同一服务器拒绝重叠调用;同一操作系统用户的 MCP 进程通过文件锁协调相同
|
|
@@ -182,7 +198,10 @@ API origin 与运行环境 ID,锁位于 `~/.cache/flashid-auto/locks/`,文
|
|
|
182
198
|
验证记录见 `docs/linkedin-mcp-verification.json`。真实业务测试不进入自动化单元测试;
|
|
183
199
|
仅在明确的 `Navigator` 调试环境执行,不保存真实采集数据到发行包。
|
|
184
200
|
|
|
185
|
-
|
|
201
|
+
2026-10-26 环境选择变更验证:MCP 专项 74 项通过;非浏览器回归 402 项通过,
|
|
202
|
+
103 项浏览器测试未运行;Ruff 与 `git diff --check` 通过。本次未执行真实账号查询。
|
|
203
|
+
|
|
204
|
+
历史发行验收结果:完整 pytest 456 项通过,ruff 与依赖检查通过。真实 MCP 客户端完成五个工具、
|
|
186
205
|
公司→员工查询及创建标签页时的取消测试,原有标签页全部保留且没有遗留新页。
|
|
187
206
|
wheel 与源码包通过 Twine 和内容审查;干净环境从 wheel 安装后,两种启动入口均通过
|
|
188
207
|
工具发现和结构化错误调用验证。正式公开上传尚未执行。
|
|
@@ -120,7 +120,7 @@ JSON 链见 [linkedin-company-people-search.json](examples/linkedin-company-peop
|
|
|
120
120
|
|
|
121
121
|
单次输出为 `{"data":{},"records":[],"artifacts":[]}`。`data` 包含 `action`、`search_key`、`company_name`、`company_id`、`requested_filters`、`applied_filters`、`requested_count`、`collected_count`、`pages_visited`、`complete`、`search_url`、`result_count_text`。搜索还含 `require_result_count`、`result_count_met`,终止时含 `stop_reason`;检查时含 `filters`。
|
|
122
122
|
|
|
123
|
-
每条人员记录包含 `rank`、`lead_id`、`name`、`url`、`title`、`company_name`、`company_url`、`location`、`tenure_text`、`about`、`connection_degree`、`recent_activity_text`、`badges`。`url` 优先使用 `https://www.linkedin.com/in/{slug}`;若详情面板无法提供有效公开链接,则使用 `https://www.linkedin.com/sales/lead/{id}`。回退链接只保留 lead ID,不带逗号后的路由附加信息、查询参数或片段;已在 `Navigator` 验证纯 ID 地址可正常打开。模块从列表卡片读取资料,直接点击员工姓名打开同一搜索页上的侧边详情面板,核对员工 ID
|
|
123
|
+
每条人员记录包含 `rank`、`lead_id`、`name`、`url`、`title`、`company_name`、`company_url`、`location`、`tenure_text`、`about`、`connection_degree`、`recent_activity_text`、`badges`。`url` 优先使用 `https://www.linkedin.com/in/{slug}`;若详情面板无法提供有效公开链接,则使用 `https://www.linkedin.com/sales/lead/{id}`。回退链接只保留 lead ID,不带逗号后的路由附加信息、查询参数或片段;已在 `Navigator` 验证纯 ID 地址可正常打开。模块从列表卡片读取资料,直接点击员工姓名打开同一搜索页上的侧边详情面板,核对员工 ID 后等待异步加载的操作菜单或 “Unlock full profile” 状态:前者出现时展开菜单、等待 “View LinkedIn profile” 链接并提取;后者出现时立即使用 `/sales/lead/` 回退链接,不再等待公开链接。两者均未出现时达到配置超时后回退。最后关闭面板继续采集。不会用 `page.goto()` 打开员工详情。缺失的可选字段为空字符串或空数组,按 lead ID 去重。
|
|
124
124
|
|
|
125
125
|
失败沿用框架 `MODULE_FAILED`,细分 `error.details.module_code`:`FILTER_UNAVAILABLE`、`FILTER_OPTION_NOT_FOUND`、`FILTER_NOT_APPLIED`、`PAGE_UNSUPPORTED`、`PAGINATION_STALLED`、`INSUFFICIENT_RESULTS`、`LOGIN_REQUIRED`、`SEARCH_CHALLENGE`、`SEARCH_TIMEOUT`、`SEARCH_FAILED`。Current company 无候选,或提供的公司 ID 无法精确匹配时返回 `FILTER_OPTION_NOT_FOUND`;`require_result_count=false` 仅允许人员结果正常耗尽时不足目标数,不会忽略公司筛选失败。公开链接缺失或无效,以及详情面板打开或菜单操作失败时,回退到 `/sales/lead/`,继续搜索。其他失败保留已解析人员的部分输出但 `complete=false`。参数与绑定预检错误为 `INVALID_PARAMS`。
|
|
126
126
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import argparse
|
|
4
4
|
import asyncio
|
|
5
5
|
import logging
|
|
6
|
-
import os
|
|
7
6
|
import sys
|
|
8
7
|
from pathlib import Path
|
|
9
8
|
|
|
@@ -11,7 +10,6 @@ from pathlib import Path
|
|
|
11
10
|
def main(argv=None):
|
|
12
11
|
parser = argparse.ArgumentParser(description="LinkedIn Sales Navigator MCP server over stdio")
|
|
13
12
|
parser.add_argument("--env-file", type=Path, default=Path(".env"))
|
|
14
|
-
parser.add_argument("--profile", help="FlashID running environment (default: Navigator)")
|
|
15
13
|
parser.add_argument(
|
|
16
14
|
"--step-timeout",
|
|
17
15
|
type=float,
|
|
@@ -27,13 +25,7 @@ def main(argv=None):
|
|
|
27
25
|
from .service import LinkedInService
|
|
28
26
|
|
|
29
27
|
config = FlashIDConfig.from_env(args.env_file)
|
|
30
|
-
service = LinkedInService(
|
|
31
|
-
config,
|
|
32
|
-
args.profile
|
|
33
|
-
if args.profile is not None
|
|
34
|
-
else os.environ.get("LINKEDIN_MCP_PROFILE", "Navigator"),
|
|
35
|
-
step_timeout=args.step_timeout,
|
|
36
|
-
)
|
|
28
|
+
service = LinkedInService(config, step_timeout=args.step_timeout)
|
|
37
29
|
asyncio.run(serve(service))
|
|
38
30
|
except ModuleNotFoundError:
|
|
39
31
|
print(
|
|
@@ -23,15 +23,12 @@ class LinkedInService:
|
|
|
23
23
|
def __init__(
|
|
24
24
|
self,
|
|
25
25
|
config,
|
|
26
|
-
profile="Navigator",
|
|
27
26
|
*,
|
|
28
27
|
step_timeout=300,
|
|
29
28
|
client_factory=FlashIDClient,
|
|
30
29
|
executor=execute_step,
|
|
31
30
|
lock_directory=None,
|
|
32
31
|
):
|
|
33
|
-
if not isinstance(profile, str) or not profile.strip():
|
|
34
|
-
raise AutomationError("INVALID_REQUEST", "A non-empty profile name is required")
|
|
35
32
|
if (
|
|
36
33
|
isinstance(step_timeout, bool)
|
|
37
34
|
or not isinstance(step_timeout, (float, int))
|
|
@@ -40,7 +37,6 @@ class LinkedInService:
|
|
|
40
37
|
):
|
|
41
38
|
raise AutomationError("INVALID_REQUEST", "Step timeout must be finite and positive")
|
|
42
39
|
self.config = config
|
|
43
|
-
self.profile = profile
|
|
44
40
|
self.step_timeout = step_timeout
|
|
45
41
|
self.client_factory = client_factory
|
|
46
42
|
self.executor = executor
|
|
@@ -48,13 +44,13 @@ class LinkedInService:
|
|
|
48
44
|
self.specs = tool_specs()
|
|
49
45
|
self._busy = False
|
|
50
46
|
|
|
51
|
-
def _environment(self):
|
|
47
|
+
def _environment(self, profile):
|
|
52
48
|
with self.client_factory(self.config) as client:
|
|
53
|
-
return resolve_environment(client.list_running_browsers(),
|
|
49
|
+
return resolve_environment(client.list_running_browsers(), profile)
|
|
54
50
|
|
|
55
|
-
async def _execute(self, spec, params, run_id):
|
|
51
|
+
async def _execute(self, spec, params, profile, run_id):
|
|
56
52
|
# Requests sessions stay inside one thread and use the existing bounded HTTP timeouts.
|
|
57
|
-
environment = await asyncio.to_thread(self._environment)
|
|
53
|
+
environment = await asyncio.to_thread(self._environment, profile)
|
|
58
54
|
identity = self.config.base_url.rstrip("/") + "\n" + environment["id"]
|
|
59
55
|
digest = hashlib.sha256(identity.encode()).hexdigest()
|
|
60
56
|
self.lock_directory.mkdir(parents=True, exist_ok=True, mode=0o700)
|
|
@@ -101,7 +97,7 @@ class LinkedInService:
|
|
|
101
97
|
spec = self.specs.get(name)
|
|
102
98
|
result = {
|
|
103
99
|
"run_id": str(uuid.uuid4()),
|
|
104
|
-
"profile":
|
|
100
|
+
"profile": "",
|
|
105
101
|
"module_id": spec.module.module_id if spec else None,
|
|
106
102
|
"module_version": spec.module.module_version if spec else None,
|
|
107
103
|
"status": "failed",
|
|
@@ -115,13 +111,18 @@ class LinkedInService:
|
|
|
115
111
|
try:
|
|
116
112
|
if spec is None:
|
|
117
113
|
raise AutomationError("UNKNOWN_TOOL", "Unknown LinkedIn MCP tool")
|
|
118
|
-
|
|
114
|
+
arguments = json_snapshot(arguments, "INVALID_PARAMS")
|
|
115
|
+
if isinstance(arguments, dict) and isinstance(arguments.get("profile"), str):
|
|
116
|
+
result["profile"] = arguments["profile"]
|
|
117
|
+
params = spec.params(arguments)
|
|
119
118
|
params.setdefault("timeout_ms", 15000)
|
|
120
119
|
if self._busy:
|
|
121
120
|
raise AutomationError("ENV_BUSY", "This MCP server already holds the environment")
|
|
122
121
|
self._busy = True
|
|
123
122
|
acquired = True
|
|
124
|
-
task = asyncio.create_task(
|
|
123
|
+
task = asyncio.create_task(
|
|
124
|
+
self._execute(spec, params, result["profile"], result["run_id"])
|
|
125
|
+
)
|
|
125
126
|
try:
|
|
126
127
|
# Finish worker cleanup before releasing the lock on cancellation.
|
|
127
128
|
result.update(await asyncio.shield(task))
|
|
@@ -9,9 +9,14 @@ from flashid_auto.modules.linkedin_people_search import LinkedInPeopleSearchModu
|
|
|
9
9
|
from flashid_auto.modules.linkedin_sales_navigator import LinkedInSalesNavigatorModule
|
|
10
10
|
|
|
11
11
|
INSTRUCTIONS = """Search LinkedIn Sales Navigator in the user's existing FlashID browser.
|
|
12
|
-
Interpret the user's natural language and call the structured tools.
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
Interpret the user's natural language and call the structured tools. Every tool
|
|
13
|
+
requires profile: the exact FlashID environment name explicitly chosen by the user
|
|
14
|
+
in the conversation. If the user has not specified an environment, ask for its name
|
|
15
|
+
before calling any tool; never guess or use a default. Reuse the user's choice in
|
|
16
|
+
subsequent calls, including company-to-people chains, until the user changes it.
|
|
17
|
+
Pass profile on every call; the server does not store a selected environment.
|
|
18
|
+
Do not call check_environment as a routine preflight or health check; use it only
|
|
19
|
+
when the user explicitly asks for an environment/access check or when diagnosing an environment
|
|
15
20
|
failure. Keep inspect_company_filters available, but do not call it as a routine
|
|
16
21
|
preflight. Use an inspect tool only when the requested dynamic filter value or ID
|
|
17
22
|
cannot be verified from the request or prior tool output; never invent LinkedIn option
|
|
@@ -51,6 +56,7 @@ class ToolSpec:
|
|
|
51
56
|
"Arguments do not match the tool schema",
|
|
52
57
|
{"paths": [list(error.absolute_path) for error in errors]},
|
|
53
58
|
)
|
|
59
|
+
arguments = {key: value for key, value in arguments.items() if key != "profile"}
|
|
54
60
|
if self.name == "check_environment":
|
|
55
61
|
arguments = {"inspect_filter": "company_headcount"}
|
|
56
62
|
return self.module.validate_params({**arguments, "action": self.action})
|
|
@@ -101,7 +107,7 @@ def tool_specs():
|
|
|
101
107
|
"check_environment",
|
|
102
108
|
company,
|
|
103
109
|
"inspect",
|
|
104
|
-
"Check the
|
|
110
|
+
"Check the user-selected FlashID environment and Sales Navigator access by opening "
|
|
105
111
|
"a temporary company search page. Does not search for records or change saved data.",
|
|
106
112
|
{"type": "object", "additionalProperties": False, "properties": {}},
|
|
107
113
|
),
|
|
@@ -146,6 +152,18 @@ def tool_specs():
|
|
|
146
152
|
module_schema(people, "search"),
|
|
147
153
|
),
|
|
148
154
|
]
|
|
155
|
+
for spec in specs:
|
|
156
|
+
spec.schema["properties"]["profile"] = {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"minLength": 1,
|
|
159
|
+
"pattern": r"\S",
|
|
160
|
+
"description": (
|
|
161
|
+
"Exact name of the running FlashID environment explicitly chosen by the user "
|
|
162
|
+
"in the conversation. Required on every call; ask the user if unspecified. "
|
|
163
|
+
"There is no default environment."
|
|
164
|
+
),
|
|
165
|
+
}
|
|
166
|
+
spec.schema.setdefault("required", []).append("profile")
|
|
149
167
|
return {spec.name: spec for spec in specs}
|
|
150
168
|
|
|
151
169
|
|
{flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/linkedin_people_search.py
RENAMED
|
@@ -188,14 +188,61 @@ class LeadSearchPage(SalesPage):
|
|
|
188
188
|
header_id = re.match(r"^/sales/lead/([^,/]+)", header_path)
|
|
189
189
|
if not header_id or header_id[1] != lead_url.rsplit("/", 1)[1]:
|
|
190
190
|
return lead_url
|
|
191
|
-
trigger = panel.get_by_role("button", name="Open actions overflow menu").first
|
|
192
191
|
# The panel header renders before the asynchronously loaded lead details.
|
|
193
|
-
# Wait for the
|
|
194
|
-
await
|
|
192
|
+
# Wait for either the public-profile action or the account-gated unlock state.
|
|
193
|
+
state = await self.page.wait_for_function(
|
|
194
|
+
r"""selector => {
|
|
195
|
+
const root = document.querySelector(selector);
|
|
196
|
+
if (!root) return false;
|
|
197
|
+
const visible = element => {
|
|
198
|
+
const style = window.getComputedStyle(element);
|
|
199
|
+
return style.display !== "none" &&
|
|
200
|
+
style.visibility !== "hidden" &&
|
|
201
|
+
!!(element.offsetWidth || element.offsetHeight ||
|
|
202
|
+
element.getClientRects().length);
|
|
203
|
+
};
|
|
204
|
+
const controls = root.querySelectorAll("button, a, [role='button']");
|
|
205
|
+
const unlock = Array.from(controls).some(element =>
|
|
206
|
+
element.textContent.trim() === "Unlock full profile" && visible(element));
|
|
207
|
+
const actions = Array.from(root.querySelectorAll(
|
|
208
|
+
"[aria-label='Open actions overflow menu']"
|
|
209
|
+
)).some(visible);
|
|
210
|
+
if (unlock) return "unlock";
|
|
211
|
+
return actions ? "actions" : false;
|
|
212
|
+
}""",
|
|
213
|
+
arg="#inline-sidesheet-outlet",
|
|
214
|
+
timeout=optional_timeout,
|
|
215
|
+
)
|
|
216
|
+
if await state.json_value() == "unlock":
|
|
217
|
+
await state.dispose()
|
|
218
|
+
return lead_url
|
|
219
|
+
await state.dispose()
|
|
220
|
+
trigger = None
|
|
221
|
+
triggers = panel.get_by_role("button", name="Open actions overflow menu", exact=True)
|
|
222
|
+
for index in range(await triggers.count()):
|
|
223
|
+
candidate = triggers.nth(index)
|
|
224
|
+
if await candidate.is_visible():
|
|
225
|
+
trigger = candidate
|
|
226
|
+
break
|
|
227
|
+
if trigger is None:
|
|
228
|
+
return lead_url
|
|
195
229
|
await trigger.click(timeout=optional_timeout)
|
|
196
230
|
link = self.page.get_by_role("link", name="View LinkedIn profile", exact=True)
|
|
197
|
-
await
|
|
198
|
-
|
|
231
|
+
await self.page.wait_for_function(
|
|
232
|
+
r"""() => Array.from(document.querySelectorAll("a")).some(element => {
|
|
233
|
+
const style = window.getComputedStyle(element);
|
|
234
|
+
return element.textContent.trim() === "View LinkedIn profile" &&
|
|
235
|
+
style.display !== "none" && style.visibility !== "hidden" &&
|
|
236
|
+
!!(element.offsetWidth || element.offsetHeight ||
|
|
237
|
+
element.getClientRects().length);
|
|
238
|
+
})""",
|
|
239
|
+
timeout=optional_timeout,
|
|
240
|
+
)
|
|
241
|
+
for index in range(await link.count()):
|
|
242
|
+
candidate = link.nth(index)
|
|
243
|
+
if await candidate.is_visible():
|
|
244
|
+
return profile_url(await candidate.get_attribute("href")) or lead_url
|
|
245
|
+
return lead_url
|
|
199
246
|
except (PlaywrightError, ValueError):
|
|
200
247
|
return lead_url
|
|
201
248
|
finally:
|
|
@@ -15,7 +15,9 @@ import anyio # noqa: E402
|
|
|
15
15
|
from mcp import Client # noqa: E402
|
|
16
16
|
from mcp.client.stdio import StdioServerParameters # noqa: E402
|
|
17
17
|
|
|
18
|
+
from flashid_auto.cli import main as cli_main # noqa: E402
|
|
18
19
|
from flashid_auto.flashid import FlashIDConfig, FlashIDTransportError # noqa: E402
|
|
20
|
+
from flashid_auto.mcp.__main__ import main as mcp_main # noqa: E402
|
|
19
21
|
from flashid_auto.mcp.server import create_server # noqa: E402
|
|
20
22
|
from flashid_auto.mcp.service import LinkedInService # noqa: E402
|
|
21
23
|
from flashid_auto.mcp.tools import RESULT_SCHEMA, tool_specs # noqa: E402
|
|
@@ -27,6 +29,14 @@ RUNNING = {
|
|
|
27
29
|
"ws": {"puppeteer": "ws://127.0.0.1:9222/devtools/browser/fake"},
|
|
28
30
|
}
|
|
29
31
|
|
|
32
|
+
TOOL_ARGUMENTS = {
|
|
33
|
+
"check_environment": {},
|
|
34
|
+
"inspect_company_filters": {"inspect_filter": "company_headcount"},
|
|
35
|
+
"search_companies": {"search_key": "test"},
|
|
36
|
+
"inspect_people_filters": {"inspect_filter": "current_company", "suggestion": "Example"},
|
|
37
|
+
"search_people": {"company_name": "Example", "company_id": "123"},
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
|
|
31
41
|
class FakeClient:
|
|
32
42
|
rows = [RUNNING]
|
|
@@ -90,11 +100,16 @@ def test_tool_schemas_reuse_modules_and_exclude_unsafe_company_fallback():
|
|
|
90
100
|
}
|
|
91
101
|
for spec in specs.values():
|
|
92
102
|
Draft202012Validator.check_schema(spec.schema)
|
|
103
|
+
assert "profile" in spec.schema["required"]
|
|
104
|
+
assert "default" not in spec.schema["properties"]["profile"]
|
|
105
|
+
assert "profile" not in spec.module.params_schema["properties"]
|
|
93
106
|
people = specs["search_people"]
|
|
94
107
|
assert "current_company" not in people.schema["properties"]["filters"]["properties"]
|
|
95
108
|
# Building the public schema must not mutate the original module.
|
|
96
109
|
assert "current_company" in people.module.params_schema["properties"]["filters"]["properties"]
|
|
97
|
-
|
|
110
|
+
params = people.params({"profile": "Navigator", "company_name": "Example", "company_id": "123"})
|
|
111
|
+
assert params["company_id"] == "123"
|
|
112
|
+
assert "profile" not in params
|
|
98
113
|
|
|
99
114
|
|
|
100
115
|
@pytest.mark.parametrize(
|
|
@@ -109,23 +124,92 @@ def test_tool_schemas_reuse_modules_and_exclude_unsafe_company_fallback():
|
|
|
109
124
|
("search_people", {"filters": {"current_company": {"include": ["Ambiguous"]}}}),
|
|
110
125
|
("inspect_people_filters", {"suggestion": "test"}),
|
|
111
126
|
("inspect_company_filters", {"search_key": "test"}),
|
|
112
|
-
("check_environment", {"
|
|
127
|
+
("check_environment", {"unexpected": "other"}),
|
|
113
128
|
("search_companies", []),
|
|
114
129
|
("search_companies", {"result_count": float("nan")}),
|
|
115
130
|
],
|
|
116
131
|
)
|
|
117
132
|
def test_invalid_requests_do_not_touch_browser(tmp_path, name, arguments):
|
|
133
|
+
def forbidden_client(_config):
|
|
134
|
+
pytest.fail("Invalid requests must not query FlashID")
|
|
135
|
+
|
|
118
136
|
async def forbidden(_request):
|
|
119
137
|
pytest.fail("Invalid requests must not execute")
|
|
120
138
|
|
|
121
139
|
app = service(tmp_path)
|
|
140
|
+
app.client_factory = forbidden_client
|
|
122
141
|
app.executor = forbidden
|
|
142
|
+
if isinstance(arguments, dict):
|
|
143
|
+
arguments = {"profile": "Navigator", **arguments}
|
|
123
144
|
result = asyncio.run(app.call(name, arguments))
|
|
124
145
|
assert result["status"] == "failed"
|
|
125
146
|
assert result["error"]["code"] == "INVALID_PARAMS"
|
|
126
147
|
Draft202012Validator(RESULT_SCHEMA).validate(result)
|
|
127
148
|
|
|
128
149
|
|
|
150
|
+
@pytest.mark.parametrize("name", TOOL_ARGUMENTS)
|
|
151
|
+
@pytest.mark.parametrize(
|
|
152
|
+
"profile",
|
|
153
|
+
[
|
|
154
|
+
{},
|
|
155
|
+
{"profile": ""},
|
|
156
|
+
{"profile": " \t\n\u3000"},
|
|
157
|
+
{"profile": None},
|
|
158
|
+
{"profile": 123},
|
|
159
|
+
{"profile": True},
|
|
160
|
+
{"profile": []},
|
|
161
|
+
{"profile": {}},
|
|
162
|
+
],
|
|
163
|
+
)
|
|
164
|
+
def test_profile_is_required_before_querying_flashid(tmp_path, name, profile):
|
|
165
|
+
def forbidden_client(_config):
|
|
166
|
+
pytest.fail("Missing or invalid profile must not query FlashID")
|
|
167
|
+
|
|
168
|
+
app = service(tmp_path)
|
|
169
|
+
app.client_factory = forbidden_client
|
|
170
|
+
result = asyncio.run(app.call(name, {**TOOL_ARGUMENTS[name], **profile}))
|
|
171
|
+
assert result["status"] == "failed"
|
|
172
|
+
assert result["error"]["code"] == "INVALID_PARAMS"
|
|
173
|
+
Draft202012Validator(RESULT_SCHEMA).validate(result)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@pytest.mark.parametrize("name", TOOL_ARGUMENTS)
|
|
177
|
+
def test_each_call_selects_its_environment(tmp_path, monkeypatch, name):
|
|
178
|
+
other = {
|
|
179
|
+
**RUNNING,
|
|
180
|
+
"id": "other-browser",
|
|
181
|
+
"name": "测试环境 B",
|
|
182
|
+
"ws": {"puppeteer": "ws://127.0.0.1:9223/devtools/browser/other"},
|
|
183
|
+
}
|
|
184
|
+
monkeypatch.setattr(FakeClient, "rows", [RUNNING, other])
|
|
185
|
+
requests = []
|
|
186
|
+
|
|
187
|
+
async def executor(request):
|
|
188
|
+
requests.append(request)
|
|
189
|
+
return success(request)
|
|
190
|
+
|
|
191
|
+
async def scenario():
|
|
192
|
+
app = service(tmp_path)
|
|
193
|
+
app.executor = executor
|
|
194
|
+
for row in (RUNNING, other, RUNNING):
|
|
195
|
+
arguments = {"profile": row["name"], **TOOL_ARGUMENTS[name]}
|
|
196
|
+
original = deepcopy(arguments)
|
|
197
|
+
result = await app.call(name, arguments)
|
|
198
|
+
assert result["status"] == "succeeded"
|
|
199
|
+
assert result["profile"] == row["name"]
|
|
200
|
+
assert requests[-1]["running_browser_id"] == row["id"]
|
|
201
|
+
assert requests[-1]["endpoint"] == row["ws"]["puppeteer"]
|
|
202
|
+
assert "profile" not in requests[-1]["params"]
|
|
203
|
+
assert arguments == original
|
|
204
|
+
# A previous choice is never an implicit fallback for the next request.
|
|
205
|
+
missing = await app.call(name, TOOL_ARGUMENTS[name])
|
|
206
|
+
assert missing["error"]["code"] == "INVALID_PARAMS"
|
|
207
|
+
assert missing["profile"] == ""
|
|
208
|
+
assert len(requests) == 3
|
|
209
|
+
|
|
210
|
+
asyncio.run(scenario())
|
|
211
|
+
|
|
212
|
+
|
|
129
213
|
def test_success_and_default_timeout(tmp_path):
|
|
130
214
|
requests = []
|
|
131
215
|
|
|
@@ -135,8 +219,9 @@ def test_success_and_default_timeout(tmp_path):
|
|
|
135
219
|
|
|
136
220
|
app = service(tmp_path)
|
|
137
221
|
app.executor = executor
|
|
138
|
-
result = asyncio.run(app.call("check_environment", {}))
|
|
222
|
+
result = asyncio.run(app.call("check_environment", {"profile": "Navigator"}))
|
|
139
223
|
assert result["status"] == "succeeded"
|
|
224
|
+
assert result["profile"] == "Navigator"
|
|
140
225
|
assert result["output_complete"] and result["cleanup_complete"]
|
|
141
226
|
assert requests[0]["params"]["inspect_filter"] == "company_headcount"
|
|
142
227
|
assert requests[0]["params"]["timeout_ms"] == 15000
|
|
@@ -148,14 +233,16 @@ def test_success_and_default_timeout(tmp_path):
|
|
|
148
233
|
"rows,code",
|
|
149
234
|
[
|
|
150
235
|
([], "ENV_NOT_RUNNING"),
|
|
236
|
+
([{**RUNNING, "name": "Other"}], "ENV_NOT_RUNNING"),
|
|
151
237
|
([RUNNING, RUNNING], "ENV_AMBIGUOUS"),
|
|
152
238
|
([{**RUNNING, "ws": {}}], "CDP_CONNECT_FAILED"),
|
|
153
239
|
],
|
|
154
240
|
)
|
|
155
241
|
def test_environment_errors(tmp_path, monkeypatch, rows, code):
|
|
156
242
|
monkeypatch.setattr(FakeClient, "rows", rows)
|
|
157
|
-
result = asyncio.run(service(tmp_path).call("check_environment", {}))
|
|
243
|
+
result = asyncio.run(service(tmp_path).call("check_environment", {"profile": "Navigator"}))
|
|
158
244
|
assert result["error"]["code"] == code
|
|
245
|
+
assert result["profile"] == "Navigator"
|
|
159
246
|
|
|
160
247
|
|
|
161
248
|
def test_secret_exceptions_and_unknown_tools(tmp_path):
|
|
@@ -165,7 +252,7 @@ def test_secret_exceptions_and_unknown_tools(tmp_path):
|
|
|
165
252
|
|
|
166
253
|
app = service(tmp_path)
|
|
167
254
|
app.client_factory = BrokenClient
|
|
168
|
-
result = asyncio.run(app.call("check_environment", {}))
|
|
255
|
+
result = asyncio.run(app.call("check_environment", {"profile": "Navigator"}))
|
|
169
256
|
assert result["error"]["code"] == "FLASHID_API_ERROR"
|
|
170
257
|
assert "DO-NOT-EXPOSE" not in json.dumps(result)
|
|
171
258
|
assert asyncio.run(app.call("no_such_tool", {}))["error"]["code"] == "UNKNOWN_TOOL"
|
|
@@ -188,7 +275,9 @@ def test_partial_output_is_preserved_as_failure(tmp_path):
|
|
|
188
275
|
|
|
189
276
|
app = service(tmp_path)
|
|
190
277
|
app.executor = executor
|
|
191
|
-
result = asyncio.run(
|
|
278
|
+
result = asyncio.run(
|
|
279
|
+
app.call("search_companies", {"profile": "Navigator", "search_key": "test"})
|
|
280
|
+
)
|
|
192
281
|
assert result["status"] == "failed"
|
|
193
282
|
assert result["output"] is not None
|
|
194
283
|
assert not result["output_complete"]
|
|
@@ -203,7 +292,7 @@ def test_invalid_worker_success_is_rejected(tmp_path):
|
|
|
203
292
|
|
|
204
293
|
app = service(tmp_path)
|
|
205
294
|
app.executor = executor
|
|
206
|
-
result = asyncio.run(app.call("check_environment", {}))
|
|
295
|
+
result = asyncio.run(app.call("check_environment", {"profile": "Navigator"}))
|
|
207
296
|
assert result["error"]["code"] == "INVALID_OUTPUT"
|
|
208
297
|
assert result["output"] is None
|
|
209
298
|
assert result["cleanup_complete"] is False
|
|
@@ -226,20 +315,21 @@ def test_busy_across_instances_and_cancel_waits_for_cleanup(tmp_path):
|
|
|
226
315
|
app = service(tmp_path)
|
|
227
316
|
app.executor = executor
|
|
228
317
|
other = service(tmp_path)
|
|
229
|
-
|
|
318
|
+
arguments = {"profile": "Navigator"}
|
|
319
|
+
task = asyncio.create_task(app.call("check_environment", arguments))
|
|
230
320
|
await asyncio.wait_for(started.wait(), 2)
|
|
231
|
-
assert (await app.call("check_environment",
|
|
232
|
-
assert (await other.call("check_environment",
|
|
321
|
+
assert (await app.call("check_environment", arguments))["error"]["code"] == "ENV_BUSY"
|
|
322
|
+
assert (await other.call("check_environment", arguments))["error"]["code"] == "ENV_BUSY"
|
|
233
323
|
task.cancel()
|
|
234
324
|
await asyncio.wait_for(cleaning.wait(), 2)
|
|
235
325
|
assert not task.done()
|
|
236
|
-
assert (await other.call("check_environment",
|
|
326
|
+
assert (await other.call("check_environment", arguments))["error"]["code"] == "ENV_BUSY"
|
|
237
327
|
finish_cleanup.set()
|
|
238
328
|
with pytest.raises(asyncio.CancelledError):
|
|
239
329
|
await task
|
|
240
|
-
assert (await other.call("check_environment",
|
|
330
|
+
assert (await other.call("check_environment", arguments))["status"] == "succeeded"
|
|
241
331
|
app.executor = successful_executor
|
|
242
|
-
assert (await app.call("check_environment",
|
|
332
|
+
assert (await app.call("check_environment", arguments))["status"] == "succeeded"
|
|
243
333
|
|
|
244
334
|
asyncio.run(scenario())
|
|
245
335
|
|
|
@@ -261,7 +351,7 @@ def test_anyio_cancel_scope_preserves_async_cleanup(tmp_path):
|
|
|
261
351
|
app.executor = executor
|
|
262
352
|
with anyio.CancelScope() as scope:
|
|
263
353
|
async with anyio.create_task_group() as tasks:
|
|
264
|
-
tasks.start_soon(app.call, "check_environment", {})
|
|
354
|
+
tasks.start_soon(app.call, "check_environment", {"profile": "Navigator"})
|
|
265
355
|
await started.wait()
|
|
266
356
|
scope.cancel()
|
|
267
357
|
assert cleaned.is_set()
|
|
@@ -277,16 +367,35 @@ def test_real_sdk_in_memory_transport(tmp_path, mode):
|
|
|
277
367
|
tools = await client.list_tools()
|
|
278
368
|
assert len(tools.tools) == 5
|
|
279
369
|
assert all(tool.annotations.read_only_hint for tool in tools.tools)
|
|
280
|
-
|
|
370
|
+
assert all("profile" in tool.input_schema["required"] for tool in tools.tools)
|
|
371
|
+
result = await client.call_tool(
|
|
372
|
+
"search_companies", {"profile": "Navigator", "search_key": "test"}
|
|
373
|
+
)
|
|
281
374
|
assert not result.is_error
|
|
282
375
|
assert result.structured_content["status"] == "succeeded"
|
|
283
|
-
|
|
376
|
+
assert result.structured_content["profile"] == "Navigator"
|
|
377
|
+
missing = await client.call_tool("check_environment", {})
|
|
378
|
+
assert missing.is_error
|
|
379
|
+
assert missing.structured_content["error"]["code"] == "INVALID_PARAMS"
|
|
380
|
+
failed = await client.call_tool(
|
|
381
|
+
"search_people", {"profile": "Navigator", "company_name": "Unknown"}
|
|
382
|
+
)
|
|
284
383
|
assert failed.is_error
|
|
285
384
|
assert failed.structured_content["error"]["code"] == "INVALID_PARAMS"
|
|
286
385
|
|
|
287
386
|
asyncio.run(scenario())
|
|
288
387
|
|
|
289
388
|
|
|
389
|
+
@pytest.mark.parametrize("entrypoint,prefix", [(mcp_main, []), (cli_main, ["mcp"])])
|
|
390
|
+
def test_mcp_entrypoints_reject_profile_startup_argument(capsys, entrypoint, prefix):
|
|
391
|
+
with pytest.raises(SystemExit) as caught:
|
|
392
|
+
entrypoint([*prefix, "--profile", "Navigator"])
|
|
393
|
+
assert caught.value.code == 2
|
|
394
|
+
captured = capsys.readouterr()
|
|
395
|
+
assert "unrecognized arguments: --profile Navigator" in captured.err
|
|
396
|
+
assert captured.out == ""
|
|
397
|
+
|
|
398
|
+
|
|
290
399
|
@pytest.mark.parametrize(
|
|
291
400
|
"entry",
|
|
292
401
|
[
|
|
@@ -305,16 +414,24 @@ def test_real_stdio_client_initialization_discovery_and_call(tmp_path, entry):
|
|
|
305
414
|
"FLASHID_API_KEY": "",
|
|
306
415
|
"FLASHID_CONNECT_TIMEOUT": "0.1",
|
|
307
416
|
"FLASHID_READ_TIMEOUT": "0.1",
|
|
417
|
+
"LINKEDIN_MCP_PROFILE": "Ignored legacy setting",
|
|
308
418
|
},
|
|
309
419
|
cwd=tmp_path,
|
|
310
420
|
)
|
|
311
421
|
async with Client(params, mode="legacy") as client:
|
|
312
422
|
tools = await client.list_tools()
|
|
313
423
|
assert len(tools.tools) == 5
|
|
314
|
-
|
|
424
|
+
assert all("profile" in tool.input_schema["required"] for tool in tools.tools)
|
|
425
|
+
missing = await client.call_tool("check_environment", {})
|
|
426
|
+
assert missing.is_error
|
|
427
|
+
assert missing.structured_content["error"]["code"] == "INVALID_PARAMS"
|
|
428
|
+
result = await client.call_tool("check_environment", {"profile": "Navigator"})
|
|
315
429
|
assert result.is_error
|
|
316
430
|
assert result.structured_content["error"]["code"] == "FLASHID_API_ERROR"
|
|
317
|
-
|
|
431
|
+
assert result.structured_content["profile"] == "Navigator"
|
|
432
|
+
invalid = await client.call_tool(
|
|
433
|
+
"search_companies", {"profile": "Navigator", "search_key": "test", "x": 1}
|
|
434
|
+
)
|
|
318
435
|
assert invalid.is_error
|
|
319
436
|
assert invalid.structured_content["error"]["code"] == "INVALID_PARAMS"
|
|
320
437
|
|
|
@@ -116,6 +116,7 @@ def people_html(
|
|
|
116
116
|
profile_href=None,
|
|
117
117
|
no_detail_panel=False,
|
|
118
118
|
locked_profile=False,
|
|
119
|
+
unlock_full_profile=False,
|
|
119
120
|
ambiguous_company=False,
|
|
120
121
|
detail_delay_ms=0,
|
|
121
122
|
menu_delay_ms=50,
|
|
@@ -157,7 +158,8 @@ def people_html(
|
|
|
157
158
|
<script>
|
|
158
159
|
const total=TOTAL, broken=BROKEN, missingCompany=MISSING_COMPANY;
|
|
159
160
|
const profileHref=PROFILE_HREF_VALUE, noDetailPanel=NO_DETAIL_PANEL_VALUE;
|
|
160
|
-
const lockedProfile=LOCKED_PROFILE_VALUE,
|
|
161
|
+
const lockedProfile=LOCKED_PROFILE_VALUE, unlockFullProfile=UNLOCK_FULL_PROFILE_VALUE;
|
|
162
|
+
const ambiguousCompany=AMBIGUOUS_COMPANY_VALUE;
|
|
161
163
|
const detailDelay=DETAIL_DELAY_VALUE, menuDelay=MENU_DELAY_VALUE;
|
|
162
164
|
const noCompanyCandidates=NO_COMPANY_CANDIDATES_VALUE;
|
|
163
165
|
let batch=0, revision=0;
|
|
@@ -239,11 +241,17 @@ def people_html(
|
|
|
239
241
|
outlet.querySelector('[aria-label="Dismiss"]').onclick=()=>outlet.innerHTML='';
|
|
240
242
|
setTimeout(()=>{
|
|
241
243
|
if(!header.isConnected)return;
|
|
244
|
+
if(unlockFullProfile){
|
|
245
|
+
outlet.insertAdjacentHTML('beforeend','<button>Unlock full profile</button>');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
242
248
|
if(lockedProfile)return;
|
|
243
249
|
outlet.insertAdjacentHTML('beforeend',
|
|
250
|
+
'<button hidden aria-label="Open actions overflow menu">Actions</button>'+
|
|
244
251
|
'<button aria-label="Open actions overflow menu">Actions</button>'+
|
|
245
|
-
(href?'<a hidden href="'+href+'">View LinkedIn profile</a>'
|
|
246
|
-
|
|
252
|
+
(href?'<a hidden href="'+href+'">View LinkedIn profile</a>'+
|
|
253
|
+
'<a href="'+href+'">View LinkedIn profile</a>':''));
|
|
254
|
+
outlet.querySelectorAll('[aria-label="Open actions overflow menu"]')[1].onclick=()=>
|
|
247
255
|
setTimeout(()=>{for(const a of outlet.querySelectorAll('a'))a.hidden=false},menuDelay);
|
|
248
256
|
},detailDelay);
|
|
249
257
|
}
|
|
@@ -269,6 +277,7 @@ def people_html(
|
|
|
269
277
|
.replace("PROFILE_HREF_VALUE", json.dumps(profile_href))
|
|
270
278
|
.replace("NO_DETAIL_PANEL_VALUE", "true" if no_detail_panel else "false")
|
|
271
279
|
.replace("LOCKED_PROFILE_VALUE", "true" if locked_profile else "false")
|
|
280
|
+
.replace("UNLOCK_FULL_PROFILE_VALUE", "true" if unlock_full_profile else "false")
|
|
272
281
|
.replace("AMBIGUOUS_COMPANY_VALUE", json.dumps(ambiguous_company))
|
|
273
282
|
.replace("DETAIL_DELAY_VALUE", str(detail_delay_ms))
|
|
274
283
|
.replace("MENU_DELAY_VALUE", str(menu_delay_ms))
|
|
@@ -544,6 +553,19 @@ def test_locked_profile_falls_back_after_configured_timeout():
|
|
|
544
553
|
assert time.monotonic() - started < 5
|
|
545
554
|
|
|
546
555
|
|
|
556
|
+
@pytest.mark.browser
|
|
557
|
+
def test_unlock_full_profile_skips_public_profile_wait():
|
|
558
|
+
started = time.monotonic()
|
|
559
|
+
result = asyncio.run(
|
|
560
|
+
execute(
|
|
561
|
+
{"company_name": "Qualitrol", "result_count": 1, "timeout_ms": 5000},
|
|
562
|
+
html=people_html(total=1, unlock_full_profile=True, detail_delay_ms=100),
|
|
563
|
+
)
|
|
564
|
+
)
|
|
565
|
+
assert result["records"][0]["url"] == "https://www.linkedin.com/sales/lead/1"
|
|
566
|
+
assert time.monotonic() - started < 2
|
|
567
|
+
|
|
568
|
+
|
|
547
569
|
@pytest.mark.browser
|
|
548
570
|
@pytest.mark.parametrize("detail_delay,menu_delay", [(500, 50), (3300, 50), (50, 3300)])
|
|
549
571
|
def test_public_profile_waits_for_delayed_details_and_menu(detail_delay, menu_delay):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{flashid_auto-0.2.2 → flashid_auto-0.2.4}/src/flashid_auto/modules/linkedin_sales_navigator.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|