datasinking 0.2.9__tar.gz → 0.2.11__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datasinking
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: Python client for DataSinking — full-text Asian financial reports (China, Korea, Japan, Taiwan) as Markdown.
5
5
  Author: DataSinking
6
6
  License: MIT
@@ -73,7 +73,24 @@ output but can't redact a URL.
73
73
 
74
74
  ### Local — run it yourself
75
75
 
76
- If you'd rather keep everything on your own machine:
76
+ If you'd rather keep everything on your own machine, there are two identical builds — pick
77
+ whichever runtime you already have:
78
+
79
+ **Node 18+ (no Python needed):**
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "datasinking": {
85
+ "command": "npx",
86
+ "args": ["-y", "datasinking-mcp"],
87
+ "env": { "DATASINK_API_KEY": "YOUR_KEY" }
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Python 3.8+:**
77
94
 
78
95
  ```bash
79
96
  pip install "datasinking[mcp]"
@@ -82,7 +99,13 @@ datasinking-mcp # requires DATASINK_API_KEY (free at https://datasink.i
82
99
 
83
100
  Then use `command: datasinking-mcp` in your client.
84
101
 
85
- Full per-client setup: [`mcp-server.md`](mcp-server.md).
102
+ Both run the same six tools with the same schemas — `npm/` and `datasinking/mcp_server.py` are
103
+ kept in lockstep by [`check_mcp_parity.py`](check_mcp_parity.py).
104
+
105
+ Full per-client setup: [`mcp-server.md`](mcp-server.md) (overview) ·
106
+ [`docs/mcp/`](docs/mcp/) (one guide per client).
107
+ Hosted endpoint is **POST-only and stateless** — `GET /mcp` returns 405, no session id, and every
108
+ client needs a restart after a config change. That trips up most first connections.
86
109
 
87
110
  ![DataSinking MCP in Claude](docs/images/mcp-demo.png)
88
111
 
@@ -95,12 +118,27 @@ datasinking/
95
118
  ├── examples/ # Example scripts: pull data from the API and analyze it
96
119
  ├── research/ # Research notes / blog posts (reproducing paper-style presentation)
97
120
  ├── datasinking/ # Python client + MCP server — pip install "datasinking[mcp]"
98
- ├── mcp-server.md # How to configure the MCP server (for AI agents: Claude / Cursor / Codex / DeepSeek)
121
+ ├── npm/ # The same MCP server on npm — npx -y datasinking-mcp (Node 18+)
122
+ ├── docs/mcp/ # Per-client MCP setup: Claude Code, Claude Desktop, Cursor, Codex, WorkBuddy
123
+ ├── mcp-server.md # MCP server overview — the two config shapes, tools, endpoint limits
99
124
  ├── llm-examples.md # Ask an LLM — no code needed (8 end-to-end examples)
100
125
  ├── api-examples.md # 7 examples × 3 interfaces (curl / Python / LLM)
101
126
  └── README.md
102
127
  ```
103
128
 
129
+ Per-client MCP guides — one file each, with the exact config path, both scopes, verification and the
130
+ errors that client actually produces:
131
+
132
+ | Client | Guide |
133
+ |---|---|
134
+ | Claude Code | [`docs/mcp/claude-code.md`](docs/mcp/claude-code.md) |
135
+ | Claude Desktop | [`docs/mcp/claude-desktop.md`](docs/mcp/claude-desktop.md) |
136
+ | OpenAI Codex CLI | [`docs/mcp/codex.md`](docs/mcp/codex.md) |
137
+ | WorkBuddy / CodeBuddy | [`docs/mcp/workbuddy.md`](docs/mcp/workbuddy.md) |
138
+ | Cursor | [`docs/mcp/cursor.md`](docs/mcp/cursor.md) |
139
+ | DeepSeek | [`docs/mcp/deepseek.md`](docs/mcp/deepseek.md) |
140
+ | Windsurf | [`docs/mcp/windsurf.md`](docs/mcp/windsurf.md) |
141
+
104
142
  ## Quick start
105
143
 
106
144
  1. Get an API key at [datasink.ing](https://datasink.ing)
@@ -50,7 +50,24 @@ output but can't redact a URL.
50
50
 
51
51
  ### Local — run it yourself
52
52
 
53
- If you'd rather keep everything on your own machine:
53
+ If you'd rather keep everything on your own machine, there are two identical builds — pick
54
+ whichever runtime you already have:
55
+
56
+ **Node 18+ (no Python needed):**
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "datasinking": {
62
+ "command": "npx",
63
+ "args": ["-y", "datasinking-mcp"],
64
+ "env": { "DATASINK_API_KEY": "YOUR_KEY" }
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ **Python 3.8+:**
54
71
 
55
72
  ```bash
56
73
  pip install "datasinking[mcp]"
@@ -59,7 +76,13 @@ datasinking-mcp # requires DATASINK_API_KEY (free at https://datasink.i
59
76
 
60
77
  Then use `command: datasinking-mcp` in your client.
61
78
 
62
- Full per-client setup: [`mcp-server.md`](mcp-server.md).
79
+ Both run the same six tools with the same schemas — `npm/` and `datasinking/mcp_server.py` are
80
+ kept in lockstep by [`check_mcp_parity.py`](check_mcp_parity.py).
81
+
82
+ Full per-client setup: [`mcp-server.md`](mcp-server.md) (overview) ·
83
+ [`docs/mcp/`](docs/mcp/) (one guide per client).
84
+ Hosted endpoint is **POST-only and stateless** — `GET /mcp` returns 405, no session id, and every
85
+ client needs a restart after a config change. That trips up most first connections.
63
86
 
64
87
  ![DataSinking MCP in Claude](docs/images/mcp-demo.png)
65
88
 
@@ -72,12 +95,27 @@ datasinking/
72
95
  ├── examples/ # Example scripts: pull data from the API and analyze it
73
96
  ├── research/ # Research notes / blog posts (reproducing paper-style presentation)
74
97
  ├── datasinking/ # Python client + MCP server — pip install "datasinking[mcp]"
75
- ├── mcp-server.md # How to configure the MCP server (for AI agents: Claude / Cursor / Codex / DeepSeek)
98
+ ├── npm/ # The same MCP server on npm — npx -y datasinking-mcp (Node 18+)
99
+ ├── docs/mcp/ # Per-client MCP setup: Claude Code, Claude Desktop, Cursor, Codex, WorkBuddy
100
+ ├── mcp-server.md # MCP server overview — the two config shapes, tools, endpoint limits
76
101
  ├── llm-examples.md # Ask an LLM — no code needed (8 end-to-end examples)
77
102
  ├── api-examples.md # 7 examples × 3 interfaces (curl / Python / LLM)
78
103
  └── README.md
79
104
  ```
80
105
 
106
+ Per-client MCP guides — one file each, with the exact config path, both scopes, verification and the
107
+ errors that client actually produces:
108
+
109
+ | Client | Guide |
110
+ |---|---|
111
+ | Claude Code | [`docs/mcp/claude-code.md`](docs/mcp/claude-code.md) |
112
+ | Claude Desktop | [`docs/mcp/claude-desktop.md`](docs/mcp/claude-desktop.md) |
113
+ | OpenAI Codex CLI | [`docs/mcp/codex.md`](docs/mcp/codex.md) |
114
+ | WorkBuddy / CodeBuddy | [`docs/mcp/workbuddy.md`](docs/mcp/workbuddy.md) |
115
+ | Cursor | [`docs/mcp/cursor.md`](docs/mcp/cursor.md) |
116
+ | DeepSeek | [`docs/mcp/deepseek.md`](docs/mcp/deepseek.md) |
117
+ | Windsurf | [`docs/mcp/windsurf.md`](docs/mcp/windsurf.md) |
118
+
81
119
  ## Quick start
82
120
 
83
121
  1. Get an API key at [datasink.ing](https://datasink.ing)
@@ -8,4 +8,4 @@ pyproject.toml 用 `dynamic = ["version"]` 从这里读,`client.py` 的 User-A
8
8
  写着旧版本)。现在只有这一处需要改。
9
9
  """
10
10
 
11
- __version__ = "0.2.9"
11
+ __version__ = "0.2.11"
@@ -18,6 +18,7 @@ the environment variable ``DATASINK_API_KEY`` (get a free key at
18
18
  https://datasink.ing).
19
19
  """
20
20
 
21
+ import json
21
22
  import os
22
23
  from typing import Annotated, Optional
23
24
 
@@ -56,7 +57,18 @@ mcp = FastMCP(
56
57
 
57
58
 
58
59
  def _get(path: str, params: Optional[dict] = None) -> dict:
59
- """Call the DataSinking API, carrying the API key automatically."""
60
+ """Call the DataSinking API, carrying the API key automatically.
61
+
62
+ 出错时**把服务端 body 原文带出去**。它写的不是「失败了」,而是「该怎么办」:
63
+
64
+ ``detail`` 一句人话(「未找到章节「X」」)
65
+ ``available`` 那份报告的**全部真实标题**
66
+
67
+ ``get_section`` 的工具描述明确让模型「retry with one of those」,所以这个列表
68
+ 必须跟着异常走。原来这里是一句 ``r.raise_for_status()``,body 整个丢掉 ——
69
+ 模型只看到裸的 ``404 Client Error: Not Found for url: ...``,既不知道错在哪,
70
+ 也没有可重试的标题(2026-09-22 用真 key 实测,三份实现里这份丢得最干净)。
71
+ """
60
72
  if not API_KEY:
61
73
  raise RuntimeError(
62
74
  "Missing DATASINK_API_KEY environment variable (get a free key at https://datasink.ing)"
@@ -64,13 +76,24 @@ def _get(path: str, params: Optional[dict] = None) -> dict:
64
76
  p = dict(params or {})
65
77
  p["apikey"] = API_KEY
66
78
  r = requests.get(f"{BASE_URL}{path}", params=p, timeout=90)
67
- r.raise_for_status()
79
+ if not r.ok:
80
+ try:
81
+ body = r.json()
82
+ except ValueError:
83
+ body = None
84
+ if not isinstance(body, dict):
85
+ body = {}
86
+ msg = f"HTTP {r.status_code}: {body.get('detail') or r.text[:2000]}"
87
+ available = body.get("available")
88
+ if isinstance(available, list):
89
+ msg += "\nAvailable sections: " + json.dumps(available, ensure_ascii=False)
90
+ raise RuntimeError(msg)
68
91
  return r.json()
69
92
 
70
93
 
71
94
  @mcp.tool()
72
95
  def list_exchanges() -> list:
73
- """List the exchanges DataSinking covers and their report counts.
96
+ """List the exchanges DataSinking covers.
74
97
 
75
98
  Returns exchange codes (sse / szse / bj / ksc / koe / knx / jpx / twse / tpex) with
76
99
  the number of reports available per exchange. Call this first to discover coverage.
@@ -82,13 +105,13 @@ def list_exchanges() -> list:
82
105
  @mcp.tool()
83
106
  def list_stocks(
84
107
  exchange: Annotated[
85
- str, Field(description="Exchange code: sse / szse / bj / ksc / koe / knx / jpx / twse / tpex")
108
+ str, Field(description="Exchange code, e.g. sse / szse / bj / ksc / koe / knx / jpx / twse / tpex")
86
109
  ],
87
110
  limit: Annotated[
88
111
  int, Field(description="Return only the first N companies (default 20) to keep the response short.")
89
112
  ] = 20,
90
113
  ) -> dict:
91
- """List stocks on an exchange, including the report count per company."""
114
+ """List the stocks on one exchange, including the report count per company."""
92
115
  data = _get("/stocks", {"exchange": exchange})
93
116
  return {"exchange": exchange, "total": data.get("total", 0), "items": data.get("items", [])[:limit]}
94
117
 
@@ -99,13 +122,13 @@ def list_reports(
99
122
  str, Field(description="FMP-style symbol, e.g. 600519.SS / 005930.KS / 7203.T / 2330.TW")
100
123
  ],
101
124
  doc_type: Annotated[
102
- str, Field(description="annual / semiannual / q1 / q3")
125
+ str, Field(description="Report type to filter on. Defaults to annual.")
103
126
  ] = "annual",
104
127
  size: Annotated[int, Field(description="Number of reports to return (default 10).")] = 10,
105
128
  ) -> dict:
106
129
  """List a company's reports — metadata only (id, title, period), no body text.
107
130
 
108
- Each item carries a ``source`` field naming the official disclosure platform;
131
+ Each item carries a `source` field naming the official disclosure platform;
109
132
  keep that attribution when you cite it.
110
133
  """
111
134
  return _get("/documents", {"symbol": symbol, "doc_type": doc_type, "size": size})
@@ -115,9 +138,9 @@ def list_reports(
115
138
  def get_report(
116
139
  document_id: Annotated[int, Field(description="Report id, from list_reports items[].id")],
117
140
  ) -> dict:
118
- """Fetch a single report's full text (metadata + Markdown body).
141
+ """Fetch one report's full text (metadata + Markdown body).
119
142
 
120
- The ``source`` field names the official disclosure platform; keep that attribution
143
+ The `source` field names the official disclosure platform; keep that attribution
121
144
  when you cite it. Expensive in tokens — prefer get_section when you only need one chapter.
122
145
  """
123
146
  return _get(f"/documents/{document_id}")
@@ -127,13 +150,13 @@ def get_report(
127
150
  def list_sections(
128
151
  document_id: Annotated[int, Field(description="Report id, from list_reports items[].id")],
129
152
  ) -> dict:
130
- """List every section of a report with its size — call this before pulling anything.
153
+ """List every section of a report with its size, before you decide what to pull.
131
154
 
132
- Returns ``sections`` (titles, in order) plus ``section_details``: the same list as
133
- objects with ``title``, ``has_tables``, ``chars`` and ``estimated_tokens``.
155
+ Returns `sections` (titles, in order) plus `section_details` — same order, one entry
156
+ per section with `title`, `has_tables`, `chars` and `estimated_tokens`.
134
157
 
135
- Use ``estimated_tokens`` to avoid pulling a chapter that would blow your context,
136
- and ``has_tables`` to know whether a chapter needs special handling (tables are the
158
+ Use `estimated_tokens` to avoid pulling a chapter that would blow your context,
159
+ and `has_tables` to know whether the chapter needs special handling (tables are the
137
160
  part RAG pipelines usually get wrong). Then call get_section with a heading keyword —
138
161
  the headings are in the report's own language.
139
162
  """
@@ -157,7 +180,7 @@ def get_section(
157
180
  ),
158
181
  ],
159
182
  ) -> dict:
160
- """Fetch only one section of a report by keyword — cheaper than get_report for RAG."""
183
+ """Fetch only one section of a report by keyword — much cheaper than get_report, best for RAG."""
161
184
  return _get(f"/documents/{document_id}", {"section": section})
162
185
 
163
186
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datasinking
3
- Version: 0.2.9
3
+ Version: 0.2.11
4
4
  Summary: Python client for DataSinking — full-text Asian financial reports (China, Korea, Japan, Taiwan) as Markdown.
5
5
  Author: DataSinking
6
6
  License: MIT
@@ -73,7 +73,24 @@ output but can't redact a URL.
73
73
 
74
74
  ### Local — run it yourself
75
75
 
76
- If you'd rather keep everything on your own machine:
76
+ If you'd rather keep everything on your own machine, there are two identical builds — pick
77
+ whichever runtime you already have:
78
+
79
+ **Node 18+ (no Python needed):**
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "datasinking": {
85
+ "command": "npx",
86
+ "args": ["-y", "datasinking-mcp"],
87
+ "env": { "DATASINK_API_KEY": "YOUR_KEY" }
88
+ }
89
+ }
90
+ }
91
+ ```
92
+
93
+ **Python 3.8+:**
77
94
 
78
95
  ```bash
79
96
  pip install "datasinking[mcp]"
@@ -82,7 +99,13 @@ datasinking-mcp # requires DATASINK_API_KEY (free at https://datasink.i
82
99
 
83
100
  Then use `command: datasinking-mcp` in your client.
84
101
 
85
- Full per-client setup: [`mcp-server.md`](mcp-server.md).
102
+ Both run the same six tools with the same schemas — `npm/` and `datasinking/mcp_server.py` are
103
+ kept in lockstep by [`check_mcp_parity.py`](check_mcp_parity.py).
104
+
105
+ Full per-client setup: [`mcp-server.md`](mcp-server.md) (overview) ·
106
+ [`docs/mcp/`](docs/mcp/) (one guide per client).
107
+ Hosted endpoint is **POST-only and stateless** — `GET /mcp` returns 405, no session id, and every
108
+ client needs a restart after a config change. That trips up most first connections.
86
109
 
87
110
  ![DataSinking MCP in Claude](docs/images/mcp-demo.png)
88
111
 
@@ -95,12 +118,27 @@ datasinking/
95
118
  ├── examples/ # Example scripts: pull data from the API and analyze it
96
119
  ├── research/ # Research notes / blog posts (reproducing paper-style presentation)
97
120
  ├── datasinking/ # Python client + MCP server — pip install "datasinking[mcp]"
98
- ├── mcp-server.md # How to configure the MCP server (for AI agents: Claude / Cursor / Codex / DeepSeek)
121
+ ├── npm/ # The same MCP server on npm — npx -y datasinking-mcp (Node 18+)
122
+ ├── docs/mcp/ # Per-client MCP setup: Claude Code, Claude Desktop, Cursor, Codex, WorkBuddy
123
+ ├── mcp-server.md # MCP server overview — the two config shapes, tools, endpoint limits
99
124
  ├── llm-examples.md # Ask an LLM — no code needed (8 end-to-end examples)
100
125
  ├── api-examples.md # 7 examples × 3 interfaces (curl / Python / LLM)
101
126
  └── README.md
102
127
  ```
103
128
 
129
+ Per-client MCP guides — one file each, with the exact config path, both scopes, verification and the
130
+ errors that client actually produces:
131
+
132
+ | Client | Guide |
133
+ |---|---|
134
+ | Claude Code | [`docs/mcp/claude-code.md`](docs/mcp/claude-code.md) |
135
+ | Claude Desktop | [`docs/mcp/claude-desktop.md`](docs/mcp/claude-desktop.md) |
136
+ | OpenAI Codex CLI | [`docs/mcp/codex.md`](docs/mcp/codex.md) |
137
+ | WorkBuddy / CodeBuddy | [`docs/mcp/workbuddy.md`](docs/mcp/workbuddy.md) |
138
+ | Cursor | [`docs/mcp/cursor.md`](docs/mcp/cursor.md) |
139
+ | DeepSeek | [`docs/mcp/deepseek.md`](docs/mcp/deepseek.md) |
140
+ | Windsurf | [`docs/mcp/windsurf.md`](docs/mcp/windsurf.md) |
141
+
104
142
  ## Quick start
105
143
 
106
144
  1. Get an API key at [datasink.ing](https://datasink.ing)
File without changes
File without changes
File without changes