mcp-query-table 0.3.0__py3-none-any.whl → 0.3.2__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/__init__.py +2 -0
- mcp_query_table/__main__.py +7 -6
- mcp_query_table/_version.py +1 -1
- mcp_query_table/enums.py +1 -1
- mcp_query_table/providers/baidu.py +4 -4
- mcp_query_table/providers/n.py +2 -2
- mcp_query_table/providers/yuanbao.py +3 -3
- mcp_query_table/server.py +15 -10
- mcp_query_table/tool.py +85 -37
- {mcp_query_table-0.3.0.dist-info → mcp_query_table-0.3.2.dist-info}/METADATA +40 -28
- mcp_query_table-0.3.2.dist-info/RECORD +19 -0
- mcp_query_table-0.3.0.dist-info/RECORD +0 -19
- {mcp_query_table-0.3.0.dist-info → mcp_query_table-0.3.2.dist-info}/WHEEL +0 -0
- {mcp_query_table-0.3.0.dist-info → mcp_query_table-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {mcp_query_table-0.3.0.dist-info → mcp_query_table-0.3.2.dist-info}/top_level.txt +0 -0
mcp_query_table/__init__.py
CHANGED
mcp_query_table/__main__.py
CHANGED
|
@@ -10,19 +10,20 @@ def main():
|
|
|
10
10
|
|
|
11
11
|
parser.add_argument("--format", type=str, help="输出格式",
|
|
12
12
|
default='markdown', choices=['markdown', 'csv', 'json'])
|
|
13
|
-
parser.add_argument("--
|
|
14
|
-
default=9222)
|
|
15
|
-
parser.add_argument("--
|
|
13
|
+
parser.add_argument("--cdp_endpoint", type=str, help="浏览器CDP调试地址",
|
|
14
|
+
default="http://127.0.0.1:9222")
|
|
15
|
+
parser.add_argument("--executable_path", type=str, help="浏览器类型",
|
|
16
16
|
default=r'C:\Program Files\Google\Chrome\Application\chrome.exe')
|
|
17
17
|
|
|
18
18
|
parser.add_argument("--transport", type=str, help="传输类型",
|
|
19
19
|
default='stdio', choices=['stdio', 'sse'])
|
|
20
|
-
parser.add_argument("--
|
|
20
|
+
parser.add_argument("--host", type=str, help="MCP服务端绑定地址",
|
|
21
21
|
default='0.0.0.0')
|
|
22
|
-
parser.add_argument("--
|
|
22
|
+
parser.add_argument("--port", type=int, help="MCP服务端绑定端口",
|
|
23
23
|
default='8000')
|
|
24
24
|
args = parser.parse_args()
|
|
25
|
-
serve(args.format, args.
|
|
25
|
+
serve(args.format, args.cdp_endpoint, args.executable_path,
|
|
26
|
+
args.transport, args.host, args.port)
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
if __name__ == "__main__":
|
mcp_query_table/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.3.
|
|
1
|
+
__version__ = "0.3.2"
|
mcp_query_table/enums.py
CHANGED
|
@@ -7,11 +7,11 @@ import json
|
|
|
7
7
|
|
|
8
8
|
from playwright.async_api import Page
|
|
9
9
|
|
|
10
|
+
import mcp_query_table
|
|
10
11
|
from mcp_query_table.tool import GlobalVars
|
|
11
12
|
|
|
12
13
|
_PAGE0_ = "https://chat.baidu.com/search"
|
|
13
14
|
_PAGE1_ = "https://chat.baidu.com/aichat/api/conversation"
|
|
14
|
-
_TIMEOUT_ = 1000 * 120
|
|
15
15
|
|
|
16
16
|
G = GlobalVars()
|
|
17
17
|
|
|
@@ -55,9 +55,9 @@ async def on_response(response):
|
|
|
55
55
|
async def on_route(route):
|
|
56
56
|
# 避免出现 Protocol error (Network.getResponseBody): No data found for resource with given identifier
|
|
57
57
|
# print("on_route", route.request.url)
|
|
58
|
-
if route.request.url
|
|
58
|
+
if route.request.url == _PAGE1_:
|
|
59
59
|
# TODO 为何只要转发一下就没事了?
|
|
60
|
-
response = await route.fetch(timeout=
|
|
60
|
+
response = await route.fetch(timeout=mcp_query_table.TIMEOUT)
|
|
61
61
|
await route.fulfill(response=response)
|
|
62
62
|
else:
|
|
63
63
|
await route.continue_()
|
|
@@ -74,7 +74,7 @@ async def chat(page: Page,
|
|
|
74
74
|
await page.goto(_PAGE0_)
|
|
75
75
|
|
|
76
76
|
await page.route(_PAGE1_, on_route)
|
|
77
|
-
async with page.expect_response(_PAGE1_, timeout=
|
|
77
|
+
async with page.expect_response(_PAGE1_, timeout=mcp_query_table.TIMEOUT) as response_info:
|
|
78
78
|
await page.locator("#chat-input-box").fill(prompt)
|
|
79
79
|
await page.locator("#chat-input-box").press("Enter")
|
|
80
80
|
await on_response(await response_info.value)
|
mcp_query_table/providers/n.py
CHANGED
|
@@ -5,12 +5,12 @@ import json
|
|
|
5
5
|
|
|
6
6
|
from playwright.async_api import Page
|
|
7
7
|
|
|
8
|
+
import mcp_query_table
|
|
8
9
|
from mcp_query_table.tool import GlobalVars
|
|
9
10
|
|
|
10
11
|
_PAGE0_ = "https://www.n.cn"
|
|
11
12
|
_PAGE1_ = "https://www.n.cn/search"
|
|
12
13
|
_PAGE2_ = "https://www.n.cn/api/common/chat/v2"
|
|
13
|
-
_TIMEOUT_ = 1000 * 120
|
|
14
14
|
|
|
15
15
|
G = GlobalVars()
|
|
16
16
|
|
|
@@ -68,7 +68,7 @@ async def chat(page: Page,
|
|
|
68
68
|
else:
|
|
69
69
|
name = "提出后续问题,Enter发送,Shift+Enter 换行"
|
|
70
70
|
|
|
71
|
-
async with page.expect_response(_PAGE2_, timeout=
|
|
71
|
+
async with page.expect_response(_PAGE2_, timeout=mcp_query_table.TIMEOUT) as response_info:
|
|
72
72
|
textbox = page.get_by_role("textbox", name=name)
|
|
73
73
|
await textbox.fill(prompt)
|
|
74
74
|
await textbox.press("Enter")
|
|
@@ -5,11 +5,11 @@ import json
|
|
|
5
5
|
|
|
6
6
|
from playwright.async_api import Page
|
|
7
7
|
|
|
8
|
+
import mcp_query_table
|
|
8
9
|
from mcp_query_table.tool import GlobalVars
|
|
9
10
|
|
|
10
11
|
_PAGE0_ = "https://yuanbao.tencent.com/"
|
|
11
12
|
_PAGE1_ = "https://yuanbao.tencent.com/api/chat"
|
|
12
|
-
_TIMEOUT_ = 1000 * 120
|
|
13
13
|
|
|
14
14
|
G = GlobalVars()
|
|
15
15
|
|
|
@@ -52,7 +52,7 @@ async def on_route(route):
|
|
|
52
52
|
# print("on_route", route.request.url)
|
|
53
53
|
if route.request.url.startswith(_PAGE1_):
|
|
54
54
|
# TODO 这里会导致数据全部加载,逻辑变了,所以界面可能混乱
|
|
55
|
-
response = await route.fetch(timeout=
|
|
55
|
+
response = await route.fetch(timeout=mcp_query_table.TIMEOUT)
|
|
56
56
|
await route.fulfill(
|
|
57
57
|
# 强行加utf-8,否则编码搞不定
|
|
58
58
|
content_type="text/event-stream; charset=utf-8",
|
|
@@ -73,7 +73,7 @@ async def chat(page: Page,
|
|
|
73
73
|
await page.goto(_PAGE0_)
|
|
74
74
|
|
|
75
75
|
await page.route(f"{_PAGE1_}/*", on_route)
|
|
76
|
-
async with page.expect_response(f"{_PAGE1_}/*", timeout=
|
|
76
|
+
async with page.expect_response(f"{_PAGE1_}/*", timeout=mcp_query_table.TIMEOUT) as response_info:
|
|
77
77
|
textbox = page.locator(".ql-editor")
|
|
78
78
|
await textbox.fill(prompt)
|
|
79
79
|
await textbox.press("Enter")
|
mcp_query_table/server.py
CHANGED
|
@@ -10,9 +10,12 @@ from mcp_query_table.tool import BrowserManager
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class QueryServer:
|
|
13
|
-
def __init__(self,
|
|
13
|
+
def __init__(self,
|
|
14
|
+
format: str = 'markdown',
|
|
15
|
+
cdp_endpoint: Optional[str] = 'http://127.0.0.1:9222',
|
|
16
|
+
executable_path: Optional[str] = None) -> None:
|
|
14
17
|
self.format: str = format
|
|
15
|
-
self.browser = BrowserManager(
|
|
18
|
+
self.browser = BrowserManager(cdp_endpoint=cdp_endpoint, executable_path=executable_path, debug=False)
|
|
16
19
|
|
|
17
20
|
async def query(self, query_input: str, query_type: QueryType, max_page: int, site: Site):
|
|
18
21
|
page = await self.browser.get_page()
|
|
@@ -54,19 +57,21 @@ async def query(
|
|
|
54
57
|
async def chat(
|
|
55
58
|
prompt: Annotated[str, Field(description="提示词。如:`9.9大还是9.11大?`")],
|
|
56
59
|
create: Annotated[bool, Field(default=False, description="是否创建新对话")],
|
|
57
|
-
provider: Annotated[
|
|
60
|
+
provider: Annotated[
|
|
61
|
+
Provider, Field(default=Provider.Nami, description="提供商。支持`纳米搜索`、`腾讯元宝`、`百度AI搜索`")]
|
|
58
62
|
) -> str:
|
|
59
63
|
return await qsv.chat(prompt, create, provider)
|
|
60
64
|
|
|
61
65
|
|
|
62
|
-
def serve(format,
|
|
66
|
+
def serve(format, cdp_endpoint, executable_path, transport, host, port):
|
|
63
67
|
qsv.format = format
|
|
64
|
-
qsv.
|
|
65
|
-
qsv.
|
|
66
|
-
logger.info("
|
|
68
|
+
qsv.cdp_endpoint = cdp_endpoint
|
|
69
|
+
qsv.executable_path = executable_path
|
|
70
|
+
logger.info(f"{format=},{transport=}")
|
|
71
|
+
logger.info(f"{cdp_endpoint=},{executable_path=}")
|
|
67
72
|
if transport == 'sse':
|
|
68
|
-
logger.info("
|
|
73
|
+
logger.info(f"{host=},{port=}", transport, host, port)
|
|
69
74
|
|
|
70
|
-
mcp.settings.host =
|
|
71
|
-
mcp.settings.port =
|
|
75
|
+
mcp.settings.host = host
|
|
76
|
+
mcp.settings.port = port
|
|
72
77
|
mcp.run(transport=transport)
|
mcp_query_table/tool.py
CHANGED
|
@@ -10,11 +10,6 @@ from playwright.async_api import async_playwright, Playwright, Page
|
|
|
10
10
|
|
|
11
11
|
from mcp_query_table.enums import QueryType, Site, Provider
|
|
12
12
|
|
|
13
|
-
browsers_path = {
|
|
14
|
-
"chrome.exe": r"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
|
15
|
-
"msedge.exe": r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
|
|
19
14
|
def create_detached_process(command):
|
|
20
15
|
# 设置通用参数
|
|
@@ -33,6 +28,29 @@ def create_detached_process(command):
|
|
|
33
28
|
return subprocess.Popen(command, **kwargs)
|
|
34
29
|
|
|
35
30
|
|
|
31
|
+
def is_local_url(url: str) -> bool:
|
|
32
|
+
"""判断url是否是本地地址"""
|
|
33
|
+
for local in ('localhost', '127.0.0.1'):
|
|
34
|
+
if local in url.lower():
|
|
35
|
+
return True
|
|
36
|
+
return False
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def get_executable_path(executable_path) -> Optional[str]:
|
|
40
|
+
"""获取浏览器可执行文件路径"""
|
|
41
|
+
browsers = {
|
|
42
|
+
"default": executable_path,
|
|
43
|
+
"chrome.exe": r"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
|
44
|
+
"msedge.exe": r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
|
|
45
|
+
}
|
|
46
|
+
for k, v in browsers.items():
|
|
47
|
+
if v is None:
|
|
48
|
+
continue
|
|
49
|
+
if Path(v).exists():
|
|
50
|
+
return v
|
|
51
|
+
return None
|
|
52
|
+
|
|
53
|
+
|
|
36
54
|
class BrowserManager:
|
|
37
55
|
async def __aenter__(self):
|
|
38
56
|
return self
|
|
@@ -40,29 +58,24 @@ class BrowserManager:
|
|
|
40
58
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
41
59
|
await self.cleanup()
|
|
42
60
|
|
|
43
|
-
def __init__(self,
|
|
61
|
+
def __init__(self,
|
|
62
|
+
cdp_endpoint: Optional[str] = None,
|
|
63
|
+
executable_path: Optional[str] = None,
|
|
64
|
+
debug: bool = False):
|
|
44
65
|
"""
|
|
45
66
|
|
|
46
67
|
Parameters
|
|
47
68
|
----------
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
69
|
+
cdp_endpoint:str
|
|
70
|
+
浏览器CDP地址
|
|
71
|
+
executable_path:str
|
|
72
|
+
浏览器可执行文件路径。推荐使用chrome,因为Microsoft Edge必须在任务管理器中完全退出才能启动调试端口
|
|
52
73
|
debug:bool
|
|
53
74
|
是否显示开发者工具
|
|
54
75
|
|
|
55
76
|
"""
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if Path(v).exists():
|
|
59
|
-
browser_path = v
|
|
60
|
-
break
|
|
61
|
-
if browser_path is None:
|
|
62
|
-
raise ValueError("未找到浏览器可执行文件")
|
|
63
|
-
|
|
64
|
-
self.port = port
|
|
65
|
-
self.browser_path = browser_path
|
|
77
|
+
self.cdp_endpoint = cdp_endpoint or 'http://127.0.0.1:9222'
|
|
78
|
+
self.executable_path = executable_path
|
|
66
79
|
self.debug = debug
|
|
67
80
|
|
|
68
81
|
self.playwright: Optional[Playwright] = None
|
|
@@ -77,25 +90,18 @@ class BrowserManager:
|
|
|
77
90
|
if self.playwright:
|
|
78
91
|
await self.playwright.stop()
|
|
79
92
|
|
|
80
|
-
async def
|
|
81
|
-
"""
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
https://blog.csdn.net/qq_30576521/article/details/142370538
|
|
86
|
-
|
|
87
|
-
"""
|
|
88
|
-
endpoint = f"http://127.0.0.1:{self.port}"
|
|
89
|
-
command = [self.browser_path, f'--remote-debugging-port={self.port}', '--start-maximized']
|
|
90
|
-
name = Path(self.browser_path).name
|
|
93
|
+
async def _connect_to_local(self) -> None:
|
|
94
|
+
"""连接本地浏览器"""
|
|
95
|
+
port = self.cdp_endpoint.split(':')[-1]
|
|
96
|
+
executable_path = get_executable_path(self.executable_path)
|
|
97
|
+
command = [executable_path, f'--remote-debugging-port={port}', '--start-maximized']
|
|
91
98
|
if self.debug:
|
|
92
99
|
command.append('--auto-open-devtools-for-tabs')
|
|
93
100
|
|
|
94
|
-
self.playwright = await async_playwright().start()
|
|
95
|
-
|
|
96
101
|
for i in range(2):
|
|
97
102
|
try:
|
|
98
|
-
self.browser = await self.playwright.chromium.connect_over_cdp(
|
|
103
|
+
self.browser = await self.playwright.chromium.connect_over_cdp(self.cdp_endpoint,
|
|
104
|
+
timeout=10000, slow_mo=1000)
|
|
99
105
|
break
|
|
100
106
|
except:
|
|
101
107
|
if i == 0:
|
|
@@ -105,7 +111,30 @@ class BrowserManager:
|
|
|
105
111
|
continue
|
|
106
112
|
if i == 1:
|
|
107
113
|
raise ConnectionError(
|
|
108
|
-
f"已提前打开了浏览器,但未开启远程调试端口?请关闭浏览器全部进程后重试 `taskkill /f /im {name}`")
|
|
114
|
+
f"已提前打开了浏览器,但未开启远程调试端口?请关闭浏览器全部进程后重试 `taskkill /f /im {Path(executable_path).name}`")
|
|
115
|
+
|
|
116
|
+
async def _connect_to_remote(self) -> None:
|
|
117
|
+
"""连接远程浏览器"""
|
|
118
|
+
try:
|
|
119
|
+
self.browser = await self.playwright.chromium.connect_over_cdp(self.cdp_endpoint,
|
|
120
|
+
timeout=10000, slow_mo=1000)
|
|
121
|
+
except:
|
|
122
|
+
raise ConnectionError(f"连接远程浏览器失败,请检查CDP地址和端口是否正确。{self.cdp_endpoint}")
|
|
123
|
+
|
|
124
|
+
async def _launch(self) -> None:
|
|
125
|
+
"""启动浏览器,并连接CDP协议
|
|
126
|
+
|
|
127
|
+
References
|
|
128
|
+
----------
|
|
129
|
+
https://blog.csdn.net/qq_30576521/article/details/142370538
|
|
130
|
+
|
|
131
|
+
"""
|
|
132
|
+
self.playwright = await async_playwright().start()
|
|
133
|
+
|
|
134
|
+
if is_local_url(self.cdp_endpoint):
|
|
135
|
+
await self._connect_to_local()
|
|
136
|
+
else:
|
|
137
|
+
await self._connect_to_remote()
|
|
109
138
|
|
|
110
139
|
self.context = self.browser.contexts[0]
|
|
111
140
|
# 复用打开的page
|
|
@@ -201,8 +230,27 @@ async def chat(
|
|
|
201
230
|
page: Page,
|
|
202
231
|
prompt: str = "9.9大还是9.11大?",
|
|
203
232
|
create: bool = False,
|
|
204
|
-
provider: Provider = Provider.
|
|
205
|
-
|
|
233
|
+
provider: Provider = Provider.Nami) -> str:
|
|
234
|
+
"""大语言对话
|
|
235
|
+
|
|
236
|
+
Parameters
|
|
237
|
+
----------
|
|
238
|
+
page : playwright.sync_api.Page
|
|
239
|
+
页面
|
|
240
|
+
prompt : str, optional
|
|
241
|
+
对话内容, by default "9.9大还是9.11大?"
|
|
242
|
+
create : bool, optional
|
|
243
|
+
是否创建新对话, by default False
|
|
244
|
+
provider : Provider, optional
|
|
245
|
+
提供商, by default Provider.N
|
|
246
|
+
|
|
247
|
+
Returns
|
|
248
|
+
-------
|
|
249
|
+
str
|
|
250
|
+
对话结果
|
|
251
|
+
|
|
252
|
+
"""
|
|
253
|
+
if provider == Provider.Nami:
|
|
206
254
|
from mcp_query_table.providers.n import chat
|
|
207
255
|
return await chat(page, prompt, create)
|
|
208
256
|
if provider == Provider.YuanBao:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mcp_query_table
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.2
|
|
4
4
|
Summary: query table from website, support MCP
|
|
5
5
|
Author-email: wukan <wu-kan@163.com>
|
|
6
6
|
License: MIT License
|
|
@@ -70,31 +70,31 @@ from mcp_query_table import *
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
async def main() -> None:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
async with BrowserManager(cdp_endpoint="http://127.0.0.1:9222", executable_path=None, debug=True) as bm:
|
|
74
|
+
# 问财需要保证浏览器宽度>768,防止界面变成适应手机
|
|
75
|
+
page = await bm.get_page()
|
|
76
|
+
df = await query(page, '收益最好的200只ETF', query_type=QueryType.ETF, max_page=1, site=Site.THS)
|
|
77
|
+
print(df.to_markdown())
|
|
78
|
+
df = await query(page, '年初至今收益率前50', query_type=QueryType.Fund, max_page=1, site=Site.TDX)
|
|
79
|
+
print(df.to_csv())
|
|
80
|
+
df = await query(page, '流通市值前10的行业板块', query_type=QueryType.Index, max_page=1, site=Site.TDX)
|
|
81
|
+
print(df.to_csv())
|
|
82
|
+
# TODO 东财翻页要提前登录
|
|
83
|
+
df = await query(page, '今日涨幅前5的概念板块;', query_type=QueryType.Board, max_page=3, site=Site.EastMoney)
|
|
84
|
+
print(df)
|
|
85
|
+
|
|
86
|
+
output = await chat(page, "1+2等于多少?", provider=Provider.YuanBao)
|
|
87
|
+
print(output)
|
|
88
|
+
output = await chat(page, "3+4等于多少?", provider=Provider.YuanBao, create=True)
|
|
89
|
+
print(output)
|
|
90
|
+
|
|
91
|
+
print('done')
|
|
92
|
+
bm.release_page(page)
|
|
93
|
+
await page.wait_for_timeout(2000)
|
|
94
94
|
|
|
95
95
|
|
|
96
96
|
if __name__ == '__main__':
|
|
97
|
-
|
|
97
|
+
asyncio.run(main())
|
|
98
98
|
|
|
99
99
|
```
|
|
100
100
|
|
|
@@ -132,7 +132,7 @@ if __name__ == '__main__':
|
|
|
132
132
|
|
|
133
133
|
确保可以在控制台中执行`python -m mcp_query_table -h`。如果不能,可能要先`pip install mcp_query_table`
|
|
134
134
|
|
|
135
|
-
在`Cline`中可以配置如下。其中`command`是`python`的绝对路径,`
|
|
135
|
+
在`Cline`中可以配置如下。其中`command`是`python`的绝对路径,`executable_path`是`Chrome`的绝对路径。
|
|
136
136
|
|
|
137
137
|
### STDIO方式
|
|
138
138
|
|
|
@@ -146,7 +146,9 @@ if __name__ == '__main__':
|
|
|
146
146
|
"mcp_query_table",
|
|
147
147
|
"--format",
|
|
148
148
|
"markdown",
|
|
149
|
-
"--
|
|
149
|
+
"--cdp_endpoint",
|
|
150
|
+
"http://127.0.0.1:9222",
|
|
151
|
+
"--executable_path",
|
|
150
152
|
"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"
|
|
151
153
|
]
|
|
152
154
|
}
|
|
@@ -159,11 +161,20 @@ if __name__ == '__main__':
|
|
|
159
161
|
先在控制台中执行如下命令,启动`MCP`服务
|
|
160
162
|
|
|
161
163
|
```commandline
|
|
162
|
-
python -m mcp_query_table --format markdown --
|
|
164
|
+
python -m mcp_query_table --format markdown --transport sse --port 8000
|
|
163
165
|
```
|
|
164
166
|
|
|
165
167
|
然后就可以连接到`MCP`服务了
|
|
166
|
-
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"mcpServers": {
|
|
172
|
+
"mcp_query_table": {
|
|
173
|
+
"url": "http://127.0.0.1:8000/sse"
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
167
178
|
|
|
168
179
|
## 使用`MCP Inspector`进行调试
|
|
169
180
|
|
|
@@ -171,7 +182,8 @@ http://localhost:8000/sse
|
|
|
171
182
|
npx @modelcontextprotocol/inspector python -m mcp_query_table --format markdown
|
|
172
183
|
```
|
|
173
184
|
|
|
174
|
-
打开浏览器并翻页是一个比较耗时的操作,会导致`MCP Inspector`页面超时,可以`http://localhost:5173/?timeout=600000`
|
|
185
|
+
打开浏览器并翻页是一个比较耗时的操作,会导致`MCP Inspector`页面超时,可以`http://localhost:5173/?timeout=600000`
|
|
186
|
+
表示超时时间为600秒
|
|
175
187
|
|
|
176
188
|
第一次尝试编写`MCP`项目,可能会有各种问题,欢迎大家交流。
|
|
177
189
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
mcp_query_table/__init__.py,sha256=gNXLL6MtH667HEdsUbJ4OAbGqwYO1dLdkqorV3-RtLM,238
|
|
2
|
+
mcp_query_table/__main__.py,sha256=W3tMnZZTvkhjlLHmSYHng3CTvYX6-LjyaBDhf-ypH7w,1186
|
|
3
|
+
mcp_query_table/_version.py,sha256=vNiWJ14r_cw5t_7UDqDQIVZvladKFGyHH2avsLpN7Vg,22
|
|
4
|
+
mcp_query_table/enums.py,sha256=l-6uuGyniMVJGNh4tx9ZtktIjKSqyoHBHCJAdaOvczY,628
|
|
5
|
+
mcp_query_table/server.py,sha256=l8tt-1UNjTc5A8r3jGPt5REyCzU7N1t9_ndNJmThJ9k,3264
|
|
6
|
+
mcp_query_table/tool.py,sha256=X-mopuv0QRiQ2J_VLDcVWkH8ynXVTPgl6vlaYnDKnWA,8143
|
|
7
|
+
mcp_query_table/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
mcp_query_table/providers/baidu.py,sha256=N7D2mWzVfNJ2dbAMbdHisoBdac17-joyeF7BkFhLKPQ,2560
|
|
9
|
+
mcp_query_table/providers/n.py,sha256=H8hXgai8GDj3KizS2du4ix28PZlDaD6BkoyaheJnYd4,2152
|
|
10
|
+
mcp_query_table/providers/yuanbao.py,sha256=eTcOeV1ERFq7x5EgThBe9zsSodriGy7-eIWJRqcgwYU,2350
|
|
11
|
+
mcp_query_table/sites/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
mcp_query_table/sites/eastmoney.py,sha256=LImjpYVuM5YnXwnNzB2hkKfHofocZZScetGqMOCHZpk,4477
|
|
13
|
+
mcp_query_table/sites/iwencai.py,sha256=g56pj3pbxu4mXLNnaaS3Hdx-DvEy_9OBrQJe26z4z08,5059
|
|
14
|
+
mcp_query_table/sites/tdx.py,sha256=RIUQaB7Tn4AVyWaevk9SzTKIDwVO2f9erIlI-adXPLY,4126
|
|
15
|
+
mcp_query_table-0.3.2.dist-info/licenses/LICENSE,sha256=rbvv_CTd7biGwT21tvhgQ2zkbPFXOoON7WFQWEdElBA,1063
|
|
16
|
+
mcp_query_table-0.3.2.dist-info/METADATA,sha256=D9kCuwRBvBsn1RRc0ysYwSPia_94ferz8UVlye68GwM,8187
|
|
17
|
+
mcp_query_table-0.3.2.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
18
|
+
mcp_query_table-0.3.2.dist-info/top_level.txt,sha256=5M_8dkO1USOX7_EWbWS6O_TEsZ5yo-AodFNKeUEgvEQ,16
|
|
19
|
+
mcp_query_table-0.3.2.dist-info/RECORD,,
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
mcp_query_table/__init__.py,sha256=HqE0MJttWSwaeAhmm-tsPN3kZ4nrZUKwlfnyYJGHVRs,126
|
|
2
|
-
mcp_query_table/__main__.py,sha256=SmOaVfIDX4dcF-SV_xcn-Sfn3io-XunsdwKPnGfzwAU,1150
|
|
3
|
-
mcp_query_table/_version.py,sha256=VrXpHDu3erkzwl_WXrqINBm9xWkcyUy53IQOj042dOs,22
|
|
4
|
-
mcp_query_table/enums.py,sha256=378RbWeuCoRdJ2TxK-yMKg3rrJS0IpeI7UP5J1uveD8,625
|
|
5
|
-
mcp_query_table/server.py,sha256=QbkpK0s_5CDORrKesH845tT_GqosHUkRxKOWBrFsOsc,3101
|
|
6
|
-
mcp_query_table/tool.py,sha256=qfjWJN3KWncLoOtZz9N5s-hm2_cWjVLL2iHgoO2MCP8,6591
|
|
7
|
-
mcp_query_table/providers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
mcp_query_table/providers/baidu.py,sha256=CsmSjtnuzo-1aZxK5kGhIQjM9RpBmfpWVaEU5rofJyU,2541
|
|
9
|
-
mcp_query_table/providers/n.py,sha256=GYGoKN0BOOWkUKiW1DAn_9yyAvUBhZ6j3aNLy2cI99w,2138
|
|
10
|
-
mcp_query_table/providers/yuanbao.py,sha256=lkRbxe9EqciCCnJiucqRpMwD-sm4XkXRW_gVO7ZwzNU,2322
|
|
11
|
-
mcp_query_table/sites/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
mcp_query_table/sites/eastmoney.py,sha256=LImjpYVuM5YnXwnNzB2hkKfHofocZZScetGqMOCHZpk,4477
|
|
13
|
-
mcp_query_table/sites/iwencai.py,sha256=g56pj3pbxu4mXLNnaaS3Hdx-DvEy_9OBrQJe26z4z08,5059
|
|
14
|
-
mcp_query_table/sites/tdx.py,sha256=RIUQaB7Tn4AVyWaevk9SzTKIDwVO2f9erIlI-adXPLY,4126
|
|
15
|
-
mcp_query_table-0.3.0.dist-info/licenses/LICENSE,sha256=rbvv_CTd7biGwT21tvhgQ2zkbPFXOoON7WFQWEdElBA,1063
|
|
16
|
-
mcp_query_table-0.3.0.dist-info/METADATA,sha256=BNAaJWqlddE_wS2saWGSNK-QzgIAmlwAobBQrPQ24Eo,8044
|
|
17
|
-
mcp_query_table-0.3.0.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
|
18
|
-
mcp_query_table-0.3.0.dist-info/top_level.txt,sha256=5M_8dkO1USOX7_EWbWS6O_TEsZ5yo-AodFNKeUEgvEQ,16
|
|
19
|
-
mcp_query_table-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|