openboost-cli 2.0.0__py3-none-any.whl → 2.0.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.
- openboost_cli/__init__.py +4 -4
- openboost_cli/cli/main.py +25 -13
- openboost_cli/mcp_client.py +15 -14
- openboost_cli/parse_result.py +27 -12
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/METADATA +2 -2
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/RECORD +10 -10
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/WHEEL +0 -0
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/entry_points.txt +0 -0
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/licenses/LICENSE +0 -0
- {openboost_cli-2.0.0.dist-info → openboost_cli-2.0.2.dist-info}/top_level.txt +0 -0
openboost_cli/__init__.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""Unified OpenBoost MCP CLI and Python client."""
|
|
2
2
|
|
|
3
|
-
__version__ = "2.0.
|
|
3
|
+
__version__ = "2.0.2"
|
|
4
4
|
|
|
5
5
|
DEFAULT_BASE_URLS = {
|
|
6
|
-
"tiktok": "http://mcp.microdata-inc.com/mcp-servers/
|
|
7
|
-
"patent": "http://mcp.microdata-inc.com/mcp-servers/
|
|
8
|
-
"amazon": "http://mcp.microdata-inc.com/mcp-servers/
|
|
6
|
+
"tiktok": "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse",
|
|
7
|
+
"patent": "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse",
|
|
8
|
+
"amazon": "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse",
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
MCP_LABELS = {
|
openboost_cli/cli/main.py
CHANGED
|
@@ -71,7 +71,7 @@ amazon_app.add_typer(amazon_hot_app, name="hot")
|
|
|
71
71
|
_state: dict[str, str | None] = {"secret_key": None, "base_url": None}
|
|
72
72
|
|
|
73
73
|
KeyOpt = Annotated[Optional[str], typer.Option("--key", "-k", help="secret-key")]
|
|
74
|
-
BaseUrlOpt = Annotated[Optional[str], typer.Option("--base-url", "-u", help="MCP
|
|
74
|
+
BaseUrlOpt = Annotated[Optional[str], typer.Option("--base-url", "-u", help="MCP SSE URL")]
|
|
75
75
|
McpArg = Annotated[str, typer.Argument(help="MCP 名称: tiktok / patent / amazon")]
|
|
76
76
|
CountryOpt = Annotated[str, typer.Option("--country-region", "--country", help="国家/地区,如 美国")]
|
|
77
77
|
CurrentOpt = Annotated[Optional[int], typer.Option("--current", help="当前页码")]
|
|
@@ -90,11 +90,23 @@ def main_callback(ctx: typer.Context, key: KeyOpt = None, base_url: BaseUrlOpt =
|
|
|
90
90
|
interactive.run_interactive(secret_key=key, base_url=base_url)
|
|
91
91
|
|
|
92
92
|
|
|
93
|
-
def _print_json(data: Any) -> None:
|
|
94
|
-
if isinstance(data, (dict, list)):
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
def _print_json(data: Any) -> None:
|
|
94
|
+
if isinstance(data, (dict, list)):
|
|
95
|
+
if sys.stdout.isatty():
|
|
96
|
+
console.print_json(json.dumps(data, ensure_ascii=False))
|
|
97
|
+
else:
|
|
98
|
+
sys.stdout.write(json.dumps(data, ensure_ascii=True, separators=(",", ":")) + "\n")
|
|
99
|
+
else:
|
|
100
|
+
_print_text(str(data))
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _print_text(text: str) -> None:
|
|
104
|
+
if sys.stdout.isatty():
|
|
105
|
+
console.print(text)
|
|
106
|
+
else:
|
|
107
|
+
sys.stdout.write(text)
|
|
108
|
+
if not text.endswith("\n"):
|
|
109
|
+
sys.stdout.write("\n")
|
|
98
110
|
|
|
99
111
|
|
|
100
112
|
def _props(mcp: str, tool_name: str) -> dict[str, Any]:
|
|
@@ -137,9 +149,9 @@ def _run_tool(mcp: str, tool_name: str, arguments: dict[str, Any], *, verbatim:
|
|
|
137
149
|
console.print(str(exc), style="red")
|
|
138
150
|
raise typer.Exit(2) from exc
|
|
139
151
|
|
|
140
|
-
text = extract_result_text(result)
|
|
141
|
-
if verbatim:
|
|
142
|
-
|
|
152
|
+
text = extract_result_text(result)
|
|
153
|
+
if verbatim:
|
|
154
|
+
_print_text(text)
|
|
143
155
|
raise typer.Exit(3 if result.isError else 0)
|
|
144
156
|
if result.isError:
|
|
145
157
|
console.print(text or "(tool error)", style="red")
|
|
@@ -148,10 +160,10 @@ def _run_tool(mcp: str, tool_name: str, arguments: dict[str, Any], *, verbatim:
|
|
|
148
160
|
if isinstance(structured, (dict, list)):
|
|
149
161
|
_print_json(structured)
|
|
150
162
|
return
|
|
151
|
-
try:
|
|
152
|
-
_print_json(decode_embedded_payload(text))
|
|
153
|
-
except ValueError:
|
|
154
|
-
|
|
163
|
+
try:
|
|
164
|
+
_print_json(decode_embedded_payload(text))
|
|
165
|
+
except ValueError:
|
|
166
|
+
_print_text(text)
|
|
155
167
|
|
|
156
168
|
|
|
157
169
|
@app.command("version")
|
openboost_cli/mcp_client.py
CHANGED
|
@@ -4,11 +4,9 @@ import asyncio
|
|
|
4
4
|
from datetime import timedelta
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
|
-
import httpx
|
|
8
7
|
from mcp import ClientSession
|
|
9
8
|
from mcp import types as mtypes
|
|
10
|
-
from mcp.client.
|
|
11
|
-
from mcp.shared._httpx_utils import create_mcp_http_client
|
|
9
|
+
from mcp.client.sse import sse_client
|
|
12
10
|
|
|
13
11
|
from openboost_cli.config import effective_secret_and_base, normalize_mcp_name
|
|
14
12
|
from openboost_cli.parse_result import decode_embedded_payload
|
|
@@ -33,17 +31,20 @@ async def invoke_tool_async(
|
|
|
33
31
|
read_timeout_sec: float = 300,
|
|
34
32
|
) -> mtypes.CallToolResult:
|
|
35
33
|
headers = {"secret-key": secret_key}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
|
|
35
|
+
async with sse_client(
|
|
36
|
+
base_url,
|
|
37
|
+
headers=headers,
|
|
38
|
+
timeout=connect_timeout_sec,
|
|
39
|
+
sse_read_timeout=read_timeout_sec,
|
|
40
|
+
) as (read, write):
|
|
41
|
+
async with ClientSession(read, write) as session:
|
|
42
|
+
await session.initialize()
|
|
43
|
+
return await session.call_tool(
|
|
44
|
+
tool_name,
|
|
45
|
+
arguments,
|
|
46
|
+
read_timeout_seconds=timedelta(seconds=read_timeout_sec),
|
|
47
|
+
)
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
class McpClient:
|
openboost_cli/parse_result.py
CHANGED
|
@@ -5,10 +5,25 @@ import re
|
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
_JSON_FENCE_RE = re.compile(r"```(?:json)?\s*([\s\S]*?)```", re.IGNORECASE)
|
|
8
|
-
_MARKER = "响应数据(JSON)"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def
|
|
8
|
+
_MARKER = "响应数据(JSON)"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _loads_json(text: str) -> Any:
|
|
12
|
+
value = json.loads(text)
|
|
13
|
+
for _ in range(4):
|
|
14
|
+
if not isinstance(value, str):
|
|
15
|
+
break
|
|
16
|
+
nested = value.strip()
|
|
17
|
+
if not nested.startswith(("{", "[")):
|
|
18
|
+
break
|
|
19
|
+
try:
|
|
20
|
+
value = json.loads(nested)
|
|
21
|
+
except json.JSONDecodeError:
|
|
22
|
+
break
|
|
23
|
+
return value
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _last_longest_json_value(text: str) -> tuple[Any | None, int]:
|
|
12
27
|
decoder = json.JSONDecoder()
|
|
13
28
|
best: Any | None = None
|
|
14
29
|
best_len = -1
|
|
@@ -25,25 +40,25 @@ def _last_longest_json_value(text: str) -> tuple[Any | None, int]:
|
|
|
25
40
|
return best, best_len
|
|
26
41
|
|
|
27
42
|
|
|
28
|
-
def decode_embedded_payload(text: str) -> Any:
|
|
29
|
-
stripped = text.strip()
|
|
30
|
-
try:
|
|
31
|
-
return
|
|
43
|
+
def decode_embedded_payload(text: str) -> Any:
|
|
44
|
+
stripped = text.strip()
|
|
45
|
+
try:
|
|
46
|
+
return _loads_json(stripped)
|
|
32
47
|
except json.JSONDecodeError:
|
|
33
48
|
pass
|
|
34
49
|
|
|
35
50
|
marker_idx = text.find(_MARKER)
|
|
36
51
|
if marker_idx >= 0:
|
|
37
|
-
tail = text[marker_idx + len(_MARKER) :].lstrip("\n:")
|
|
52
|
+
tail = text[marker_idx + len(_MARKER) :].lstrip("\n:")
|
|
38
53
|
try:
|
|
39
54
|
return decode_embedded_payload(tail)
|
|
40
55
|
except ValueError:
|
|
41
56
|
pass
|
|
42
57
|
|
|
43
58
|
for match in _JSON_FENCE_RE.finditer(text):
|
|
44
|
-
block = match.group(1).strip()
|
|
45
|
-
try:
|
|
46
|
-
return
|
|
59
|
+
block = match.group(1).strip()
|
|
60
|
+
try:
|
|
61
|
+
return _loads_json(block)
|
|
47
62
|
except json.JSONDecodeError:
|
|
48
63
|
continue
|
|
49
64
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openboost-cli
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.2
|
|
4
4
|
Summary: Unified CLI and Python client for OpenBoost TikTok, Patent, and Amazon MCP servers.
|
|
5
5
|
Author: OpenBoost CLI
|
|
6
6
|
License-Expression: MIT
|
|
@@ -56,7 +56,7 @@ openboost config set --secret-key "your-secret-key"
|
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
openboost config set --mcp amazon --secret-key "your-secret-key"
|
|
59
|
-
openboost config set --mcp amazon --base-url "http://mcp.microdata-inc.com/mcp-servers/
|
|
59
|
+
openboost config set --mcp amazon --base-url "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse"
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
默认配置文件位于:
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
openboost_cli/__init__.py,sha256=
|
|
1
|
+
openboost_cli/__init__.py,sha256=m8YBYqEfg4NQF2KR9PZzBzOtArzu7geWsepZN--ra1I,613
|
|
2
2
|
openboost_cli/client.py,sha256=jHb-sVXuViGh-aUHjwxM2ssJ2ZT32nza71Yzr1K9Ll0,1772
|
|
3
3
|
openboost_cli/coerce_args.py,sha256=X7XtLzv0F0MQiRk_lzd8CSCAOsI2BCrwwNvRU18dowU,1916
|
|
4
4
|
openboost_cli/config.py,sha256=8VLgh_FH9N-_UJ5DyslYZf7wIqzeyI0n7-LuSb4Iv6I,3187
|
|
5
|
-
openboost_cli/mcp_client.py,sha256=
|
|
6
|
-
openboost_cli/parse_result.py,sha256=
|
|
5
|
+
openboost_cli/mcp_client.py,sha256=k_3LYDLF7Jtc6R0MFNRcKmLa84u5pTEH3FxQpbrxj-s,3915
|
|
6
|
+
openboost_cli/parse_result.py,sha256=DW87Se0s8H4ZbHWajKb8iJJf_NThVCp5Mp-eLDwLZ24,1834
|
|
7
7
|
openboost_cli/registry.py,sha256=-meFvMdd87H1TG2r5y-2YP_O3XTJQsp8c0H-ZEC0_jI,3392
|
|
8
8
|
openboost_cli/schemas_loader.py,sha256=B03YAbDxsT3VVuKHAI74s6_nTIN4tqXAd8H0ywoROJQ,1592
|
|
9
9
|
openboost_cli/cli/__init__.py,sha256=lJ_3DIyJzHkk2VDB2ENyIKpc87zqJCQEgyGPYjoIJnE,25
|
|
10
10
|
openboost_cli/cli/interactive.py,sha256=BLg9OkQDdN9ixOsjVloQvPS5ZV2VJkxMs8CzRJLo7XU,4713
|
|
11
|
-
openboost_cli/cli/main.py,sha256=
|
|
11
|
+
openboost_cli/cli/main.py,sha256=IPst_aymRphVRYwETXijzQ5yf1BzcX9JIYsGXxjPQvI,33499
|
|
12
12
|
openboost_cli/schemas/__init__.py,sha256=pIKnuOBdX5nqw3eQj9POQr3xGQ81scLMCjEvT9TFB58,55
|
|
13
13
|
openboost_cli/schemas/amazon/__init__.py,sha256=Q1wr2GXle_G8ZgZ6WMALqFnkmduvLJCUl5t3pttoPNQ,34
|
|
14
14
|
openboost_cli/schemas/amazon/amz_category_query.json,sha256=il7usUcX6wODqly1HVFJDjM7F5X-_KwYxwm-XSZAN08,542
|
|
@@ -68,9 +68,9 @@ openboost_cli/schemas/tiktok/tt_video_new_video_summary.json,sha256=JRigehO0v3mt
|
|
|
68
68
|
openboost_cli/schemas/tiktok/tt_video_script_diy_query.json,sha256=y5xPaj2ioe3KHaAHD0_adStEG-wJapway1efnQVW1xA,729
|
|
69
69
|
openboost_cli/schemas/tiktok/tt_video_voice_read.json,sha256=GrOj2ru3Wo3dj0-F7QytLKFxKKJn86i8vxPmsTNe1J0,789
|
|
70
70
|
openboost_cli/schemas/tiktok/tt_video_voice_summary.json,sha256=PWNcih9Pye4lKhfHE1ipff5ZvsF_xAhKM01ijuCrS6s,893
|
|
71
|
-
openboost_cli-2.0.
|
|
72
|
-
openboost_cli-2.0.
|
|
73
|
-
openboost_cli-2.0.
|
|
74
|
-
openboost_cli-2.0.
|
|
75
|
-
openboost_cli-2.0.
|
|
76
|
-
openboost_cli-2.0.
|
|
71
|
+
openboost_cli-2.0.2.dist-info/licenses/LICENSE,sha256=WtoBh2kyvgEzy24AZ5QEpaysJOrHsDJqAh9VLL5c0ho,1104
|
|
72
|
+
openboost_cli-2.0.2.dist-info/METADATA,sha256=Zg18DD28Qep5QgIGXSoeIPd4W7OQpczxAa0wRigs5ek,3968
|
|
73
|
+
openboost_cli-2.0.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
74
|
+
openboost_cli-2.0.2.dist-info/entry_points.txt,sha256=4yhtbbjYqMlu2NtzSWyu3kx4Gru0HPNUwa7J8EDXI2c,58
|
|
75
|
+
openboost_cli-2.0.2.dist-info/top_level.txt,sha256=HCJbNNMwGKu5ccPAKEO_CEO34fWq2ucFJxtCysOFFBo,14
|
|
76
|
+
openboost_cli-2.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|