openboost-cli 2.0.1__tar.gz → 2.0.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.
Files changed (85) hide show
  1. {openboost_cli-2.0.1/src/openboost_cli.egg-info → openboost_cli-2.0.2}/PKG-INFO +1 -1
  2. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/README.md +1 -1
  3. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/pyproject.toml +1 -1
  4. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/__init__.py +6 -6
  5. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/cli/main.py +25 -13
  6. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/mcp_client.py +19 -19
  7. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/parse_result.py +27 -12
  8. {openboost_cli-2.0.1 → openboost_cli-2.0.2/src/openboost_cli.egg-info}/PKG-INFO +1 -1
  9. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/tests/test_cli.py +19 -5
  10. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/tests/test_config.py +10 -10
  11. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/tests/test_mcp_client.py +33 -33
  12. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/tests/test_schemas_and_parsing.py +15 -6
  13. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/LICENSE +0 -0
  14. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/setup.cfg +0 -0
  15. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/cli/__init__.py +0 -0
  16. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/cli/interactive.py +0 -0
  17. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/client.py +0 -0
  18. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/coerce_args.py +0 -0
  19. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/config.py +0 -0
  20. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/registry.py +0 -0
  21. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/__init__.py +0 -0
  22. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/__init__.py +0 -0
  23. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_category_query.json +0 -0
  24. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_hot_amz_hot_cat_tree.json +0 -0
  25. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_hot_amz_hot_list.json +0 -0
  26. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_market_price.json +0 -0
  27. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_product_selection.json +0 -0
  28. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_review_query.json +0 -0
  29. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_sales_query.json +0 -0
  30. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/amazon/amz_sku_query.json +0 -0
  31. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/__init__.py +0 -0
  32. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_abstract_image.json +0 -0
  33. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_abstract_translated.json +0 -0
  34. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_bibliography.json +0 -0
  35. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_claim_data.json +0 -0
  36. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_claim_translated.json +0 -0
  37. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_description.json +0 -0
  38. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_description_translated.json +0 -0
  39. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_family.json +0 -0
  40. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_fulltext_image.json +0 -0
  41. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_image_search_multiple.json +0 -0
  42. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_image_search_single.json +0 -0
  43. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_legal_status.json +0 -0
  44. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_pdf.json +0 -0
  45. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_query_count.json +0 -0
  46. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_query_search.json +0 -0
  47. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_query_search_with_agg.json +0 -0
  48. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/patent/patent_semantic_search.json +0 -0
  49. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/__init__.py +0 -0
  50. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tk_expert_sale_show.json +0 -0
  51. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_detail.json +0 -0
  52. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_expert_draw_expert_trend.json +0 -0
  53. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_get_commodity_cat_tree.json +0 -0
  54. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_info_list.json +0 -0
  55. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_sales_trend.json +0 -0
  56. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_statistics_get_category_statistics.json +0 -0
  57. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_statistics_get_expert_statistics.json +0 -0
  58. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_statistics_get_price_statistics.json +0 -0
  59. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_statistics_get_total_statistics.json +0 -0
  60. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_commodity_voice_analyze.json +0 -0
  61. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_basic_analyze.json +0 -0
  62. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_category_analyze.json +0 -0
  63. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_detail.json +0 -0
  64. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_fans_analyze.json +0 -0
  65. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_fans_portrait.json +0 -0
  66. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_expert_info_list.json +0 -0
  67. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_sale_channel_sale_channel.json +0 -0
  68. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_shop_commodity_account_list.json +0 -0
  69. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_shop_detail.json +0 -0
  70. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_shop_info_list.json +0 -0
  71. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_shop_market_info.json +0 -0
  72. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_shop_sales_trend.json +0 -0
  73. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_content.json +0 -0
  74. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_detail.json +0 -0
  75. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_info_list.json +0 -0
  76. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_new_video_summary.json +0 -0
  77. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_script_diy_query.json +0 -0
  78. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_voice_read.json +0 -0
  79. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas/tiktok/tt_video_voice_summary.json +0 -0
  80. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli/schemas_loader.py +0 -0
  81. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli.egg-info/SOURCES.txt +0 -0
  82. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli.egg-info/dependency_links.txt +0 -0
  83. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli.egg-info/entry_points.txt +0 -0
  84. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli.egg-info/requires.txt +0 -0
  85. {openboost_cli-2.0.1 → openboost_cli-2.0.2}/src/openboost_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: openboost-cli
3
- Version: 2.0.1
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
@@ -34,7 +34,7 @@ openboost config set --secret-key "your-secret-key"
34
34
 
35
35
  ```bash
36
36
  openboost config set --mcp amazon --secret-key "your-secret-key"
37
- openboost config set --mcp amazon --base-url "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse"
37
+ openboost config set --mcp amazon --base-url "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse"
38
38
  ```
39
39
 
40
40
  默认配置文件位于:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "openboost-cli"
7
- version = "2.0.1"
7
+ version = "2.0.2"
8
8
  description = "Unified CLI and Python client for OpenBoost TikTok, Patent, and Amazon MCP servers."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,12 +1,12 @@
1
1
  """Unified OpenBoost MCP CLI and Python client."""
2
2
 
3
- __version__ = "2.0.1"
3
+ __version__ = "2.0.2"
4
4
 
5
- DEFAULT_BASE_URLS = {
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
- }
5
+ DEFAULT_BASE_URLS = {
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
+ }
10
10
 
11
11
  MCP_LABELS = {
12
12
  "tiktok": "TikTok",
@@ -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 SSE URL")]
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
- console.print_json(json.dumps(data, ensure_ascii=False))
96
- else:
97
- console.print(str(data))
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
- console.print(text)
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
- console.print(text)
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")
@@ -4,9 +4,9 @@ import asyncio
4
4
  from datetime import timedelta
5
5
  from typing import Any
6
6
 
7
- from mcp import ClientSession
8
- from mcp import types as mtypes
9
- from mcp.client.sse import sse_client
7
+ from mcp import ClientSession
8
+ from mcp import types as mtypes
9
+ from mcp.client.sse import sse_client
10
10
 
11
11
  from openboost_cli.config import effective_secret_and_base, normalize_mcp_name
12
12
  from openboost_cli.parse_result import decode_embedded_payload
@@ -29,22 +29,22 @@ async def invoke_tool_async(
29
29
  *,
30
30
  connect_timeout_sec: float = 30,
31
31
  read_timeout_sec: float = 300,
32
- ) -> mtypes.CallToolResult:
33
- headers = {"secret-key": secret_key}
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
- )
32
+ ) -> mtypes.CallToolResult:
33
+ headers = {"secret-key": secret_key}
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
+ )
48
48
 
49
49
 
50
50
  class McpClient:
@@ -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 _last_longest_json_value(text: str) -> tuple[Any | None, int]:
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 json.loads(stripped)
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 json.loads(block)
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.1
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
@@ -1,6 +1,8 @@
1
- from __future__ import annotations
2
-
3
- from typing import Any
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ import json
5
+ from typing import Any
4
6
 
5
7
  import pytest
6
8
  from typer.testing import CliRunner
@@ -25,11 +27,23 @@ def test_help_uses_openboost_brand() -> None:
25
27
  assert "call" in result.output
26
28
 
27
29
 
28
- def test_version() -> None:
30
+ def test_version() -> None:
29
31
  result = runner.invoke(cli.app, ["version"])
30
32
 
31
33
  assert result.exit_code == 0
32
- assert "2.0.1" in result.output
34
+ assert "2.0.2" in result.output
35
+
36
+
37
+ def test_redirected_json_output_is_single_line_ascii_safe_json(monkeypatch: pytest.MonkeyPatch) -> None:
38
+ output = io.StringIO()
39
+ monkeypatch.setattr(cli.sys, "stdout", output)
40
+
41
+ cli._print_json({"success": True, "catCnName": "汽车与摩托车"})
42
+
43
+ raw = output.getvalue()
44
+ assert raw.count("\n") == 1
45
+ assert "\\u6c7d\\u8f66" in raw
46
+ assert json.loads(raw) == {"success": True, "catCnName": "汽车与摩托车"}
33
47
 
34
48
 
35
49
  def test_list_reports_all_bundled_tools() -> None:
@@ -4,16 +4,16 @@ import json
4
4
  from pathlib import Path
5
5
 
6
6
  from openboost_cli import DEFAULT_BASE_URLS
7
- from openboost_cli.config import config_path, effective_secret_and_base, load_config, mask_secret, update_config
8
-
9
-
10
- def test_default_mcp_urls_use_unified_openboost_sse_endpoint() -> None:
11
- expected = "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse"
12
-
13
- assert set(DEFAULT_BASE_URLS.values()) == {expected}
14
-
15
-
16
- def test_config_uses_only_openboost_names(monkeypatch, tmp_path: Path) -> None:
7
+ from openboost_cli.config import config_path, effective_secret_and_base, load_config, mask_secret, update_config
8
+
9
+
10
+ def test_default_mcp_urls_use_unified_openboost_sse_endpoint() -> None:
11
+ expected = "http://mcp.microdata-inc.com/mcp-servers/openboost-all-mcp/sse"
12
+
13
+ assert set(DEFAULT_BASE_URLS.values()) == {expected}
14
+
15
+
16
+ def test_config_uses_only_openboost_names(monkeypatch, tmp_path: Path) -> None:
17
17
  path = tmp_path / "openboost.json"
18
18
  monkeypatch.setenv("OPENBOOST_CONFIG", str(path))
19
19
  monkeypatch.setenv("PROBOOST_SECRET_KEY", "ignored-old-secret")
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import asyncio
4
- from datetime import timedelta
4
+ from datetime import timedelta
5
5
  from types import SimpleNamespace
6
6
 
7
7
  import pytest
@@ -61,30 +61,30 @@ def test_python_client_raises_mcp_error(monkeypatch: pytest.MonkeyPatch) -> None
61
61
  client.call_tool("patent_query_count", {"query_text": "test"})
62
62
 
63
63
 
64
- def test_invoke_tool_uses_sse_protocol(monkeypatch: pytest.MonkeyPatch) -> None:
65
- observed = {}
66
-
67
- class FakeSseClient:
68
- def __init__(self, base_url, *, headers, timeout, sse_read_timeout):
69
- observed["base_url"] = base_url
70
- observed["headers"] = headers
71
- observed["timeout"] = timeout
72
- observed["sse_read_timeout"] = sse_read_timeout
73
-
74
- async def __aenter__(self):
75
- return "read", "write"
76
-
77
- async def __aexit__(self, exc_type, exc, tb):
78
- return False
79
-
80
- def fake_sse_client(base_url, *, headers, timeout, sse_read_timeout):
81
- observed["base_url"] = base_url
82
- return FakeSseClient(
83
- base_url,
84
- headers=headers,
85
- timeout=timeout,
86
- sse_read_timeout=sse_read_timeout,
87
- )
64
+ def test_invoke_tool_uses_sse_protocol(monkeypatch: pytest.MonkeyPatch) -> None:
65
+ observed = {}
66
+
67
+ class FakeSseClient:
68
+ def __init__(self, base_url, *, headers, timeout, sse_read_timeout):
69
+ observed["base_url"] = base_url
70
+ observed["headers"] = headers
71
+ observed["timeout"] = timeout
72
+ observed["sse_read_timeout"] = sse_read_timeout
73
+
74
+ async def __aenter__(self):
75
+ return "read", "write"
76
+
77
+ async def __aexit__(self, exc_type, exc, tb):
78
+ return False
79
+
80
+ def fake_sse_client(base_url, *, headers, timeout, sse_read_timeout):
81
+ observed["base_url"] = base_url
82
+ return FakeSseClient(
83
+ base_url,
84
+ headers=headers,
85
+ timeout=timeout,
86
+ sse_read_timeout=sse_read_timeout,
87
+ )
88
88
 
89
89
  class FakeSession:
90
90
  def __init__(self, read, write):
@@ -103,8 +103,8 @@ def test_invoke_tool_uses_sse_protocol(monkeypatch: pytest.MonkeyPatch) -> None:
103
103
  observed["call"] = (name, arguments, read_timeout_seconds)
104
104
  return text_result('{"ok": true}')
105
105
 
106
- monkeypatch.setattr(mcp_client, "sse_client", fake_sse_client)
107
- monkeypatch.setattr(mcp_client, "ClientSession", FakeSession)
106
+ monkeypatch.setattr(mcp_client, "sse_client", fake_sse_client)
107
+ monkeypatch.setattr(mcp_client, "ClientSession", FakeSession)
108
108
 
109
109
  result = asyncio.run(
110
110
  mcp_client.invoke_tool_async(
@@ -117,12 +117,12 @@ def test_invoke_tool_uses_sse_protocol(monkeypatch: pytest.MonkeyPatch) -> None:
117
117
  )
118
118
  )
119
119
 
120
- assert result.isError is False
121
- assert observed["headers"] == {"secret-key": "test-secret"}
122
- assert observed["base_url"] == "http://mcp.example/server"
123
- assert observed["timeout"] == 12
124
- assert observed["sse_read_timeout"] == 34
125
- assert observed["initialized"] is True
120
+ assert result.isError is False
121
+ assert observed["headers"] == {"secret-key": "test-secret"}
122
+ assert observed["base_url"] == "http://mcp.example/server"
123
+ assert observed["timeout"] == 12
124
+ assert observed["sse_read_timeout"] == 34
125
+ assert observed["initialized"] is True
126
126
  assert observed["call"] == (
127
127
  "existing_tool_name",
128
128
  {"existingField": "value"},
@@ -1,6 +1,8 @@
1
- from __future__ import annotations
2
-
3
- import pytest
1
+ from __future__ import annotations
2
+
3
+ import json
4
+
5
+ import pytest
4
6
 
5
7
  from openboost_cli.coerce_args import coerce_argument_value, merge_tool_arguments_json
6
8
  from openboost_cli.parse_result import decode_embedded_payload
@@ -59,6 +61,13 @@ def test_decode_embedded_payload(text, expected) -> None:
59
61
  assert decode_embedded_payload(text) == expected
60
62
 
61
63
 
62
- def test_decode_embedded_payload_rejects_plain_text() -> None:
63
- with pytest.raises(ValueError, match="No JSON object"):
64
- decode_embedded_payload("plain text")
64
+ def test_decode_embedded_payload_rejects_plain_text() -> None:
65
+ with pytest.raises(ValueError, match="No JSON object"):
66
+ decode_embedded_payload("plain text")
67
+
68
+
69
+ def test_decode_embedded_payload_unwraps_nested_json_string() -> None:
70
+ payload = {"success": True, "data": [{"catCnName": "汽车与摩托车"}]}
71
+ nested = json.dumps(json.dumps(payload, ensure_ascii=False), ensure_ascii=False)
72
+
73
+ assert decode_embedded_payload(nested) == payload
File without changes
File without changes