Metadata-Version: 2.4
Name: tuvi-mcp-server
Version: 0.6.0
Summary: A Model Context Protocol (MCP) server for Vietnamese Tu Vi horoscope calculation
Author-email: Manh Ha Nguyen <manh.ha.3218@gmail.com>
License: Apache-2.0
Project-URL: Homepage, https://github.com/nmhaaa3218/TuViMCP
Project-URL: Repository, https://github.com/nmhaaa3218/TuViMCP
Project-URL: Documentation, https://tuvimcp.readthedocs.io/en/latest/
Project-URL: Bug Tracker, https://github.com/nmhaaa3218/TuViMCP/issues
Keywords: mcp,tuvi,horoscope,astrology,vietnamese,lunar-calendar
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: NOTICE
Requires-Dist: mcp<2.0.0,>=1.27.2
Requires-Dist: pillow>=10.0.0
Provides-Extra: test
Requires-Dist: pytest>=8.0.0; extra == "test"
Provides-Extra: docs
Requires-Dist: sphinx>=7.2; extra == "docs"
Requires-Dist: furo>=2024; extra == "docs"
Requires-Dist: myst-parser>=2.0; extra == "docs"
Requires-Dist: sphinx-autodoc-typehints>=2.0; extra == "docs"
Requires-Dist: sphinx-copybutton>=0.5; extra == "docs"
Requires-Dist: linkify-it-py>=2.0; extra == "docs"
Dynamic: license-file

# TuViMCP — Vietnamese Tử Vi Library & MCP Server

[![CI](https://github.com/nmhaaa3218/TuViMCP/actions/workflows/ci.yml/badge.svg)](https://github.com/nmhaaa3218/TuViMCP/actions/workflows/ci.yml)
[![PyPI version](https://img.shields.io/pypi/v/tuvi-mcp-server)](https://pypi.org/project/tuvi-mcp-server/)
[![Documentation Status](https://readthedocs.org/projects/tuvimcp/badge/?version=latest)](https://tuvimcp.readthedocs.io/en/latest/)
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

[![TuViMCP MCP server](https://glama.ai/mcp/servers/nmhaaa3218/TuViMCP/badges/card.svg)](https://glama.ai/mcp/servers/nmhaaa3218/TuViMCP)

**[English](#english)** · **[Tiếng Việt](#tiếng-việt)** · **[Full Documentation (ReadTheDocs)](https://tuvimcp.readthedocs.io/en/latest/)**

![TuViMCP Demo](assets/demo.gif)

---

## English

**TuViMCP** is a stateless Python library and [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) server for Vietnamese **Tử Vi Đẩu Số** chart calculation (*Thiên Lương* conventions), transit analysis (*Vận Hạn*), Solar ↔ Lunar conversion, and auspicious date evaluation (*Lịch Vạn Niên*).

### Highlights

- **Full Birth Charts:** Computes *Thiên Bàn*, 12-house *Địa Bàn* (100+ stars, static house geometry, Tuần/Triệt), and **51 Cách Cục Trung Châu Phái** formations from Solar or Lunar dates.
- **Vận Hạn (Transits):** Yearly transit stars (*Lưu tinh*) plus active *Đại Hạn*, *Tiểu Hạn*, *Nguyệt Hạn*, and *Nhật Hạn* cycles.
- **Auspicious Almanac & Calendar:** *Hoàng Đạo / Hắc Đạo*, 12 *Trực*, 28 *Tú*, 24 *Tiết Khí*, travel directions, 12 auspicious hours, and strict Ho Ngọc Đức / Meeus Solar ↔ Lunar conversion.
- **Print-Ready PNG Charts:** Bundled **Roboto** Unicode fonts render crisp Vietnamese diacritics on headless/serverless environments, with optional custom `.ttf` overrides.
- **Zero External Services:** Runs 100% locally and statelessly — no API keys, no database required.

### Installation

```bash
pip install tuvi-mcp-server
```

### MCP Server Setup

Run locally over `stdio` (default for Claude Desktop & Cursor) or Streamable HTTP:

```bash
tuvi-mcp                              # stdio transport
tuvi-mcp --http --port 1850           # streamable-http transport
```

**Claude Desktop (`claude_desktop_config.json`):**

```json
{
  "mcpServers": {
    "tuvi-horoscope": {
      "command": "/path/to/.venv/bin/tuvi-mcp",
      "args": []
    }
  }
}
```

#### Available MCP Tools

| Tool | Description | Docs |
|---|---|---|
| `generate_horoscope` | Build a full Tử Vi chart (+ optional PNG image & `timezone`) | [Reference](https://tuvimcp.readthedocs.io/en/latest/tools/generate_horoscope.html) |
| `get_van_han` | Yearly *Lưu tinh* and *Đại / Tiểu / Nguyệt / Nhật Hạn* for a Lunar period | [Reference](https://tuvimcp.readthedocs.io/en/latest/tools/get_van_han.html) |
| `convert_calendar` | Solar ↔ Lunar conversion with leap-month & 29/30-day validation | [Reference](https://tuvimcp.readthedocs.io/en/latest/tools/convert_calendar.html) |
| `get_auspicious_info` | *Hoàng Đạo*, 12 *Trực*, 28 *Tú*, *Tiết Khí*, directions & hours | [Reference](https://tuvimcp.readthedocs.io/en/latest/tools/get_auspicious_info.html) |

### Python Library Quickstart

```python
from tuvi_mcp import Horoscope

h = Horoscope.from_birth(
    name="Nguyễn Văn A",
    year=1995, month=6, day=10,
    hour="14:30",      # also accepts "Mùi", 14, or 8 (branch index)
    gender="Nam",      # also accepts "male", 1, or Gender.MALE
    calendar="solar",  # or "lunar" / Calendar.LUNAR
)

chart = h.chart()                                  # Thiên Bàn + Địa Bàn + 51 Cách Cục
van_han = h.transit(year=2026, month=5, day=15)    # Đại / Tiểu / Nguyệt / Nhật Hạn
auspicious = h.auspicious(day=27, month=7, year=2026)
png_path = h.render_chart(chart, year=2026)        # PNG chart with bundled Roboto font
```

> **Note on Tradition:** Vietnamese Tử Vi spans multiple lineages. `tuvi_mcp` implements **Thiên Lương** conventions (*Số Tử Vi dưới mắt khoa học*) and should be used as an objective computational reference. See [Methodology & School Rules](https://tuvimcp.readthedocs.io/en/latest/guides/methodology.html) for full details.

### Links

- [Full Documentation](https://tuvimcp.readthedocs.io/en/latest/) · [MCP Setup Guide](https://tuvimcp.readthedocs.io/en/latest/mcp-setup.html) · [Output Schemas](https://tuvimcp.readthedocs.io/en/latest/guides/schemas.html)
- [Sample JSON Outputs & Scripts](examples/) · [Changelog](CHANGELOG.md) · [Contributing](CONTRIBUTING.md)

---

## Tiếng Việt

**TuViMCP** là thư viện Python và máy chủ [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) không trạng thái (stateless) chuyên lập lá số **Tử Vi Đẩu Số** Việt Nam (theo hệ phái *Thiên Lương*), phân tích *Vận Hạn*, chuyển đổi Dương lịch ↔ Âm lịch và tra cứu ngày giờ *Hoàng Đạo*.

### Tính năng nổi bật

- **Lập lá số Tử Vi đầy đủ:** Tính toán *Thiên Bàn*, 12 cung *Địa Bàn* (hơn 100 sao, quan hệ tam hợp/xung chiếu/nhị hợp/giáp cung, Tuần/Triệt) và nhận diện tự động **51 Cách Cục Trung Châu Phái**.
- **Xem Vận Hạn:** Tính bộ sao lưu niên (*Lưu tinh*) cùng các cung kích hoạt *Đại Hạn*, *Tiểu Hạn*, *Nguyệt Hạn* và *Nhật Hạn*.
- **Lịch Vạn Niên & Chuyển đổi lịch:** Đánh giá *Ngày/Giờ Hoàng Đạo*, 12 *Trực*, 28 *Tú*, 24 *Tiết Khí*, hướng xuất hành và chuyển đổi Dương ↔ Âm lịch chính xác theo thuật toán Hồ Ngọc Đức / Meeus.
- **Xuất ảnh lá số PNG sắc nét:** Tích hợp sẵn font **Roboto** Unicode hiển thị chuẩn dấu tiếng Việt trên mọi môi trường (kể cả server Linux không có font hệ thống), hỗ trợ truyền font `.ttf` tùy chọn.
- **Chạy hoàn toàn cục bộ:** Không cần API key, không cần cơ sở dữ liệu.

### Cài đặt

```bash
pip install tuvi-mcp-server
```

### Khởi chạy Máy chủ MCP

```bash
tuvi-mcp                              # Chế độ stdio (Claude Desktop, Cursor)
tuvi-mcp --http --port 1850           # Chế độ Streamable HTTP
```

**Cấu hình Claude Desktop (`claude_desktop_config.json`):**

```json
{
  "mcpServers": {
    "tuvi-horoscope": {
      "command": "/path/to/.venv/bin/tuvi-mcp",
      "args": []
    }
  }
}
```

#### Danh sách công cụ MCP

| Công cụ | Chức năng | Tài liệu |
|---|---|---|
| `generate_horoscope` | Lập lá số Tử Vi đầy đủ (tùy chọn xuất ảnh PNG & `timezone`) | [Chi tiết](https://tuvimcp.readthedocs.io/en/latest/tools/generate_horoscope.html) |
| `get_van_han` | Tính *Lưu tinh* và *Đại / Tiểu / Nguyệt / Nhật Hạn* theo ngày Âm lịch | [Chi tiết](https://tuvimcp.readthedocs.io/en/latest/tools/get_van_han.html) |
| `convert_calendar` | Chuyển đổi Dương lịch ↔ Âm lịch (kiểm tra tháng nhuận & 29/30 ngày) | [Chi tiết](https://tuvimcp.readthedocs.io/en/latest/tools/convert_calendar.html) |
| `get_auspicious_info` | Xem ngày giờ *Hoàng Đạo*, 12 *Trực*, 28 *Tú*, *Tiết Khí* & hướng xuất hành | [Chi tiết](https://tuvimcp.readthedocs.io/en/latest/tools/get_auspicious_info.html) |

### Dùng nhanh bằng Python

```python
from tuvi_mcp import Horoscope

h = Horoscope.from_birth(
    name="Nguyễn Văn A",
    year=1995, month=6, day=10,
    hour="14:30",      # chấp nhận "Mùi", 14, hoặc 8 (chỉ số Địa Chi)
    gender="Nam",      # chấp nhận "male", 1, hoặc Gender.MALE
    calendar="solar",  # hoặc "lunar" / Calendar.LUNAR
)

chart = h.chart()                                  # Thiên Bàn + Địa Bàn + 51 Cách Cục
van_han = h.transit(year=2026, month=5, day=15)    # Đại / Tiểu / Nguyệt / Nhật Hạn
auspicious = h.auspicious(day=27, month=7, year=2026)
png_path = h.render_chart(chart, year=2026)        # Xuất ảnh PNG bằng font Roboto tích hợp sẵn
```

> **Lưu ý về học phái:** Tử Vi Việt Nam có nhiều trường phái khác nhau. `tuvi_mcp` áp dụng quy chuẩn **Thiên Lương** (*Số Tử Vi dưới mắt khoa học*) để làm công cụ tính toán tham khảo khách quan. Xem chi tiết tại [Methodology & School Rules](https://tuvimcp.readthedocs.io/en/latest/guides/methodology.html).

### Tài liệu & Liên kết

- [Tài liệu đầy đủ (ReadTheDocs)](https://tuvimcp.readthedocs.io/en/latest/) · [Ví dụ JSON & mã nguồn](examples/) · [Lịch sử thay đổi](CHANGELOG.md) · [Hướng dẫn đóng góp](CONTRIBUTING.md)

---

## License

Licensed under the **Apache License 2.0** — see [LICENSE](LICENSE) and [NOTICE](NOTICE) for details. Derivative works and distributions must preserve author attribution as specified in [NOTICE](NOTICE).
