mcp-query-table 0.3.7__py3-none-any.whl → 0.3.9__py3-none-any.whl
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.
- mcp_query_table/__main__.py +1 -1
- mcp_query_table/_version.py +1 -1
- mcp_query_table/server.py +2 -1
- mcp_query_table/sites/iwencai.py +0 -4
- mcp_query_table/tool.py +10 -5
- mcp_query_table/utils.py +0 -17
- {mcp_query_table-0.3.7.dist-info → mcp_query_table-0.3.9.dist-info}/METADATA +9 -10
- mcp_query_table-0.3.9.dist-info/RECORD +19 -0
- {mcp_query_table-0.3.7.dist-info → mcp_query_table-0.3.9.dist-info}/WHEEL +1 -2
- mcp_query_table-0.3.7.dist-info/RECORD +0 -20
- mcp_query_table-0.3.7.dist-info/top_level.txt +0 -1
- {mcp_query_table-0.3.7.dist-info → mcp_query_table-0.3.9.dist-info}/licenses/LICENSE +0 -0
mcp_query_table/__main__.py
CHANGED
|
@@ -17,7 +17,7 @@ def main():
|
|
|
17
17
|
parser.add_argument("--executable_path", type=str, help="浏览器路径",
|
|
18
18
|
nargs="?", default=r'C:\Program Files\Google\Chrome\Application\chrome.exe')
|
|
19
19
|
parser.add_argument("--user_data_dir", type=str, help="浏览器用户数据目录",
|
|
20
|
-
nargs="?", default=rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data')
|
|
20
|
+
nargs="?", default=rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data\Default')
|
|
21
21
|
parser.add_argument("--transport", type=str, help="传输类型",
|
|
22
22
|
default='stdio', choices=['stdio', 'sse'])
|
|
23
23
|
parser.add_argument("--host", type=str, help="MCP服务端绑定地址",
|
mcp_query_table/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.9"
|
mcp_query_table/server.py
CHANGED
|
@@ -58,7 +58,8 @@ async def query(
|
|
|
58
58
|
return await qsv.query(query_input, query_type, max_page, site)
|
|
59
59
|
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
# chat功能不通过mcp暴露,因为在Cline等客户端中本就有LLM功能,反而导致返回的数据没有正确提交
|
|
62
|
+
# @mcp.tool(description="大语言模型对话")
|
|
62
63
|
async def chat(
|
|
63
64
|
prompt: Annotated[str, Field(description="提示词。如:`9.9大还是9.11大?`")],
|
|
64
65
|
create: Annotated[bool, Field(default=False, description="是否创建新对话")],
|
mcp_query_table/sites/iwencai.py
CHANGED
|
@@ -10,10 +10,8 @@ import re
|
|
|
10
10
|
import pandas as pd
|
|
11
11
|
from loguru import logger
|
|
12
12
|
from playwright.async_api import Page
|
|
13
|
-
from playwright_stealth import stealth_async
|
|
14
13
|
|
|
15
14
|
from mcp_query_table.enums import QueryType
|
|
16
|
-
from mcp_query_table.utils import FixedConfig
|
|
17
15
|
|
|
18
16
|
# 初次查询页面
|
|
19
17
|
_PAGE1_ = 'https://www.iwencai.com/customized/chart/get-robot-data'
|
|
@@ -154,8 +152,6 @@ async def query(page: Page,
|
|
|
154
152
|
querytype = _querytype_.get(type_, None)
|
|
155
153
|
assert querytype is not None, f"不支持的类型:{type_}"
|
|
156
154
|
|
|
157
|
-
await stealth_async(page, FixedConfig())
|
|
158
|
-
|
|
159
155
|
await page.route(re.compile(r'.*\.(?:jpg|jpeg|png|gif|webp)(?:$|\?)'), lambda route: route.abort())
|
|
160
156
|
|
|
161
157
|
P.reset()
|
mcp_query_table/tool.py
CHANGED
|
@@ -4,11 +4,12 @@ import sys
|
|
|
4
4
|
import time
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import Optional
|
|
7
|
-
from urllib.parse import urlparse
|
|
7
|
+
from urllib.parse import urlparse, quote
|
|
8
8
|
|
|
9
9
|
import pandas as pd
|
|
10
10
|
from loguru import logger
|
|
11
11
|
from playwright.async_api import async_playwright, Playwright, Page
|
|
12
|
+
from playwright_stealth import Stealth
|
|
12
13
|
|
|
13
14
|
from mcp_query_table.enums import QueryType, Site, Provider
|
|
14
15
|
|
|
@@ -65,8 +66,8 @@ def get_user_data_dir(user_data_dir) -> Optional[str]:
|
|
|
65
66
|
"""获取浏览器可用户目录"""
|
|
66
67
|
browsers = {
|
|
67
68
|
"default": user_data_dir,
|
|
68
|
-
"chrome.exe": rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data',
|
|
69
|
-
"msedge.exe": rf"C:\Users\{getpass.getuser()}\AppData\Local\Microsoft\Edge\User Data",
|
|
69
|
+
"chrome.exe": rf'C:\Users\{getpass.getuser()}\AppData\Local\Google\Chrome\User Data\Default',
|
|
70
|
+
"msedge.exe": rf"C:\Users\{getpass.getuser()}\AppData\Local\Microsoft\Edge\User Data\Default",
|
|
70
71
|
}
|
|
71
72
|
for k, v in browsers.items():
|
|
72
73
|
if v is None:
|
|
@@ -144,7 +145,7 @@ class BrowserManager:
|
|
|
144
145
|
except:
|
|
145
146
|
if i == 0:
|
|
146
147
|
create_detached_process(command)
|
|
147
|
-
time.sleep(
|
|
148
|
+
time.sleep(5)
|
|
148
149
|
continue
|
|
149
150
|
if i == 1:
|
|
150
151
|
raise ConnectionError(
|
|
@@ -171,7 +172,8 @@ class BrowserManager:
|
|
|
171
172
|
user_data_dir=self.user_data_dir,
|
|
172
173
|
executable_path=self.executable_path,
|
|
173
174
|
headless=self.headless,
|
|
174
|
-
devtools=self.devtools
|
|
175
|
+
devtools=self.devtools,
|
|
176
|
+
timeout=10000, slow_mo=1000)
|
|
175
177
|
except:
|
|
176
178
|
raise ConnectionError(f"launch失败,可能已经有浏览器已经打开了数据目录。{self.user_data_dir}")
|
|
177
179
|
else:
|
|
@@ -203,6 +205,8 @@ class BrowserManager:
|
|
|
203
205
|
self.context = await self.browser.new_context()
|
|
204
206
|
else:
|
|
205
207
|
self.context = self.browser.contexts[0]
|
|
208
|
+
# 爱问财,无头模式,需要使用 stealth 插件
|
|
209
|
+
await Stealth().apply_stealth_async(self.context)
|
|
206
210
|
|
|
207
211
|
# 复用打开的page
|
|
208
212
|
for page in self.context.pages:
|
|
@@ -267,6 +271,7 @@ async def query(
|
|
|
267
271
|
查询结果
|
|
268
272
|
|
|
269
273
|
"""
|
|
274
|
+
query_input = quote(query_input.strip(), safe='')
|
|
270
275
|
|
|
271
276
|
if site == Site.EastMoney:
|
|
272
277
|
from mcp_query_table.sites.eastmoney import query
|
mcp_query_table/utils.py
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import random
|
|
2
|
-
import string
|
|
3
1
|
from pathlib import Path
|
|
4
2
|
from typing import List, Tuple
|
|
5
3
|
|
|
6
|
-
from playwright_stealth import StealthConfig
|
|
7
|
-
|
|
8
4
|
|
|
9
5
|
def is_image(path: str) -> bool:
|
|
10
6
|
"""判断是否是图片文件"""
|
|
@@ -36,16 +32,3 @@ class GlobalVars:
|
|
|
36
32
|
|
|
37
33
|
def get_text(self):
|
|
38
34
|
return self.text
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# https://github.com/AtuboDad/playwright_stealth/issues/31#issuecomment-2342541305
|
|
42
|
-
class FixedConfig(StealthConfig):
|
|
43
|
-
|
|
44
|
-
@property
|
|
45
|
-
def enabled_scripts(self):
|
|
46
|
-
key = "".join(random.choices(string.ascii_letters, k=10))
|
|
47
|
-
for script in super().enabled_scripts:
|
|
48
|
-
if "const opts" in script:
|
|
49
|
-
yield script.replace("const opts", f"window.{key}")
|
|
50
|
-
continue
|
|
51
|
-
yield script.replace("opts", f"window.{key}")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp_query_table
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.9
|
|
4
4
|
Summary: query table from website, support MCP
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -24,19 +24,18 @@ License: MIT License
|
|
|
24
24
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
25
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
26
|
SOFTWARE.
|
|
27
|
-
|
|
28
|
-
Keywords:
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Keywords: eastmoney,iwencai,mcp,playwright,table,tdx
|
|
29
29
|
Classifier: Development Status :: 4 - Beta
|
|
30
30
|
Classifier: Programming Language :: Python
|
|
31
31
|
Requires-Python: >=3.10
|
|
32
|
-
Description-Content-Type: text/markdown
|
|
33
|
-
License-File: LICENSE
|
|
34
|
-
Requires-Dist: pandas
|
|
35
32
|
Requires-Dist: loguru
|
|
36
|
-
Requires-Dist: playwright
|
|
37
|
-
Requires-Dist: playwright-stealth
|
|
38
33
|
Requires-Dist: mcp
|
|
39
|
-
|
|
34
|
+
Requires-Dist: pandas
|
|
35
|
+
Requires-Dist: playwright
|
|
36
|
+
Requires-Dist: playwright-stealth>=2.0.0
|
|
37
|
+
Requires-Dist: tabulate
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
40
39
|
|
|
41
40
|
# mcp_query_table
|
|
42
41
|
|
|
@@ -223,4 +222,4 @@ npx @modelcontextprotocol/inspector python -m mcp_query_table --format markdown
|
|
|
223
222
|
|
|
224
223
|
## 参考
|
|
225
224
|
- [Selenium webdriver无法附加到edge实例,edge的--remote-debugging-port选项无效](https://blog.csdn.net/qq_30576521/article/details/142370538)
|
|
226
|
-
- https://github.com/AtuboDad/playwright_stealth/issues/31
|
|
225
|
+
- https://github.com/AtuboDad/playwright_stealth/issues/31
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
mcp_query_table/__init__.py,sha256=K-0DU2hpeRvM9ZAuky0aWZtJLuOgKg7ZRd-pL9noc0o,330
|
|
2
|
+
mcp_query_table/__main__.py,sha256=K0r7y8PD9y9pFg3bAQxNo21KlQpGz1jqGg_zptPfenM,1461
|
|
3
|
+
mcp_query_table/_version.py,sha256=xmkmdvq15kb61xdtCoa1YARnvHBnUgI-0GWIJYvHNeA,22
|
|
4
|
+
mcp_query_table/enums.py,sha256=7bu0m0zJBIfiS-eHGURw1ZHWNXgsq6gH1SztUhCgF-Y,678
|
|
5
|
+
mcp_query_table/server.py,sha256=D2-7ZmutijphasbLMosg9P5EOhJTB4RvC9-zmvCvc5k,3749
|
|
6
|
+
mcp_query_table/tool.py,sha256=dW6Hcv7aB-hBotd7OBzCWQrpRck1h5812y6sRCUENVA,11380
|
|
7
|
+
mcp_query_table/utils.py,sha256=MUKcklPF9TkABhM8wN0-kW0iy9AlmjL6oycZyxB_Qk8,722
|
|
8
|
+
mcp_query_table/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
mcp_query_table/providers/baidu.py,sha256=S75D2zbpqG1r4Rxz7pJf5u2ZHNLO8nqV-LPEjlACtHg,3390
|
|
10
|
+
mcp_query_table/providers/n.py,sha256=SLalpwHSdkXNoMCLQEx1TEFlo50dS7I9JNli5jz8w6k,3202
|
|
11
|
+
mcp_query_table/providers/yuanbao.py,sha256=1wRMy7Z2JraM3MrgLDSdyg-EqX-D26ysx7CW1GFtVho,3292
|
|
12
|
+
mcp_query_table/sites/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
mcp_query_table/sites/eastmoney.py,sha256=LImjpYVuM5YnXwnNzB2hkKfHofocZZScetGqMOCHZpk,4477
|
|
14
|
+
mcp_query_table/sites/iwencai.py,sha256=FlIQOAN6wPz0B8w5DFX-EHekPO5HPIYdLMhiX1dYV7s,5057
|
|
15
|
+
mcp_query_table/sites/tdx.py,sha256=P-GNFUsS5_INy3sicaZbUBdudgQBZuhu_QyVvyw4yDg,4126
|
|
16
|
+
mcp_query_table-0.3.9.dist-info/METADATA,sha256=w6Kk_cokNDdnTgr7APF6IhlSVOHJTrDAO0uGdhTaNvA,9353
|
|
17
|
+
mcp_query_table-0.3.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
mcp_query_table-0.3.9.dist-info/licenses/LICENSE,sha256=rbvv_CTd7biGwT21tvhgQ2zkbPFXOoON7WFQWEdElBA,1063
|
|
19
|
+
mcp_query_table-0.3.9.dist-info/RECORD,,
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
mcp_query_table/__init__.py,sha256=K-0DU2hpeRvM9ZAuky0aWZtJLuOgKg7ZRd-pL9noc0o,330
|
|
2
|
-
mcp_query_table/__main__.py,sha256=oePptyDeLtOHcR0XZxx-O12hO6LSe6cplb4gaJBG4rI,1453
|
|
3
|
-
mcp_query_table/_version.py,sha256=J0I0c7-a50EOnWXMryTu_E6xhXSYFBPjVpeYP_a3vRI,22
|
|
4
|
-
mcp_query_table/enums.py,sha256=7bu0m0zJBIfiS-eHGURw1ZHWNXgsq6gH1SztUhCgF-Y,678
|
|
5
|
-
mcp_query_table/server.py,sha256=0hnkZGbGvmCREd92QcjtktdyaHPsqpw_hh1n8hRj-S8,3618
|
|
6
|
-
mcp_query_table/tool.py,sha256=tVGGqryE-tcXzfi-Rks_Tj81_NvbHAI2NW1NVqaT_SM,11092
|
|
7
|
-
mcp_query_table/utils.py,sha256=VjKYLRPEa-W3qAOaNSJa9GnezrAAYykn4XY-R4P5NJg,1264
|
|
8
|
-
mcp_query_table/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
mcp_query_table/providers/baidu.py,sha256=S75D2zbpqG1r4Rxz7pJf5u2ZHNLO8nqV-LPEjlACtHg,3390
|
|
10
|
-
mcp_query_table/providers/n.py,sha256=SLalpwHSdkXNoMCLQEx1TEFlo50dS7I9JNli5jz8w6k,3202
|
|
11
|
-
mcp_query_table/providers/yuanbao.py,sha256=1wRMy7Z2JraM3MrgLDSdyg-EqX-D26ysx7CW1GFtVho,3292
|
|
12
|
-
mcp_query_table/sites/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
mcp_query_table/sites/eastmoney.py,sha256=LImjpYVuM5YnXwnNzB2hkKfHofocZZScetGqMOCHZpk,4477
|
|
14
|
-
mcp_query_table/sites/iwencai.py,sha256=43sBrVCXgiIybv25lEwTS6dlR2jXXceSBVGCOb03woE,5194
|
|
15
|
-
mcp_query_table/sites/tdx.py,sha256=P-GNFUsS5_INy3sicaZbUBdudgQBZuhu_QyVvyw4yDg,4126
|
|
16
|
-
mcp_query_table-0.3.7.dist-info/licenses/LICENSE,sha256=rbvv_CTd7biGwT21tvhgQ2zkbPFXOoON7WFQWEdElBA,1063
|
|
17
|
-
mcp_query_table-0.3.7.dist-info/METADATA,sha256=E-ww9VKlg5JVNXzwXfgBK8VST6DFt8iNDaQIIZVfgrI,9354
|
|
18
|
-
mcp_query_table-0.3.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
19
|
-
mcp_query_table-0.3.7.dist-info/top_level.txt,sha256=5M_8dkO1USOX7_EWbWS6O_TEsZ5yo-AodFNKeUEgvEQ,16
|
|
20
|
-
mcp_query_table-0.3.7.dist-info/RECORD,,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
mcp_query_table
|
|
File without changes
|