mcp-query-table 0.3.3__tar.gz → 0.3.5__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.
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/PKG-INFO +7 -1
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/README.md +6 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/__init__.py +2 -1
- mcp_query_table-0.3.5/mcp_query_table/_version.py +1 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/providers/baidu.py +19 -5
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/providers/n.py +1 -1
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/providers/yuanbao.py +5 -10
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/sites/tdx.py +1 -1
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/tool.py +19 -1
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/PKG-INFO +7 -1
- mcp_query_table-0.3.3/mcp_query_table/_version.py +0 -1
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/LICENSE +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/__main__.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/enums.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/providers/__init__.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/server.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/sites/__init__.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/sites/eastmoney.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table/sites/iwencai.py +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/SOURCES.txt +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/dependency_links.txt +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/requires.txt +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/top_level.txt +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/pyproject.toml +0 -0
- {mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp_query_table
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
4
4
|
Summary: query table from website, support MCP
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -205,6 +205,12 @@ npx @modelcontextprotocol/inspector python -m mcp_query_table --format markdown
|
|
|
205
205
|
- 向东方财富板块查询 “去年涨的最差的行业板块”,再查询此板块中去年涨的最好的5只股票
|
|
206
206
|
> 分成两步查询,先查询板块,再查询股票。但最好不要全自动,因为第一步的结果它不理解“今日涨幅”和“区间涨幅”,需要交互修正
|
|
207
207
|
|
|
208
|
+
## 支持`Streamlit`
|
|
209
|
+
|
|
210
|
+
实现在同一页面中查询金融数据,并手工输入到`AI`中进行深度分析。参考`streamlit`目录下的`README.md`文件。
|
|
211
|
+
|
|
212
|
+

|
|
213
|
+
|
|
208
214
|
## 参考
|
|
209
215
|
|
|
210
216
|
- [Playwright](https://playwright.dev/python/docs/intro)
|
|
@@ -166,6 +166,12 @@ npx @modelcontextprotocol/inspector python -m mcp_query_table --format markdown
|
|
|
166
166
|
- 向东方财富板块查询 “去年涨的最差的行业板块”,再查询此板块中去年涨的最好的5只股票
|
|
167
167
|
> 分成两步查询,先查询板块,再查询股票。但最好不要全自动,因为第一步的结果它不理解“今日涨幅”和“区间涨幅”,需要交互修正
|
|
168
168
|
|
|
169
|
+
## 支持`Streamlit`
|
|
170
|
+
|
|
171
|
+
实现在同一页面中查询金融数据,并手工输入到`AI`中进行深度分析。参考`streamlit`目录下的`README.md`文件。
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
169
175
|
## 参考
|
|
170
176
|
|
|
171
177
|
- [Playwright](https://playwright.dev/python/docs/intro)
|
|
@@ -3,4 +3,5 @@ from ._version import __version__
|
|
|
3
3
|
from .enums import QueryType, Site, Provider
|
|
4
4
|
from .tool import BrowserManager, query, chat
|
|
5
5
|
|
|
6
|
-
TIMEOUT = 1000 * 60 *
|
|
6
|
+
TIMEOUT = 1000 * 60 * 3 # 3分钟,在抓取EventStream数据时等待数据返回,防止外层30秒超时
|
|
7
|
+
TIMEOUT_60 = 1000 * 60 # 1分钟
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.3.5"
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
"""
|
|
6
6
|
import json
|
|
7
7
|
|
|
8
|
-
from loguru import logger
|
|
9
8
|
from playwright.async_api import Page
|
|
10
9
|
|
|
11
10
|
import mcp_query_table
|
|
12
|
-
from mcp_query_table.tool import GlobalVars
|
|
11
|
+
from mcp_query_table.tool import GlobalVars, split_images
|
|
13
12
|
|
|
14
13
|
_PAGE0_ = "https://chat.baidu.com/search"
|
|
15
14
|
_PAGE1_ = "https://chat.baidu.com/aichat/api/conversation"
|
|
15
|
+
_PAGE2_ = "https://chat.baidu.com/aichat/api/file/upload"
|
|
16
16
|
|
|
17
17
|
G = GlobalVars()
|
|
18
18
|
|
|
@@ -69,16 +69,30 @@ async def chat(page: Page,
|
|
|
69
69
|
create: bool,
|
|
70
70
|
files: list[str],
|
|
71
71
|
) -> str:
|
|
72
|
+
async def on_file_chooser(file_chooser):
|
|
73
|
+
# 文件选择对话框
|
|
74
|
+
await file_chooser.set_files(files)
|
|
75
|
+
|
|
72
76
|
if not page.url.startswith(_PAGE0_):
|
|
73
77
|
create = True
|
|
74
78
|
|
|
75
79
|
if create:
|
|
76
80
|
await page.goto(_PAGE0_)
|
|
77
81
|
|
|
82
|
+
# 文件上传
|
|
78
83
|
if len(files) > 0:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
imgs, docs = split_images(files)
|
|
85
|
+
assert len(imgs) == 0 or len(docs) == 0, "不能同时包含图片和文档"
|
|
86
|
+
|
|
87
|
+
page.on("filechooser", on_file_chooser)
|
|
88
|
+
async with page.expect_response(f"{_PAGE2_}*", timeout=mcp_query_table.TIMEOUT_60) as response_info:
|
|
89
|
+
if len(imgs) > 0:
|
|
90
|
+
await page.locator(".cs-input-upload-icon").last.click()
|
|
91
|
+
else:
|
|
92
|
+
await page.locator(".cs-input-upload-icon").first.click()
|
|
93
|
+
page.remove_listener("filechooser", on_file_chooser)
|
|
94
|
+
|
|
95
|
+
# 提交问题
|
|
82
96
|
await page.route(_PAGE1_, on_route)
|
|
83
97
|
async with page.expect_response(_PAGE1_, timeout=mcp_query_table.TIMEOUT) as response_info:
|
|
84
98
|
await page.locator("#chat-input-box").fill(prompt)
|
|
@@ -93,7 +93,7 @@ async def chat(page: Page,
|
|
|
93
93
|
await page.goto(_PAGE0_)
|
|
94
94
|
if len(files) > 0:
|
|
95
95
|
# 只能在新会话中上传文件
|
|
96
|
-
async with page.expect_response(_PAGE3_, timeout=mcp_query_table.
|
|
96
|
+
async with page.expect_response(_PAGE3_, timeout=mcp_query_table.TIMEOUT_60) as response_info:
|
|
97
97
|
await page.locator("input[type=\"file\"]").set_input_files(files)
|
|
98
98
|
else:
|
|
99
99
|
name = "提出后续问题,Enter发送,Shift+Enter 换行"
|
|
@@ -7,7 +7,7 @@ import re
|
|
|
7
7
|
from playwright.async_api import Page
|
|
8
8
|
|
|
9
9
|
import mcp_query_table
|
|
10
|
-
from mcp_query_table.tool import GlobalVars,
|
|
10
|
+
from mcp_query_table.tool import GlobalVars, split_images
|
|
11
11
|
|
|
12
12
|
_PAGE0_ = "https://yuanbao.tencent.com/"
|
|
13
13
|
_PAGE1_ = "https://yuanbao.tencent.com/api/chat"
|
|
@@ -76,20 +76,15 @@ async def chat(page: Page,
|
|
|
76
76
|
await page.goto(_PAGE0_)
|
|
77
77
|
|
|
78
78
|
if len(files) > 0:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if is_image(f):
|
|
82
|
-
is_img = True
|
|
83
|
-
else:
|
|
84
|
-
is_doc = True
|
|
85
|
-
assert is_img ^ is_doc, "不能同时包含图片和文档"
|
|
79
|
+
imgs, docs = split_images(files)
|
|
80
|
+
assert len(imgs) == 0 or len(docs) == 0, "不能同时包含图片和文档"
|
|
86
81
|
|
|
87
82
|
# 点击上传文件按钮,才会出现上传文件的input
|
|
88
83
|
await page.get_by_role("button").filter(has_text=re.compile(r"^$")).last.click()
|
|
89
84
|
|
|
90
85
|
# 上传文件
|
|
91
|
-
async with page.expect_response(_PAGE2_, timeout=mcp_query_table.
|
|
92
|
-
if
|
|
86
|
+
async with page.expect_response(_PAGE2_, timeout=mcp_query_table.TIMEOUT_60) as response_info:
|
|
87
|
+
if len(imgs) > 0:
|
|
93
88
|
await page.locator("input[type=\"file\"]").nth(-2).set_input_files(files)
|
|
94
89
|
else:
|
|
95
90
|
await page.locator("input[type=\"file\"]").last.set_input_files(files)
|
|
@@ -2,7 +2,7 @@ import subprocess
|
|
|
2
2
|
import sys
|
|
3
3
|
import time
|
|
4
4
|
from pathlib import Path
|
|
5
|
-
from typing import Optional
|
|
5
|
+
from typing import Optional, List, Tuple
|
|
6
6
|
|
|
7
7
|
import pandas as pd
|
|
8
8
|
from loguru import logger
|
|
@@ -142,6 +142,12 @@ class BrowserManager:
|
|
|
142
142
|
# 防止开发者工具被使用
|
|
143
143
|
if page.url.startswith("devtools://"):
|
|
144
144
|
continue
|
|
145
|
+
# 防止chrome扩展被使用
|
|
146
|
+
if page.url.startswith("chrome-extension://"):
|
|
147
|
+
continue
|
|
148
|
+
# 防止edge扩展被使用
|
|
149
|
+
if page.url.startswith("extension://"):
|
|
150
|
+
continue
|
|
145
151
|
self.pages.append(page)
|
|
146
152
|
|
|
147
153
|
async def _try_launch(self) -> None:
|
|
@@ -275,3 +281,15 @@ def is_image(path: str) -> bool:
|
|
|
275
281
|
img_ext = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp']
|
|
276
282
|
ext = Path(path).suffix.lower()
|
|
277
283
|
return ext in img_ext
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def split_images(files: List[str]) -> Tuple[List[str], List[str]]:
|
|
287
|
+
"""图片列表分成两部分"""
|
|
288
|
+
imgs = []
|
|
289
|
+
docs = []
|
|
290
|
+
for f in files:
|
|
291
|
+
if is_image(f):
|
|
292
|
+
imgs.append(f)
|
|
293
|
+
else:
|
|
294
|
+
docs.append(f)
|
|
295
|
+
return imgs, docs
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp_query_table
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.5
|
|
4
4
|
Summary: query table from website, support MCP
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -205,6 +205,12 @@ npx @modelcontextprotocol/inspector python -m mcp_query_table --format markdown
|
|
|
205
205
|
- 向东方财富板块查询 “去年涨的最差的行业板块”,再查询此板块中去年涨的最好的5只股票
|
|
206
206
|
> 分成两步查询,先查询板块,再查询股票。但最好不要全自动,因为第一步的结果它不理解“今日涨幅”和“区间涨幅”,需要交互修正
|
|
207
207
|
|
|
208
|
+
## 支持`Streamlit`
|
|
209
|
+
|
|
210
|
+
实现在同一页面中查询金融数据,并手工输入到`AI`中进行深度分析。参考`streamlit`目录下的`README.md`文件。
|
|
211
|
+
|
|
212
|
+

|
|
213
|
+
|
|
208
214
|
## 参考
|
|
209
215
|
|
|
210
216
|
- [Playwright](https://playwright.dev/python/docs/intro)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.3.3"
|
|
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
|
{mcp_query_table-0.3.3 → mcp_query_table-0.3.5}/mcp_query_table.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|