cnks 0.1.1__tar.gz → 0.2.2__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.
- {cnks-0.1.1 → cnks-0.2.2}/CURSOR_CONNECTION.md +1 -1
- cnks-0.2.2/PKG-INFO +187 -0
- cnks-0.2.2/README.md +176 -0
- cnks-0.2.2/cnks.log +1120 -0
- cnks-0.2.2/oldmain.py +255 -0
- {cnks-0.1.1 → cnks-0.2.2}/pyproject.toml +2 -2
- cnks-0.2.2/src/cnks/__init__.py +50 -0
- cnks-0.2.2/src/cnks/chrome_extractor.py +413 -0
- cnks-0.2.2/src/cnks/extractor.py +250 -0
- {cnks-0.1.1 → cnks-0.2.2}/src/cnks/server.py +125 -101
- cnks-0.1.1/PKG-INFO +0 -841
- cnks-0.1.1/README.md +0 -830
- cnks-0.1.1/cnks.log +0 -246
- cnks-0.1.1/src/cnks/__init__.py +0 -39
- {cnks-0.1.1 → cnks-0.2.2}/.python-version +0 -0
cnks-0.2.2/PKG-INFO
ADDED
@@ -0,0 +1,187 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: cnks
|
3
|
+
Version: 0.2.2
|
4
|
+
Summary: CNKI Search tool with Chrome browser integration
|
5
|
+
Author-email: bai-z-l <b@iziliang.com>
|
6
|
+
Requires-Python: >=3.10
|
7
|
+
Requires-Dist: mcp[cli]>=1.6.0
|
8
|
+
Requires-Dist: playwright>=1.51.0
|
9
|
+
Requires-Dist: pydantic>=2.11.3
|
10
|
+
Description-Content-Type: text/markdown
|
11
|
+
|
12
|
+
# 知网搜索MCP服务器
|
13
|
+
|
14
|
+
该MCP服务器可以帮助您打开Chrome浏览器访问中国知网,搜索关键词并提取论文详细内容。
|
15
|
+
|
16
|
+
## 功能
|
17
|
+
|
18
|
+
- 打开Chrome浏览器访问知网
|
19
|
+
- 提供关键词搜索工具
|
20
|
+
- **自动提取论文完整内容**(v0.2.0新增)
|
21
|
+
- **将搜索结果转换为结构化JSON数据**(v0.2.0新增)
|
22
|
+
- 允许用户保存笔记
|
23
|
+
|
24
|
+
## 版本更新
|
25
|
+
|
26
|
+
### v0.2.2
|
27
|
+
- 优化Chrome浏览器本地调用,不再尝试下载Chromium
|
28
|
+
- 增强错误处理和日志记录
|
29
|
+
- 降低Python版本要求至3.10,提高兼容性
|
30
|
+
- 修复若干bug和稳定性问题
|
31
|
+
|
32
|
+
### v0.2.0
|
33
|
+
- 简化工具接口,统一为单一的`mcp_cnks_search_and_extract`工具
|
34
|
+
- 实现一步式搜索和内容提取
|
35
|
+
- 支持从搜索结果提取50篇论文的完整内容
|
36
|
+
- 结果包含标题、作者、摘要、关键词和引用格式等信息
|
37
|
+
|
38
|
+
### v0.1.1
|
39
|
+
- 初始版本
|
40
|
+
- 基本搜索功能
|
41
|
+
- 提供链接列表
|
42
|
+
|
43
|
+
## 安装
|
44
|
+
|
45
|
+
确保您已安装Python 3.10或更高版本,然后执行以下命令安装:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
uv add "mcp[cli]"
|
49
|
+
```
|
50
|
+
|
51
|
+
## 安装Playwright(必需)
|
52
|
+
|
53
|
+
为了实现自动搜索和内容提取功能,必须安装Playwright:
|
54
|
+
|
55
|
+
```bash
|
56
|
+
# 安装playwright库
|
57
|
+
uv add playwright
|
58
|
+
|
59
|
+
# 安装playwright浏览器
|
60
|
+
playwright install
|
61
|
+
```
|
62
|
+
|
63
|
+
## 开发模式运行
|
64
|
+
|
65
|
+
使用MCP Inspector测试和调试服务器:
|
66
|
+
|
67
|
+
```bash
|
68
|
+
mcp dev src/cnks/server.py
|
69
|
+
```
|
70
|
+
|
71
|
+
## 安装到Claude Desktop
|
72
|
+
|
73
|
+
准备好后,将其安装到Claude Desktop:
|
74
|
+
|
75
|
+
```bash
|
76
|
+
mcp install src/cnks/server.py --name "知网搜索助手"
|
77
|
+
```
|
78
|
+
|
79
|
+
## 使用方法
|
80
|
+
|
81
|
+
在Claude或其他支持MCP的应用中可以使用以下工具:
|
82
|
+
|
83
|
+
### 工具
|
84
|
+
|
85
|
+
- `mcp_cnks_search_and_extract` - 搜索关键词并提取所有论文的详细内容
|
86
|
+
|
87
|
+
### 资源
|
88
|
+
|
89
|
+
- `webpage://current` - 当前打开的网页内容
|
90
|
+
- `webpage://cnki/search` - 中国知网搜索页面
|
91
|
+
- `note://internal/{name}` - 用户保存的笔记
|
92
|
+
|
93
|
+
### 提示
|
94
|
+
|
95
|
+
- `search-literature` - 按主题搜索文献
|
96
|
+
- `advanced-search` - 高级文献搜索
|
97
|
+
- `summarize-notes` - 总结所有笔记
|
98
|
+
|
99
|
+
## 示例用法
|
100
|
+
|
101
|
+
### 搜索并提取内容
|
102
|
+
|
103
|
+
```
|
104
|
+
请使用mcp_cnks_search_and_extract工具搜索"人工智能教育应用"相关论文并提取详细内容
|
105
|
+
```
|
106
|
+
|
107
|
+
### 使用高级搜索
|
108
|
+
|
109
|
+
```
|
110
|
+
请使用高级搜索,查找标题包含"教育科技"、作者为"张三"的论文
|
111
|
+
```
|
112
|
+
|
113
|
+
## 返回结果格式
|
114
|
+
|
115
|
+
搜索并提取内容后返回的JSON格式如下:
|
116
|
+
|
117
|
+
```json
|
118
|
+
{
|
119
|
+
"keywords": "搜索的关键词",
|
120
|
+
"count": 50,
|
121
|
+
"results": [
|
122
|
+
{
|
123
|
+
"title": "论文标题",
|
124
|
+
"authors": ["作者1", "作者2"],
|
125
|
+
"abstract": "论文摘要...",
|
126
|
+
"keywords": ["关键词1", "关键词2"],
|
127
|
+
"cite_format": "引用格式",
|
128
|
+
"url": "论文URL"
|
129
|
+
},
|
130
|
+
// 更多论文...
|
131
|
+
],
|
132
|
+
"success_count": 45,
|
133
|
+
"error_count": 5
|
134
|
+
}
|
135
|
+
```
|
136
|
+
|
137
|
+
## 故障排除
|
138
|
+
|
139
|
+
### Chrome未找到
|
140
|
+
|
141
|
+
系统会自动在常见位置查找Chrome浏览器。如果遇到"未找到Chrome可执行文件"错误,可以通过设置环境变量来指定Chrome位置:
|
142
|
+
|
143
|
+
#### Windows
|
144
|
+
|
145
|
+
```cmd
|
146
|
+
set CHROME_PATH="C:\你的Chrome路径\chrome.exe"
|
147
|
+
```
|
148
|
+
|
149
|
+
#### macOS/Linux
|
150
|
+
|
151
|
+
```bash
|
152
|
+
export CHROME_PATH="/path/to/chrome"
|
153
|
+
```
|
154
|
+
|
155
|
+
### Playwright相关问题
|
156
|
+
|
157
|
+
如果在使用Playwright时遇到问题:
|
158
|
+
|
159
|
+
```bash
|
160
|
+
# 确保playwright库已安装
|
161
|
+
uv add playwright
|
162
|
+
|
163
|
+
# 安装所需浏览器
|
164
|
+
playwright install chromium
|
165
|
+
|
166
|
+
# 如果上述命令无效,可能需要管理员权限
|
167
|
+
```
|
168
|
+
|
169
|
+
### 登录知网
|
170
|
+
|
171
|
+
对于需要登录的知网资源:
|
172
|
+
|
173
|
+
1. 程序会检测到登录需求并等待几秒
|
174
|
+
2. 您需要在打开的浏览器窗口中手动登录知网
|
175
|
+
3. 登录后程序将自动继续执行提取操作
|
176
|
+
|
177
|
+
### 批量提取时浏览器关闭
|
178
|
+
|
179
|
+
如果在批量提取过程中浏览器意外关闭:
|
180
|
+
|
181
|
+
1. 请不要手动关闭浏览器窗口
|
182
|
+
2. 提取过程可能需要几分钟时间,请耐心等待
|
183
|
+
3. 对于大量链接,程序会自动限制为最多处理50个
|
184
|
+
|
185
|
+
## 许可证
|
186
|
+
|
187
|
+
本项目使用MIT许可证 - 详情见LICENSE文件。
|
cnks-0.2.2/README.md
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
# 知网搜索MCP服务器
|
2
|
+
|
3
|
+
该MCP服务器可以帮助您打开Chrome浏览器访问中国知网,搜索关键词并提取论文详细内容。
|
4
|
+
|
5
|
+
## 功能
|
6
|
+
|
7
|
+
- 打开Chrome浏览器访问知网
|
8
|
+
- 提供关键词搜索工具
|
9
|
+
- **自动提取论文完整内容**(v0.2.0新增)
|
10
|
+
- **将搜索结果转换为结构化JSON数据**(v0.2.0新增)
|
11
|
+
- 允许用户保存笔记
|
12
|
+
|
13
|
+
## 版本更新
|
14
|
+
|
15
|
+
### v0.2.2
|
16
|
+
- 优化Chrome浏览器本地调用,不再尝试下载Chromium
|
17
|
+
- 增强错误处理和日志记录
|
18
|
+
- 降低Python版本要求至3.10,提高兼容性
|
19
|
+
- 修复若干bug和稳定性问题
|
20
|
+
|
21
|
+
### v0.2.0
|
22
|
+
- 简化工具接口,统一为单一的`mcp_cnks_search_and_extract`工具
|
23
|
+
- 实现一步式搜索和内容提取
|
24
|
+
- 支持从搜索结果提取50篇论文的完整内容
|
25
|
+
- 结果包含标题、作者、摘要、关键词和引用格式等信息
|
26
|
+
|
27
|
+
### v0.1.1
|
28
|
+
- 初始版本
|
29
|
+
- 基本搜索功能
|
30
|
+
- 提供链接列表
|
31
|
+
|
32
|
+
## 安装
|
33
|
+
|
34
|
+
确保您已安装Python 3.10或更高版本,然后执行以下命令安装:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
uv add "mcp[cli]"
|
38
|
+
```
|
39
|
+
|
40
|
+
## 安装Playwright(必需)
|
41
|
+
|
42
|
+
为了实现自动搜索和内容提取功能,必须安装Playwright:
|
43
|
+
|
44
|
+
```bash
|
45
|
+
# 安装playwright库
|
46
|
+
uv add playwright
|
47
|
+
|
48
|
+
# 安装playwright浏览器
|
49
|
+
playwright install
|
50
|
+
```
|
51
|
+
|
52
|
+
## 开发模式运行
|
53
|
+
|
54
|
+
使用MCP Inspector测试和调试服务器:
|
55
|
+
|
56
|
+
```bash
|
57
|
+
mcp dev src/cnks/server.py
|
58
|
+
```
|
59
|
+
|
60
|
+
## 安装到Claude Desktop
|
61
|
+
|
62
|
+
准备好后,将其安装到Claude Desktop:
|
63
|
+
|
64
|
+
```bash
|
65
|
+
mcp install src/cnks/server.py --name "知网搜索助手"
|
66
|
+
```
|
67
|
+
|
68
|
+
## 使用方法
|
69
|
+
|
70
|
+
在Claude或其他支持MCP的应用中可以使用以下工具:
|
71
|
+
|
72
|
+
### 工具
|
73
|
+
|
74
|
+
- `mcp_cnks_search_and_extract` - 搜索关键词并提取所有论文的详细内容
|
75
|
+
|
76
|
+
### 资源
|
77
|
+
|
78
|
+
- `webpage://current` - 当前打开的网页内容
|
79
|
+
- `webpage://cnki/search` - 中国知网搜索页面
|
80
|
+
- `note://internal/{name}` - 用户保存的笔记
|
81
|
+
|
82
|
+
### 提示
|
83
|
+
|
84
|
+
- `search-literature` - 按主题搜索文献
|
85
|
+
- `advanced-search` - 高级文献搜索
|
86
|
+
- `summarize-notes` - 总结所有笔记
|
87
|
+
|
88
|
+
## 示例用法
|
89
|
+
|
90
|
+
### 搜索并提取内容
|
91
|
+
|
92
|
+
```
|
93
|
+
请使用mcp_cnks_search_and_extract工具搜索"人工智能教育应用"相关论文并提取详细内容
|
94
|
+
```
|
95
|
+
|
96
|
+
### 使用高级搜索
|
97
|
+
|
98
|
+
```
|
99
|
+
请使用高级搜索,查找标题包含"教育科技"、作者为"张三"的论文
|
100
|
+
```
|
101
|
+
|
102
|
+
## 返回结果格式
|
103
|
+
|
104
|
+
搜索并提取内容后返回的JSON格式如下:
|
105
|
+
|
106
|
+
```json
|
107
|
+
{
|
108
|
+
"keywords": "搜索的关键词",
|
109
|
+
"count": 50,
|
110
|
+
"results": [
|
111
|
+
{
|
112
|
+
"title": "论文标题",
|
113
|
+
"authors": ["作者1", "作者2"],
|
114
|
+
"abstract": "论文摘要...",
|
115
|
+
"keywords": ["关键词1", "关键词2"],
|
116
|
+
"cite_format": "引用格式",
|
117
|
+
"url": "论文URL"
|
118
|
+
},
|
119
|
+
// 更多论文...
|
120
|
+
],
|
121
|
+
"success_count": 45,
|
122
|
+
"error_count": 5
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
## 故障排除
|
127
|
+
|
128
|
+
### Chrome未找到
|
129
|
+
|
130
|
+
系统会自动在常见位置查找Chrome浏览器。如果遇到"未找到Chrome可执行文件"错误,可以通过设置环境变量来指定Chrome位置:
|
131
|
+
|
132
|
+
#### Windows
|
133
|
+
|
134
|
+
```cmd
|
135
|
+
set CHROME_PATH="C:\你的Chrome路径\chrome.exe"
|
136
|
+
```
|
137
|
+
|
138
|
+
#### macOS/Linux
|
139
|
+
|
140
|
+
```bash
|
141
|
+
export CHROME_PATH="/path/to/chrome"
|
142
|
+
```
|
143
|
+
|
144
|
+
### Playwright相关问题
|
145
|
+
|
146
|
+
如果在使用Playwright时遇到问题:
|
147
|
+
|
148
|
+
```bash
|
149
|
+
# 确保playwright库已安装
|
150
|
+
uv add playwright
|
151
|
+
|
152
|
+
# 安装所需浏览器
|
153
|
+
playwright install chromium
|
154
|
+
|
155
|
+
# 如果上述命令无效,可能需要管理员权限
|
156
|
+
```
|
157
|
+
|
158
|
+
### 登录知网
|
159
|
+
|
160
|
+
对于需要登录的知网资源:
|
161
|
+
|
162
|
+
1. 程序会检测到登录需求并等待几秒
|
163
|
+
2. 您需要在打开的浏览器窗口中手动登录知网
|
164
|
+
3. 登录后程序将自动继续执行提取操作
|
165
|
+
|
166
|
+
### 批量提取时浏览器关闭
|
167
|
+
|
168
|
+
如果在批量提取过程中浏览器意外关闭:
|
169
|
+
|
170
|
+
1. 请不要手动关闭浏览器窗口
|
171
|
+
2. 提取过程可能需要几分钟时间,请耐心等待
|
172
|
+
3. 对于大量链接,程序会自动限制为最多处理50个
|
173
|
+
|
174
|
+
## 许可证
|
175
|
+
|
176
|
+
本项目使用MIT许可证 - 详情见LICENSE文件。
|