vn-value-screener 0.1.0__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.
- vn_value_screener-0.1.0/.github/workflows/ci.yml +24 -0
- vn_value_screener-0.1.0/.github/workflows/release.yml +63 -0
- vn_value_screener-0.1.0/.gitignore +11 -0
- vn_value_screener-0.1.0/CLAUDE.md +62 -0
- vn_value_screener-0.1.0/LICENSE +21 -0
- vn_value_screener-0.1.0/PKG-INFO +143 -0
- vn_value_screener-0.1.0/README.md +127 -0
- vn_value_screener-0.1.0/pyproject.toml +39 -0
- vn_value_screener-0.1.0/scripts/check_versions.py +45 -0
- vn_value_screener-0.1.0/scripts/sync-engine.sh +28 -0
- vn_value_screener-0.1.0/server.json +35 -0
- vn_value_screener-0.1.0/src/vn_value_screener/__init__.py +4 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/__init__.py +11 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/config.py +102 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/data.py +474 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/fisher.py +89 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/graham.py +228 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/quality.py +139 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/report.py +295 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/store.py +577 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/vndirect.py +169 -0
- vn_value_screener-0.1.0/src/vn_value_screener/engine/vps.py +222 -0
- vn_value_screener-0.1.0/src/vn_value_screener/server.py +152 -0
- vn_value_screener-0.1.0/src/vn_value_screener/service.py +356 -0
- vn_value_screener-0.1.0/tests/__init__.py +0 -0
- vn_value_screener-0.1.0/tests/test_server.py +87 -0
- vn_value_screener-0.1.0/tests/test_service.py +164 -0
- vn_value_screener-0.1.0/tests/world.py +70 -0
- vn_value_screener-0.1.0/uv.lock +881 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_call:
|
|
8
|
+
|
|
9
|
+
permissions:
|
|
10
|
+
contents: read
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
test:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
matrix:
|
|
17
|
+
python: ["3.11", "3.12", "3.13"]
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
20
|
+
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
21
|
+
- run: uv sync --python ${{ matrix.python }}
|
|
22
|
+
- run: uv run ruff check .
|
|
23
|
+
- run: uv run pytest -q
|
|
24
|
+
- run: uv run python scripts/check_versions.py
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Push a tag vX.Y.Z → tests → PyPI (trusted publishing, no token) → MCP Registry (GitHub OIDC, no token).
|
|
2
|
+
#
|
|
3
|
+
# One-time setup by the owner, before the first tag:
|
|
4
|
+
# 1. pypi.org → Your projects → Publishing → add a "pending publisher": project vn-value-screener,
|
|
5
|
+
# owner Nghiauet, repository vn-value-screener, workflow release.yml, environment pypi.
|
|
6
|
+
# 2. GitHub repo → Settings → Environments → create "pypi" (optionally: require a reviewer).
|
|
7
|
+
name: release
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
tags: ["v*"]
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
env:
|
|
17
|
+
MCP_PUBLISHER_VERSION: "1.8.16"
|
|
18
|
+
MCP_PUBLISHER_SHA256: "6e2f799550cf843c6fd3350498d56cc49be3dc0af1e6237eb0e6435c7a9d5c05" # linux_amd64 tarball
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
test:
|
|
22
|
+
uses: ./.github/workflows/ci.yml
|
|
23
|
+
|
|
24
|
+
publish:
|
|
25
|
+
needs: test
|
|
26
|
+
runs-on: ubuntu-latest
|
|
27
|
+
environment: pypi
|
|
28
|
+
permissions:
|
|
29
|
+
contents: read
|
|
30
|
+
id-token: write # PyPI trusted publishing and the registry's GitHub OIDC login
|
|
31
|
+
steps:
|
|
32
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
33
|
+
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
|
|
34
|
+
|
|
35
|
+
- name: Tag, pyproject, package and server.json agree
|
|
36
|
+
run: uv run python scripts/check_versions.py "${GITHUB_REF_NAME}"
|
|
37
|
+
|
|
38
|
+
- run: uv build
|
|
39
|
+
|
|
40
|
+
- name: Publish to PyPI
|
|
41
|
+
uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # v1.14.3
|
|
42
|
+
|
|
43
|
+
- name: Wait until PyPI serves this version
|
|
44
|
+
run: |
|
|
45
|
+
version="${GITHUB_REF_NAME#v}"
|
|
46
|
+
for _ in $(seq 1 30); do
|
|
47
|
+
if curl -fsS "https://pypi.org/pypi/vn-value-screener/${version}/json" > /dev/null; then exit 0; fi
|
|
48
|
+
sleep 10
|
|
49
|
+
done
|
|
50
|
+
echo "PyPI still doesn't list vn-value-screener ${version}" >&2
|
|
51
|
+
exit 1
|
|
52
|
+
|
|
53
|
+
- name: Install mcp-publisher (pinned, checksum-verified)
|
|
54
|
+
run: |
|
|
55
|
+
url="https://github.com/modelcontextprotocol/registry/releases/download/v${MCP_PUBLISHER_VERSION}/mcp-publisher_linux_amd64.tar.gz"
|
|
56
|
+
curl -fsSL -o mcp-publisher.tar.gz "$url"
|
|
57
|
+
echo "${MCP_PUBLISHER_SHA256} mcp-publisher.tar.gz" | sha256sum -c -
|
|
58
|
+
tar -xzf mcp-publisher.tar.gz mcp-publisher
|
|
59
|
+
|
|
60
|
+
- name: Publish to the MCP Registry
|
|
61
|
+
run: |
|
|
62
|
+
./mcp-publisher login github-oidc
|
|
63
|
+
./mcp-publisher publish
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# vn-value-screener
|
|
2
|
+
|
|
3
|
+
A public MCP server (stdio, PyPI package) that runs Graham/Fisher screens over Vietnamese listed companies. Users
|
|
4
|
+
install it with `uvx vn-value-screener`. Machine-specific notes, if any, are in `CLAUDE.local.md` (untracked).
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
uv sync
|
|
10
|
+
uv run pytest -q # synthetic VNDirect (tests/world.py), no network; includes a real stdio run
|
|
11
|
+
uv run ruff check .
|
|
12
|
+
uv run python scripts/check_versions.py [vX.Y.Z] # pyproject, __init__, server.json (+ tag) agree; README has mcp-name
|
|
13
|
+
uv build # wheel + sdist in dist/
|
|
14
|
+
uv run vn-value-screener --data-dir /tmp/x [--offline] # the server on stdio (an MCP client starts it)
|
|
15
|
+
bash scripts/sync-engine.sh <stock-analyzer checkout> [rev] # re-copy the engine, committed files only
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Architecture
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
src/vn_value_screener/
|
|
22
|
+
engine/ the screening engine, copied UNCHANGED from the author's stock-analyzer (revision in engine/__init__.py)
|
|
23
|
+
service.py tool logic: Screener (store + client, analysed market reused for an hour), JSON shapes, input checks,
|
|
24
|
+
methodology() read from engine Config; sets our own User-Agent on the engine's client
|
|
25
|
+
server.py MCPServer (mcp SDK 2.x): screen_stocks, analyze_company, explain_method; all engine work on ONE worker
|
|
26
|
+
thread (sqlite connection is thread-bound); engine log lines → MCP progress notifications
|
|
27
|
+
tests/ world.py (synthetic VNDirect), test_service.py, test_server.py (in-process + stdio)
|
|
28
|
+
server.json MCP Registry metadata (schema 2025-12-11); name io.github.Nghiauet/vn-value-screener
|
|
29
|
+
.github/workflows/ci.yml, release.yml tag vX.Y.Z → tests → PyPI (trusted publishing) → MCP Registry (GitHub OIDC)
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Rules
|
|
33
|
+
|
|
34
|
+
- **Never edit `engine/` here.** Change stock-analyzer, commit there, then `sync-engine.sh` and re-test. After a sync,
|
|
35
|
+
run one live screen and compare its universe line and list counts with stock-analyzer's report of the same day
|
|
36
|
+
(2026-11-24: 1519 → 277 → 222; lists 34/30/26/6/18/19, identical).
|
|
37
|
+
- **Nothing may print to stdout**: it is the MCP channel. The engine logs through a callback; keep it that way.
|
|
38
|
+
- **Politeness is not negotiable:** honest User-Agent (`service.USER_AGENT`), ≥ 1 s between requests (engine), every
|
|
39
|
+
response stored. No proxies, no User-Agent rotation, no evasion. If VNDirect refuses, slow down or stop.
|
|
40
|
+
- **Not advice:** every tool result carries the disclaimer. Tool descriptions and the server instructions tell the
|
|
41
|
+
calling model not to present results as buy/sell calls. Keep it so.
|
|
42
|
+
- Tools stay read-only (`read_only_hint=True`, `destructive_hint=False`). A tool that writes anything beyond the
|
|
43
|
+
local cache needs a design review first.
|
|
44
|
+
- New tool inputs: validate type, range and empty values (pydantic `Field` in server.py and checks in service.py),
|
|
45
|
+
and add a bad-input test.
|
|
46
|
+
- Errors users can act on → `ScreenerError` (becomes an MCP tool error with that text). Data-source failures are
|
|
47
|
+
caught as `service.SOURCE_ERRORS`.
|
|
48
|
+
|
|
49
|
+
## Release
|
|
50
|
+
|
|
51
|
+
1. Bump the version in `pyproject.toml`, `src/vn_value_screener/__init__.py` and `server.json` (both places), then
|
|
52
|
+
run `check_versions.py`.
|
|
53
|
+
2. Commit, then tag `vX.Y.Z` and push the tag. `release.yml` does the rest.
|
|
54
|
+
3. Actions are pinned to full commit hashes, with the version in a comment. setup-uv publishes no floating major
|
|
55
|
+
tag (`@v10` failed on 2026-11-24). Bump by resolving the new tag: `gh api repos/<owner>/<action>/git/ref/tags/<tag>`.
|
|
56
|
+
4. To bump `mcp-publisher`: change `MCP_PUBLISHER_VERSION` and `MCP_PUBLISHER_SHA256` in `release.yml`. The sha256
|
|
57
|
+
is the `mcp-publisher_linux_amd64.tar.gz` line in that release's `registry_<v>_checksums.txt`.
|
|
58
|
+
|
|
59
|
+
The MCP Registry is still in preview (data resets possible). It stores only metadata; the code is the PyPI package.
|
|
60
|
+
To be listed it needs the `mcp-name: io.github.Nghiauet/vn-value-screener` line in README.md, which becomes the PyPI
|
|
61
|
+
description. Glama picks the package up from the registry. Claude's Connectors Directory needs a remote HTTP server,
|
|
62
|
+
so it is not in scope.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nghiauet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: vn-value-screener
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server: Graham- and Fisher-style screens of Vietnamese listed companies (HOSE, HNX, UPCOM)
|
|
5
|
+
Project-URL: Repository, https://github.com/Nghiauet/vn-value-screener
|
|
6
|
+
Author: Nghiauet
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: fisher,graham,mcp,screener,stocks,value-investing,vietnam
|
|
10
|
+
Classifier: Intended Audience :: Education
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Topic :: Office/Business :: Financial :: Investment
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Requires-Dist: mcp<3,>=2.3
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# vn-value-screener
|
|
18
|
+
|
|
19
|
+
An [MCP](https://modelcontextprotocol.io) server that screens every company listed in Vietnam (HOSE, HNX, UPCOM)
|
|
20
|
+
with Benjamin Graham's tests and the measurable parts of Philip Fisher's 15 points. Ask your AI assistant
|
|
21
|
+
"which Vietnamese companies pass Graham's defensive test?" or "walk me through FPT's numbers", and it calls these
|
|
22
|
+
tools instead of guessing.
|
|
23
|
+
|
|
24
|
+
<!-- mcp-name: io.github.Nghiauet/vn-value-screener -->
|
|
25
|
+
|
|
26
|
+
> **Not investment advice.** A screen finds companies worth reading about. It cannot tell you what to buy or sell,
|
|
27
|
+
> and the figures can be wrong. Check them against the audited annual report.
|
|
28
|
+
|
|
29
|
+
## Tools
|
|
30
|
+
|
|
31
|
+
| Tool | What it returns |
|
|
32
|
+
| --- | --- |
|
|
33
|
+
| `screen_stocks(list_name="all", limit=10)` | Six lists over every liquid non-financial company. **defensive**: Graham's defensive investor, ≥ 6 of 7 tests. **qarp**: quality at a reasonable price. **enterprising**: Graham's enterprising investor, 6 of 6. **net_net**: price below ⅔ of net current assets. **leaders**: quality ≥ 7 of 8, at any price. **fisher**: Fisher growth candidates. Each list gives its rule, how many companies pass, and the top `limit` with price, P/E, P/B, Graham number, scores and growth. |
|
|
34
|
+
| `analyze_company(ticker)` | One company's worksheet: valuation, every Graham and quality test with the numbers behind it, ten years of figures, the last eight quarters, warnings about the data, and Fisher's questions that numbers can't answer. Works for illiquid tickers too. |
|
|
35
|
+
| `explain_method()` | Every test and threshold, how each was adapted to Vietnam, and the method's known blind spots. Needs no network. |
|
|
36
|
+
|
|
37
|
+
All three are read-only. Prices are in VND, `*_bn` fields in billions of VND, and ratios are fractions (0.15 = 15%).
|
|
38
|
+
Banks, insurers, brokers and lenders are left out: Graham's tests don't fit their balance sheets.
|
|
39
|
+
|
|
40
|
+
## Install
|
|
41
|
+
|
|
42
|
+
You need [uv](https://docs.astral.sh/uv/). `uvx` downloads and runs the package; nothing else to set up.
|
|
43
|
+
|
|
44
|
+
**Claude Code**
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
claude mcp add vn-value-screener -- uvx vn-value-screener
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Claude Desktop, Cursor, and other clients** (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
|
|
51
|
+
|
|
52
|
+
```json
|
|
53
|
+
{
|
|
54
|
+
"mcpServers": {
|
|
55
|
+
"vn-value-screener": {
|
|
56
|
+
"command": "uvx",
|
|
57
|
+
"args": ["vn-value-screener"]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
If the client can't find `uvx`, put its full path in `command`. To find it, run `which uvx` on macOS/Linux or
|
|
64
|
+
`where uvx` on Windows.
|
|
65
|
+
|
|
66
|
+
### First call of the day: about a minute
|
|
67
|
+
|
|
68
|
+
The first call downloads what the screens need (about 55 requests to VNDirect, one per second). Later calls take
|
|
69
|
+
seconds. Every response is stored as it arrives, so if your client gives up waiting, just ask again: the next call
|
|
70
|
+
picks up where the last one stopped.
|
|
71
|
+
|
|
72
|
+
Options, as arguments or environment variables:
|
|
73
|
+
|
|
74
|
+
| Argument | Environment variable | Default |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `--data-dir PATH` | `VN_VALUE_SCREENER_DATA_DIR` | `$XDG_CACHE_HOME/vn-value-screener`, else `~/.cache/vn-value-screener` |
|
|
77
|
+
| `--offline` | `VN_VALUE_SCREENER_OFFLINE=1` | off: answer only from stored data, never call the API |
|
|
78
|
+
|
|
79
|
+
The store is a SQLite file. It holds a few tens of MB after a day's screen and grows as you look at more companies.
|
|
80
|
+
|
|
81
|
+
## Data source
|
|
82
|
+
|
|
83
|
+
Everything comes from VNDirect's finfo API (`api-finfo.vndirect.com.vn`): the public, undocumented API behind
|
|
84
|
+
VNDirect's website. This project is **not affiliated with VNDirect**, and the API may change or stop without notice.
|
|
85
|
+
|
|
86
|
+
The client stays polite on purpose:
|
|
87
|
+
- It names itself in its User-Agent (`vn-value-screener/<version> (+repository URL)`).
|
|
88
|
+
- It waits at least one second between requests and backs off on errors.
|
|
89
|
+
- It stores every response, so the same question isn't asked twice in a day.
|
|
90
|
+
|
|
91
|
+
If VNDirect objects, this project will slow down or stop. It will never disguise its traffic.
|
|
92
|
+
|
|
93
|
+
## Method, briefly
|
|
94
|
+
|
|
95
|
+
`explain_method` has the full list. In short:
|
|
96
|
+
|
|
97
|
+
- **Graham defensive** (*The Intelligent Investor*, ch. 14), adapted to Vietnam:
|
|
98
|
+
- sales ≥ 1,000 bn VND;
|
|
99
|
+
- current ratio ≥ 2;
|
|
100
|
+
- profit in each of 10 years;
|
|
101
|
+
- cash dividends in each of 10 years (Graham asked 20, but HOSE opened in 2000);
|
|
102
|
+
- earnings up a third;
|
|
103
|
+
- P/E ≤ 15 on 3-year earnings;
|
|
104
|
+
- P/B ≤ 1.5, or P/E × P/B ≤ 22.5.
|
|
105
|
+
- **Graham enterprising** (ch. 15) and **net-nets** (price below ⅔ of net current assets).
|
|
106
|
+
- **Eight quality signals** for the parts of Fisher's points that numbers can show:
|
|
107
|
+
- sales growth and steadiness;
|
|
108
|
+
- operating margin above the median, and margins holding;
|
|
109
|
+
- ROE ≥ 15%;
|
|
110
|
+
- cash conversion;
|
|
111
|
+
- little dilution;
|
|
112
|
+
- conservative debt.
|
|
113
|
+
- EPS for every year uses **today's share count**. Vietnamese companies pay many stock dividends, and reported EPS
|
|
114
|
+
hides that growth.
|
|
115
|
+
|
|
116
|
+
Known blind spots:
|
|
117
|
+
- Shares held by subsidiaries and preferred shares count as ordinary shares.
|
|
118
|
+
- Profit is struck before the bonus-and-welfare fund and staff share schemes.
|
|
119
|
+
- One-off gains stay inside profit.
|
|
120
|
+
- Cyclical companies pass the growth tests at the top of their cycle.
|
|
121
|
+
|
|
122
|
+
Read the company's filings before trusting any result.
|
|
123
|
+
|
|
124
|
+
## Development
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
uv sync
|
|
128
|
+
uv run pytest -q # synthetic data, no network
|
|
129
|
+
uv run ruff check .
|
|
130
|
+
uv run vn-value-screener --help
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
`src/vn_value_screener/engine/` is the screening engine. It is copied unchanged from the author's research tool, and
|
|
134
|
+
`scripts/sync-engine.sh` refreshes it. The MCP layer is `service.py` (tool logic, JSON shapes) and `server.py` (the MCP
|
|
135
|
+
server).
|
|
136
|
+
|
|
137
|
+
Releases: push a tag `vX.Y.Z` that matches the version in `pyproject.toml`, `src/vn_value_screener/__init__.py` and
|
|
138
|
+
`server.json`. The release workflow then tests the code, publishes it to PyPI (trusted publishing), and publishes
|
|
139
|
+
`server.json` to the [MCP Registry](https://registry.modelcontextprotocol.io).
|
|
140
|
+
|
|
141
|
+
## License
|
|
142
|
+
|
|
143
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# vn-value-screener
|
|
2
|
+
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server that screens every company listed in Vietnam (HOSE, HNX, UPCOM)
|
|
4
|
+
with Benjamin Graham's tests and the measurable parts of Philip Fisher's 15 points. Ask your AI assistant
|
|
5
|
+
"which Vietnamese companies pass Graham's defensive test?" or "walk me through FPT's numbers", and it calls these
|
|
6
|
+
tools instead of guessing.
|
|
7
|
+
|
|
8
|
+
<!-- mcp-name: io.github.Nghiauet/vn-value-screener -->
|
|
9
|
+
|
|
10
|
+
> **Not investment advice.** A screen finds companies worth reading about. It cannot tell you what to buy or sell,
|
|
11
|
+
> and the figures can be wrong. Check them against the audited annual report.
|
|
12
|
+
|
|
13
|
+
## Tools
|
|
14
|
+
|
|
15
|
+
| Tool | What it returns |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| `screen_stocks(list_name="all", limit=10)` | Six lists over every liquid non-financial company. **defensive**: Graham's defensive investor, ≥ 6 of 7 tests. **qarp**: quality at a reasonable price. **enterprising**: Graham's enterprising investor, 6 of 6. **net_net**: price below ⅔ of net current assets. **leaders**: quality ≥ 7 of 8, at any price. **fisher**: Fisher growth candidates. Each list gives its rule, how many companies pass, and the top `limit` with price, P/E, P/B, Graham number, scores and growth. |
|
|
18
|
+
| `analyze_company(ticker)` | One company's worksheet: valuation, every Graham and quality test with the numbers behind it, ten years of figures, the last eight quarters, warnings about the data, and Fisher's questions that numbers can't answer. Works for illiquid tickers too. |
|
|
19
|
+
| `explain_method()` | Every test and threshold, how each was adapted to Vietnam, and the method's known blind spots. Needs no network. |
|
|
20
|
+
|
|
21
|
+
All three are read-only. Prices are in VND, `*_bn` fields in billions of VND, and ratios are fractions (0.15 = 15%).
|
|
22
|
+
Banks, insurers, brokers and lenders are left out: Graham's tests don't fit their balance sheets.
|
|
23
|
+
|
|
24
|
+
## Install
|
|
25
|
+
|
|
26
|
+
You need [uv](https://docs.astral.sh/uv/). `uvx` downloads and runs the package; nothing else to set up.
|
|
27
|
+
|
|
28
|
+
**Claude Code**
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
claude mcp add vn-value-screener -- uvx vn-value-screener
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Claude Desktop, Cursor, and other clients** (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"mcpServers": {
|
|
39
|
+
"vn-value-screener": {
|
|
40
|
+
"command": "uvx",
|
|
41
|
+
"args": ["vn-value-screener"]
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the client can't find `uvx`, put its full path in `command`. To find it, run `which uvx` on macOS/Linux or
|
|
48
|
+
`where uvx` on Windows.
|
|
49
|
+
|
|
50
|
+
### First call of the day: about a minute
|
|
51
|
+
|
|
52
|
+
The first call downloads what the screens need (about 55 requests to VNDirect, one per second). Later calls take
|
|
53
|
+
seconds. Every response is stored as it arrives, so if your client gives up waiting, just ask again: the next call
|
|
54
|
+
picks up where the last one stopped.
|
|
55
|
+
|
|
56
|
+
Options, as arguments or environment variables:
|
|
57
|
+
|
|
58
|
+
| Argument | Environment variable | Default |
|
|
59
|
+
| --- | --- | --- |
|
|
60
|
+
| `--data-dir PATH` | `VN_VALUE_SCREENER_DATA_DIR` | `$XDG_CACHE_HOME/vn-value-screener`, else `~/.cache/vn-value-screener` |
|
|
61
|
+
| `--offline` | `VN_VALUE_SCREENER_OFFLINE=1` | off: answer only from stored data, never call the API |
|
|
62
|
+
|
|
63
|
+
The store is a SQLite file. It holds a few tens of MB after a day's screen and grows as you look at more companies.
|
|
64
|
+
|
|
65
|
+
## Data source
|
|
66
|
+
|
|
67
|
+
Everything comes from VNDirect's finfo API (`api-finfo.vndirect.com.vn`): the public, undocumented API behind
|
|
68
|
+
VNDirect's website. This project is **not affiliated with VNDirect**, and the API may change or stop without notice.
|
|
69
|
+
|
|
70
|
+
The client stays polite on purpose:
|
|
71
|
+
- It names itself in its User-Agent (`vn-value-screener/<version> (+repository URL)`).
|
|
72
|
+
- It waits at least one second between requests and backs off on errors.
|
|
73
|
+
- It stores every response, so the same question isn't asked twice in a day.
|
|
74
|
+
|
|
75
|
+
If VNDirect objects, this project will slow down or stop. It will never disguise its traffic.
|
|
76
|
+
|
|
77
|
+
## Method, briefly
|
|
78
|
+
|
|
79
|
+
`explain_method` has the full list. In short:
|
|
80
|
+
|
|
81
|
+
- **Graham defensive** (*The Intelligent Investor*, ch. 14), adapted to Vietnam:
|
|
82
|
+
- sales ≥ 1,000 bn VND;
|
|
83
|
+
- current ratio ≥ 2;
|
|
84
|
+
- profit in each of 10 years;
|
|
85
|
+
- cash dividends in each of 10 years (Graham asked 20, but HOSE opened in 2000);
|
|
86
|
+
- earnings up a third;
|
|
87
|
+
- P/E ≤ 15 on 3-year earnings;
|
|
88
|
+
- P/B ≤ 1.5, or P/E × P/B ≤ 22.5.
|
|
89
|
+
- **Graham enterprising** (ch. 15) and **net-nets** (price below ⅔ of net current assets).
|
|
90
|
+
- **Eight quality signals** for the parts of Fisher's points that numbers can show:
|
|
91
|
+
- sales growth and steadiness;
|
|
92
|
+
- operating margin above the median, and margins holding;
|
|
93
|
+
- ROE ≥ 15%;
|
|
94
|
+
- cash conversion;
|
|
95
|
+
- little dilution;
|
|
96
|
+
- conservative debt.
|
|
97
|
+
- EPS for every year uses **today's share count**. Vietnamese companies pay many stock dividends, and reported EPS
|
|
98
|
+
hides that growth.
|
|
99
|
+
|
|
100
|
+
Known blind spots:
|
|
101
|
+
- Shares held by subsidiaries and preferred shares count as ordinary shares.
|
|
102
|
+
- Profit is struck before the bonus-and-welfare fund and staff share schemes.
|
|
103
|
+
- One-off gains stay inside profit.
|
|
104
|
+
- Cyclical companies pass the growth tests at the top of their cycle.
|
|
105
|
+
|
|
106
|
+
Read the company's filings before trusting any result.
|
|
107
|
+
|
|
108
|
+
## Development
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv sync
|
|
112
|
+
uv run pytest -q # synthetic data, no network
|
|
113
|
+
uv run ruff check .
|
|
114
|
+
uv run vn-value-screener --help
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`src/vn_value_screener/engine/` is the screening engine. It is copied unchanged from the author's research tool, and
|
|
118
|
+
`scripts/sync-engine.sh` refreshes it. The MCP layer is `service.py` (tool logic, JSON shapes) and `server.py` (the MCP
|
|
119
|
+
server).
|
|
120
|
+
|
|
121
|
+
Releases: push a tag `vX.Y.Z` that matches the version in `pyproject.toml`, `src/vn_value_screener/__init__.py` and
|
|
122
|
+
`server.json`. The release workflow then tests the code, publishes it to PyPI (trusted publishing), and publishes
|
|
123
|
+
`server.json` to the [MCP Registry](https://registry.modelcontextprotocol.io).
|
|
124
|
+
|
|
125
|
+
## License
|
|
126
|
+
|
|
127
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vn-value-screener"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "MCP server: Graham- and Fisher-style screens of Vietnamese listed companies (HOSE, HNX, UPCOM)"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Nghiauet" }]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
dependencies = ["mcp>=2.3,<3"]
|
|
11
|
+
keywords = ["mcp", "vietnam", "stocks", "value-investing", "graham", "fisher", "screener"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Topic :: Office/Business :: Financial :: Investment",
|
|
15
|
+
"Intended Audience :: Education",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.urls]
|
|
19
|
+
Repository = "https://github.com/Nghiauet/vn-value-screener"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
vn-value-screener = "vn_value_screener.server:main"
|
|
23
|
+
|
|
24
|
+
[dependency-groups]
|
|
25
|
+
dev = ["pytest>=8", "ruff>=0.6"]
|
|
26
|
+
|
|
27
|
+
[build-system]
|
|
28
|
+
requires = ["hatchling>=1.27"]
|
|
29
|
+
build-backend = "hatchling.build"
|
|
30
|
+
|
|
31
|
+
[tool.hatch.build.targets.wheel]
|
|
32
|
+
packages = ["src/vn_value_screener"]
|
|
33
|
+
|
|
34
|
+
[tool.ruff]
|
|
35
|
+
line-length = 110
|
|
36
|
+
extend-exclude = ["src/vn_value_screener/engine"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Exit 1 unless pyproject.toml, the package, server.json (and its PyPI package), and the tag, if given, agree.
|
|
2
|
+
|
|
3
|
+
python scripts/check_versions.py [vX.Y.Z]
|
|
4
|
+
"""
|
|
5
|
+
import json
|
|
6
|
+
import re
|
|
7
|
+
import sys
|
|
8
|
+
import tomllib
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def versions() -> dict[str, str]:
|
|
15
|
+
pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text())
|
|
16
|
+
init = (ROOT / "src" / "vn_value_screener" / "__init__.py").read_text()
|
|
17
|
+
server = json.loads((ROOT / "server.json").read_text())
|
|
18
|
+
found = {
|
|
19
|
+
"pyproject.toml": pyproject["project"]["version"],
|
|
20
|
+
"__init__.py": re.search(r'__version__ = "([^"]+)"', init).group(1),
|
|
21
|
+
"server.json": server["version"],
|
|
22
|
+
}
|
|
23
|
+
for i, package in enumerate(server["packages"]):
|
|
24
|
+
found[f"server.json packages[{i}]"] = package["version"]
|
|
25
|
+
if package["identifier"] != pyproject["project"]["name"]:
|
|
26
|
+
sys.exit(f"server.json packages[{i}] is {package['identifier']!r}, not {pyproject['project']['name']!r}")
|
|
27
|
+
readme = (ROOT / "README.md").read_text()
|
|
28
|
+
if f"mcp-name: {server['name']} " not in readme and f"mcp-name: {server['name']}\n" not in readme:
|
|
29
|
+
sys.exit(f"README.md lacks 'mcp-name: {server['name']}' (the registry's PyPI ownership check)")
|
|
30
|
+
return found
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def main() -> int:
|
|
34
|
+
found = versions()
|
|
35
|
+
if len(sys.argv) > 1:
|
|
36
|
+
found["tag"] = sys.argv[1].removeprefix("refs/tags/").removeprefix("v")
|
|
37
|
+
if len(set(found.values())) != 1:
|
|
38
|
+
print("versions disagree: " + ", ".join(f"{k} {v}" for k, v in found.items()), file=sys.stderr)
|
|
39
|
+
return 1
|
|
40
|
+
print(f"version {next(iter(found.values()))} everywhere ({', '.join(found)})")
|
|
41
|
+
return 0
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
sys.exit(main())
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Re-copy the screening engine from a stock-analyzer checkout, unchanged, at a committed revision.
|
|
3
|
+
#
|
|
4
|
+
# bash scripts/sync-engine.sh <path to stock-analyzer checkout> [revision, default HEAD]
|
|
5
|
+
#
|
|
6
|
+
# Copies only committed files (git show), so uncommitted edits upstream never leak in. Then run the tests, and
|
|
7
|
+
# compare a live screen with upstream's report for the same day before releasing.
|
|
8
|
+
set -euo pipefail
|
|
9
|
+
|
|
10
|
+
src=${1:?usage: sync-engine.sh <stock-analyzer checkout> [revision]}
|
|
11
|
+
rev=$(git -C "$src" rev-parse "${2:-HEAD}")
|
|
12
|
+
dest=$(cd "$(dirname "$0")/.." && pwd)/src/vn_value_screener/engine
|
|
13
|
+
files=(config store vndirect vps data graham quality fisher report)
|
|
14
|
+
|
|
15
|
+
for f in "${files[@]}"; do
|
|
16
|
+
git -C "$src" show "$rev:src/stock_analyzer/$f.py" > "$dest/$f.py"
|
|
17
|
+
done
|
|
18
|
+
|
|
19
|
+
# Imports between engine files must stay inside the copied set.
|
|
20
|
+
if grep -hoE '^from \.[a-z_]+' "$dest"/*.py | sort -u | grep -vE "^from \.($(IFS='|'; echo "${files[*]}"))$"; then
|
|
21
|
+
echo "error: the engine now imports a module that isn't copied; add it to files=(...)" >&2
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
sed -i -E "s/^Source revision: [0-9a-f]+$/Source revision: $rev/; s/^SOURCE_REVISION = \"[0-9a-f]+\"$/SOURCE_REVISION = \"$rev\"/" \
|
|
26
|
+
"$dest/__init__.py"
|
|
27
|
+
echo "engine copied from $rev"
|
|
28
|
+
git -C "$dest" status --short -- . || true
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.Nghiauet/vn-value-screener",
|
|
4
|
+
"title": "Vietnam Value Screener",
|
|
5
|
+
"description": "Graham and Fisher screens of Vietnamese listed stocks (HOSE, HNX, UPCOM) from public data",
|
|
6
|
+
"repository": {
|
|
7
|
+
"url": "https://github.com/Nghiauet/vn-value-screener",
|
|
8
|
+
"source": "github"
|
|
9
|
+
},
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"packages": [
|
|
12
|
+
{
|
|
13
|
+
"registryType": "pypi",
|
|
14
|
+
"identifier": "vn-value-screener",
|
|
15
|
+
"version": "0.1.0",
|
|
16
|
+
"transport": {
|
|
17
|
+
"type": "stdio"
|
|
18
|
+
},
|
|
19
|
+
"environmentVariables": [
|
|
20
|
+
{
|
|
21
|
+
"name": "VN_VALUE_SCREENER_DATA_DIR",
|
|
22
|
+
"description": "Folder for the downloaded data (default: ~/.cache/vn-value-screener)",
|
|
23
|
+
"isRequired": false,
|
|
24
|
+
"isSecret": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "VN_VALUE_SCREENER_OFFLINE",
|
|
28
|
+
"description": "Set to 1 to answer from stored data only, never calling the API",
|
|
29
|
+
"isRequired": false,
|
|
30
|
+
"isSecret": false
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"""The screening engine, copied unchanged from the author's research tool (stock-analyzer).
|
|
2
|
+
|
|
3
|
+
Copied files: config, store, vndirect, vps, data, graham, quality, fisher, report.
|
|
4
|
+
Source revision: 1a8a9a82d9264f357ed9614f65fd25aaadd54782
|
|
5
|
+
|
|
6
|
+
Do not edit these files here: change them upstream, then re-copy with scripts/sync-engine.sh, so the two copies
|
|
7
|
+
stay identical. The MCP layer (../service.py, ../server.py) adapts them: its own User-Agent, its own cache folder,
|
|
8
|
+
JSON output instead of report files.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
SOURCE_REVISION = "1a8a9a82d9264f357ed9614f65fd25aaadd54782"
|