bangla-tools-mcp 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.
- bangla_tools_mcp-0.1.0/.gitignore +10 -0
- bangla_tools_mcp-0.1.0/LICENSE +21 -0
- bangla_tools_mcp-0.1.0/PKG-INFO +86 -0
- bangla_tools_mcp-0.1.0/README.md +68 -0
- bangla_tools_mcp-0.1.0/bangla_tools_mcp/__init__.py +3 -0
- bangla_tools_mcp-0.1.0/bangla_tools_mcp/calendar.py +49 -0
- bangla_tools_mcp-0.1.0/bangla_tools_mcp/numbers.py +78 -0
- bangla_tools_mcp-0.1.0/bangla_tools_mcp/server.py +69 -0
- bangla_tools_mcp-0.1.0/pyproject.toml +38 -0
- bangla_tools_mcp-0.1.0/tests/test_server.py +19 -0
- bangla_tools_mcp-0.1.0/tests/test_tools.py +96 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mohammed Hossain
|
|
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,86 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bangla-tools-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: MCP server with Bangla tools for AI assistants: number words, Bangladeshi Bangla date, lakh/crore commas
|
|
5
|
+
Project-URL: Homepage, https://github.com/hossainbuilds/bangla-tools-mcp
|
|
6
|
+
Project-URL: Issues, https://github.com/hossainbuilds/bangla-tools-mcp/issues
|
|
7
|
+
Project-URL: Benchmark, https://github.com/hossainbuilds/bangla-ai-eval
|
|
8
|
+
Author: Mohammed Hossain
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: bangla,bangladesh,bengali,claude,mcp,model-context-protocol
|
|
12
|
+
Classifier: Natural Language :: Bengali
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Requires-Dist: mcp<3,>=2
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
|
|
19
|
+
# bangla-tools-mcp
|
|
20
|
+
|
|
21
|
+
<!-- mcp-name: io.github.hossainbuilds/bangla-tools-mcp -->
|
|
22
|
+
|
|
23
|
+
An [MCP](https://modelcontextprotocol.io) server that gives AI assistants like Claude three small Bangla tools, for things language models often get wrong.
|
|
24
|
+
|
|
25
|
+
> AI বাংলায় যেসব জায়গায় ভুল করে, তার তিনটার জন্য ছোট টুল: সংখ্যার নাম, বাংলা তারিখ, লাখ-কোটি কমা।
|
|
26
|
+
|
|
27
|
+
## Why
|
|
28
|
+
|
|
29
|
+
We measured it with [bangla-ai-eval](https://github.com/hossainbuilds/bangla-ai-eval) ([report](https://doi.org/10.5281/zenodo.24653100), runs of 29 November 2026):
|
|
30
|
+
|
|
31
|
+
- On number words, ERNIE 5.5 Flash scored 71% and Nemotron 3 Ultra 54%. One wrote ৫৩ as *তিরান্ন*; the right word is *তিপ্পান্ন*.
|
|
32
|
+
- Nemotron placed Pohela Falgun on 13 February. In Bangladesh it has been 14 February since the 2019 calendar revision.
|
|
33
|
+
|
|
34
|
+
Both models formatted lakh/crore commas correctly in that run. The tool is here for models that don't.
|
|
35
|
+
|
|
36
|
+
## Tools
|
|
37
|
+
|
|
38
|
+
| Tool | Example |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `number_to_bangla_words` | `53` → তিপ্পান্ন, `350000` → তিন লক্ষ পঞ্চাশ হাজার |
|
|
41
|
+
| `gregorian_to_bangla_date` | `2026-12-16` → ১ পৌষ ১৪৩৩ |
|
|
42
|
+
| `format_bangla_number` | `1234567` → ১২,৩৪,৫৬৭ |
|
|
43
|
+
|
|
44
|
+
All three are local calculations: no network access and no API keys.
|
|
45
|
+
|
|
46
|
+
The date tool follows the **Bangladeshi** calendar as revised in 2019 (not the West Bengal one) and accepts dates from 14 April 2019.
|
|
47
|
+
|
|
48
|
+
## Setup
|
|
49
|
+
|
|
50
|
+
You need [uv](https://docs.astral.sh/uv/).
|
|
51
|
+
|
|
52
|
+
**Claude Code**
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
claude mcp add bangla-tools -- uvx bangla-tools-mcp
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Claude Desktop, Cursor and other clients**
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"mcpServers": {
|
|
63
|
+
"bangla-tools": {
|
|
64
|
+
"command": "uvx",
|
|
65
|
+
"args": ["bangla-tools-mcp"]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Without uv: `pip install bangla-tools-mcp`, then use `bangla-tools-mcp` as the command.
|
|
72
|
+
|
|
73
|
+
Then ask, for example: *"১৬ ডিসেম্বর ২০২৬ বাংলা কত তারিখ?"* or *"Write 1,25,00,000 in Bangla words."*
|
|
74
|
+
|
|
75
|
+
## Development
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
pip install -e . pytest
|
|
79
|
+
pytest
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Number-word and comma tests use the native-speaker-checked answers from bangla-ai-eval. The full 0–99 table was reviewed by a native speaker. Found a wrong spelling or date? [Open an issue](https://github.com/hossainbuilds/bangla-tools-mcp/issues).
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# bangla-tools-mcp
|
|
2
|
+
|
|
3
|
+
<!-- mcp-name: io.github.hossainbuilds/bangla-tools-mcp -->
|
|
4
|
+
|
|
5
|
+
An [MCP](https://modelcontextprotocol.io) server that gives AI assistants like Claude three small Bangla tools, for things language models often get wrong.
|
|
6
|
+
|
|
7
|
+
> AI বাংলায় যেসব জায়গায় ভুল করে, তার তিনটার জন্য ছোট টুল: সংখ্যার নাম, বাংলা তারিখ, লাখ-কোটি কমা।
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
We measured it with [bangla-ai-eval](https://github.com/hossainbuilds/bangla-ai-eval) ([report](https://doi.org/10.5281/zenodo.24653100), runs of 29 November 2026):
|
|
12
|
+
|
|
13
|
+
- On number words, ERNIE 5.5 Flash scored 71% and Nemotron 3 Ultra 54%. One wrote ৫৩ as *তিরান্ন*; the right word is *তিপ্পান্ন*.
|
|
14
|
+
- Nemotron placed Pohela Falgun on 13 February. In Bangladesh it has been 14 February since the 2019 calendar revision.
|
|
15
|
+
|
|
16
|
+
Both models formatted lakh/crore commas correctly in that run. The tool is here for models that don't.
|
|
17
|
+
|
|
18
|
+
## Tools
|
|
19
|
+
|
|
20
|
+
| Tool | Example |
|
|
21
|
+
| --- | --- |
|
|
22
|
+
| `number_to_bangla_words` | `53` → তিপ্পান্ন, `350000` → তিন লক্ষ পঞ্চাশ হাজার |
|
|
23
|
+
| `gregorian_to_bangla_date` | `2026-12-16` → ১ পৌষ ১৪৩৩ |
|
|
24
|
+
| `format_bangla_number` | `1234567` → ১২,৩৪,৫৬৭ |
|
|
25
|
+
|
|
26
|
+
All three are local calculations: no network access and no API keys.
|
|
27
|
+
|
|
28
|
+
The date tool follows the **Bangladeshi** calendar as revised in 2019 (not the West Bengal one) and accepts dates from 14 April 2019.
|
|
29
|
+
|
|
30
|
+
## Setup
|
|
31
|
+
|
|
32
|
+
You need [uv](https://docs.astral.sh/uv/).
|
|
33
|
+
|
|
34
|
+
**Claude Code**
|
|
35
|
+
|
|
36
|
+
```sh
|
|
37
|
+
claude mcp add bangla-tools -- uvx bangla-tools-mcp
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**Claude Desktop, Cursor and other clients**
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"mcpServers": {
|
|
45
|
+
"bangla-tools": {
|
|
46
|
+
"command": "uvx",
|
|
47
|
+
"args": ["bangla-tools-mcp"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Without uv: `pip install bangla-tools-mcp`, then use `bangla-tools-mcp` as the command.
|
|
54
|
+
|
|
55
|
+
Then ask, for example: *"১৬ ডিসেম্বর ২০২৬ বাংলা কত তারিখ?"* or *"Write 1,25,00,000 in Bangla words."*
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
pip install -e . pytest
|
|
61
|
+
pytest
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Number-word and comma tests use the native-speaker-checked answers from bangla-ai-eval. The full 0–99 table was reviewed by a native speaker. Found a wrong spelling or date? [Open an issue](https://github.com/hossainbuilds/bangla-tools-mcp/issues).
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
MIT
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Gregorian date -> Bangladeshi Bangla date (revised calendar of 2019).
|
|
2
|
+
|
|
3
|
+
This is the calendar used in Bangladesh. West Bengal follows a different one.
|
|
4
|
+
Pohela Boishakh is 14 April. Boishakh to Ashwin have 31 days, Kartik to Magh 30,
|
|
5
|
+
Falgun 29 (30 when the Gregorian year it falls in is a leap year), Chaitra 30.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import calendar as _calendar
|
|
11
|
+
import datetime as dt
|
|
12
|
+
import unicodedata
|
|
13
|
+
|
|
14
|
+
MONTHS = "বৈশাখ জ্যৈষ্ঠ আষাঢ় শ্রাবণ ভাদ্র আশ্বিন কার্তিক অগ্রহায়ণ পৌষ মাঘ ফাল্গুন চৈত্র".split()
|
|
15
|
+
SEASONS = "গ্রীষ্ম বর্ষা শরৎ হেমন্ত শীত বসন্ত".split() # two months each
|
|
16
|
+
_TO_BN = str.maketrans("0123456789", "০১২৩৪৫৬৭৮৯")
|
|
17
|
+
|
|
18
|
+
# The revision took effect with Bangla year 1426.
|
|
19
|
+
FIRST_SUPPORTED = dt.date(2019, 4, 14)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _month_lengths(start_year: int) -> list[int]:
|
|
23
|
+
falgun = 30 if _calendar.isleap(start_year + 1) else 29
|
|
24
|
+
return [31] * 6 + [30] * 4 + [falgun, 30]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def bangla_date(iso_date: str) -> dict:
|
|
28
|
+
""""2026-12-16" -> ১ পৌষ ১৪৩৩."""
|
|
29
|
+
date = dt.date.fromisoformat(iso_date.strip())
|
|
30
|
+
if date < FIRST_SUPPORTED:
|
|
31
|
+
raise ValueError(f"only dates from {FIRST_SUPPORTED.isoformat()} are supported (revised calendar)")
|
|
32
|
+
start_year = date.year if (date.month, date.day) >= (4, 14) else date.year - 1
|
|
33
|
+
day = (date - dt.date(start_year, 4, 14)).days
|
|
34
|
+
month = 0
|
|
35
|
+
for month, length in enumerate(_month_lengths(start_year)):
|
|
36
|
+
if day < length:
|
|
37
|
+
break
|
|
38
|
+
day -= length
|
|
39
|
+
year = start_year - 593
|
|
40
|
+
text = f"{str(day + 1).translate(_TO_BN)} {MONTHS[month]} {str(year).translate(_TO_BN)}"
|
|
41
|
+
nfc = lambda s: unicodedata.normalize("NFC", s) # noqa: E731
|
|
42
|
+
return {
|
|
43
|
+
"text": nfc(text),
|
|
44
|
+
"day": day + 1,
|
|
45
|
+
"month": nfc(MONTHS[month]),
|
|
46
|
+
"month_number": month + 1,
|
|
47
|
+
"year": year,
|
|
48
|
+
"season": nfc(SEASONS[month // 2]),
|
|
49
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Numbers in Bangla: words, and lakh/crore comma grouping."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
import unicodedata
|
|
7
|
+
|
|
8
|
+
_TO_BN = str.maketrans("0123456789", "০১২৩৪৫৬৭৮৯")
|
|
9
|
+
_TO_ASCII = str.maketrans("০১২৩৪৫৬৭৮৯", "0123456789")
|
|
10
|
+
_PLAIN = re.compile(r"(\d+)(\.\d+)?")
|
|
11
|
+
|
|
12
|
+
# 0-99 are irregular in Bangla, so they are a table, not a rule.
|
|
13
|
+
_UNDER_100 = """
|
|
14
|
+
শূন্য এক দুই তিন চার পাঁচ ছয় সাত আট নয়
|
|
15
|
+
দশ এগারো বারো তেরো চৌদ্দ পনেরো ষোলো সতেরো আঠারো উনিশ
|
|
16
|
+
বিশ একুশ বাইশ তেইশ চব্বিশ পঁচিশ ছাব্বিশ সাতাশ আটাশ ঊনত্রিশ
|
|
17
|
+
ত্রিশ একত্রিশ বত্রিশ তেত্রিশ চৌত্রিশ পঁয়ত্রিশ ছত্রিশ সাঁইত্রিশ আটত্রিশ ঊনচল্লিশ
|
|
18
|
+
চল্লিশ একচল্লিশ বিয়াল্লিশ তেতাল্লিশ চুয়াল্লিশ পঁয়তাল্লিশ ছেচল্লিশ সাতচল্লিশ আটচল্লিশ ঊনপঞ্চাশ
|
|
19
|
+
পঞ্চাশ একান্ন বায়ান্ন তিপ্পান্ন চুয়ান্ন পঞ্চান্ন ছাপ্পান্ন সাতান্ন আটান্ন ঊনষাট
|
|
20
|
+
ষাট একষট্টি বাষট্টি তেষট্টি চৌষট্টি পঁয়ষট্টি ছেষট্টি সাতষট্টি আটষট্টি ঊনসত্তর
|
|
21
|
+
সত্তর একাত্তর বাহাত্তর তিয়াত্তর চুয়াত্তর পঁচাত্তর ছিয়াত্তর সাতাত্তর আটাত্তর ঊনআশি
|
|
22
|
+
আশি একাশি বিরাশি তিরাশি চুরাশি পঁচাশি ছিয়াশি সাতাশি অষ্টাশি ঊননব্বই
|
|
23
|
+
নব্বই একানব্বই বিরানব্বই তিরানব্বই চুরানব্বই পঁচানব্বই ছিয়ানব্বই সাতানব্বই আটানব্বই নিরানব্বই
|
|
24
|
+
""".split()
|
|
25
|
+
|
|
26
|
+
MAX_NUMBER = 10**15 - 1
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _clean(value: int | str) -> tuple[str, str]:
|
|
30
|
+
"""Return (integer digits, decimal part including the dot) from "৩,৫০,০০০" or 350000."""
|
|
31
|
+
text = str(value).strip().translate(_TO_ASCII).replace(",", "").replace(" ", "")
|
|
32
|
+
match = _PLAIN.fullmatch(text)
|
|
33
|
+
if not match:
|
|
34
|
+
raise ValueError(f"not a non-negative number: {value!r}")
|
|
35
|
+
return match.group(1).lstrip("0") or "0", match.group(2) or ""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _words(n: int, lakh: str) -> list[str]:
|
|
39
|
+
parts: list[str] = []
|
|
40
|
+
crore, n = divmod(n, 10_000_000)
|
|
41
|
+
if crore:
|
|
42
|
+
parts += _words(crore, lakh) + ["কোটি"]
|
|
43
|
+
for size, name in ((100_000, lakh), (1_000, "হাজার")):
|
|
44
|
+
count, n = divmod(n, size)
|
|
45
|
+
if count:
|
|
46
|
+
parts += [_UNDER_100[count], name]
|
|
47
|
+
hundreds, n = divmod(n, 100)
|
|
48
|
+
if hundreds:
|
|
49
|
+
parts.append(_UNDER_100[hundreds] + "শো")
|
|
50
|
+
if n:
|
|
51
|
+
parts.append(_UNDER_100[n])
|
|
52
|
+
return parts
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def number_to_words(value: int | str, lakh_word: str = "লক্ষ") -> str:
|
|
56
|
+
"""53 -> তিপ্পান্ন. Whole numbers only; accepts Bangla or English digits and commas."""
|
|
57
|
+
if lakh_word not in ("লক্ষ", "লাখ"):
|
|
58
|
+
raise ValueError("lakh_word must be লক্ষ or লাখ")
|
|
59
|
+
digits, decimal = _clean(value)
|
|
60
|
+
if decimal:
|
|
61
|
+
raise ValueError("only whole numbers are supported")
|
|
62
|
+
n = int(digits)
|
|
63
|
+
if n > MAX_NUMBER:
|
|
64
|
+
raise ValueError(f"number is too large (maximum {MAX_NUMBER})")
|
|
65
|
+
words = " ".join(_words(n, lakh_word)) if n else _UNDER_100[0]
|
|
66
|
+
return unicodedata.normalize("NFC", words)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def format_lakh_crore(value: int | str, bangla_digits: bool = True) -> str:
|
|
70
|
+
"""1234567 -> ১২,৩৪,৫৬৭ (last three digits, then groups of two)."""
|
|
71
|
+
digits, decimal = _clean(value)
|
|
72
|
+
head, tail = digits[:-3], digits[-3:]
|
|
73
|
+
groups = []
|
|
74
|
+
while head:
|
|
75
|
+
groups.insert(0, head[-2:])
|
|
76
|
+
head = head[:-2]
|
|
77
|
+
out = ",".join(groups + [tail]) + decimal
|
|
78
|
+
return out.translate(_TO_BN) if bangla_digits else out
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"""MCP server (stdio). Every tool is a local calculation: no network, no API keys."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from contextlib import contextmanager
|
|
6
|
+
|
|
7
|
+
from mcp.server import MCPServer
|
|
8
|
+
from mcp.server.mcpserver.exceptions import ToolError
|
|
9
|
+
|
|
10
|
+
from . import __version__
|
|
11
|
+
from .calendar import bangla_date
|
|
12
|
+
from .numbers import format_lakh_crore, number_to_words
|
|
13
|
+
|
|
14
|
+
mcp = MCPServer(
|
|
15
|
+
"bangla-tools",
|
|
16
|
+
version=__version__,
|
|
17
|
+
instructions=(
|
|
18
|
+
"Use these tools instead of answering from memory when you need a number written in "
|
|
19
|
+
"Bangla words, a Bangladeshi Bangla date, or lakh/crore comma grouping."
|
|
20
|
+
),
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
@contextmanager
|
|
24
|
+
def _explain_bad_input():
|
|
25
|
+
"""Send the reason to the assistant; other exceptions stay generic."""
|
|
26
|
+
try:
|
|
27
|
+
yield
|
|
28
|
+
except ValueError as exc:
|
|
29
|
+
raise ToolError(str(exc)) from exc
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@mcp.tool()
|
|
33
|
+
def number_to_bangla_words(number: str, lakh_word: str = "লক্ষ") -> str:
|
|
34
|
+
"""Write a whole number in Bangla words, e.g. "53" -> তিপ্পান্ন.
|
|
35
|
+
|
|
36
|
+
Bangla words for 0-99 are irregular, so do not compose them yourself.
|
|
37
|
+
number: digits, Bangla or English, commas allowed. lakh_word: লক্ষ or লাখ.
|
|
38
|
+
"""
|
|
39
|
+
with _explain_bad_input():
|
|
40
|
+
return number_to_words(number, lakh_word)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@mcp.tool()
|
|
44
|
+
def gregorian_to_bangla_date(date: str) -> dict:
|
|
45
|
+
"""Convert a YYYY-MM-DD date to the Bangladeshi Bangla date (revised 2019 calendar).
|
|
46
|
+
|
|
47
|
+
Returns the formatted date, day, month, Bangla year and season. Dates from 2019-04-14.
|
|
48
|
+
Not for the West Bengal calendar.
|
|
49
|
+
"""
|
|
50
|
+
with _explain_bad_input():
|
|
51
|
+
return bangla_date(date)
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@mcp.tool()
|
|
55
|
+
def format_bangla_number(number: str, bangla_digits: bool = True) -> str:
|
|
56
|
+
"""Add Bangladeshi lakh/crore commas, e.g. "1234567" -> ১২,৩৪,৫৬৭.
|
|
57
|
+
|
|
58
|
+
Set bangla_digits to false to keep English digits (12,34,567).
|
|
59
|
+
"""
|
|
60
|
+
with _explain_bad_input():
|
|
61
|
+
return format_lakh_crore(number, bangla_digits)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def main() -> None:
|
|
65
|
+
mcp.run()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
if __name__ == "__main__":
|
|
69
|
+
main()
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.24"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "bangla-tools-mcp"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "MCP server with Bangla tools for AI assistants: number words, Bangladeshi Bangla date, lakh/crore commas"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Mohammed Hossain" }]
|
|
14
|
+
keywords = ["mcp", "model-context-protocol", "bangla", "bengali", "bangladesh", "claude"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Natural Language :: Bengali",
|
|
18
|
+
"Operating System :: OS Independent",
|
|
19
|
+
]
|
|
20
|
+
dependencies = ["mcp>=2,<3"]
|
|
21
|
+
|
|
22
|
+
[project.scripts]
|
|
23
|
+
bangla-tools-mcp = "bangla_tools_mcp.server:main"
|
|
24
|
+
|
|
25
|
+
[project.urls]
|
|
26
|
+
Homepage = "https://github.com/hossainbuilds/bangla-tools-mcp"
|
|
27
|
+
Issues = "https://github.com/hossainbuilds/bangla-tools-mcp/issues"
|
|
28
|
+
Benchmark = "https://github.com/hossainbuilds/bangla-ai-eval"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.build.targets.wheel]
|
|
31
|
+
packages = ["bangla_tools_mcp"]
|
|
32
|
+
|
|
33
|
+
[tool.hatch.build.targets.sdist]
|
|
34
|
+
include = ["bangla_tools_mcp", "tests", "README.md", "LICENSE"]
|
|
35
|
+
|
|
36
|
+
[tool.pytest.ini_options]
|
|
37
|
+
testpaths = ["tests"]
|
|
38
|
+
pythonpath = ["."]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
from mcp import Client
|
|
4
|
+
|
|
5
|
+
from bangla_tools_mcp.server import mcp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_server_lists_and_runs_tools():
|
|
9
|
+
async def go():
|
|
10
|
+
async with Client(mcp) as client:
|
|
11
|
+
tools = {t.name for t in (await client.list_tools()).tools}
|
|
12
|
+
words = await client.call_tool("number_to_bangla_words", {"number": "৫৩"})
|
|
13
|
+
bad = await client.call_tool("number_to_bangla_words", {"number": "abc"})
|
|
14
|
+
return tools, words, bad
|
|
15
|
+
|
|
16
|
+
tools, words, bad = asyncio.run(go())
|
|
17
|
+
assert tools == {"number_to_bangla_words", "gregorian_to_bangla_date", "format_bangla_number"}
|
|
18
|
+
assert words.content[0].text == "তিপ্পান্ন"
|
|
19
|
+
assert bad.is_error and "not a non-negative number" in bad.content[0].text
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import datetime as dt
|
|
2
|
+
import unicodedata
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from bangla_tools_mcp.calendar import bangla_date
|
|
7
|
+
from bangla_tools_mcp.numbers import _UNDER_100, format_lakh_crore, number_to_words
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def nfc(s):
|
|
11
|
+
return unicodedata.normalize("NFC", s)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Expected values are the native-speaker-verified answers from bangla-ai-eval.
|
|
15
|
+
@pytest.mark.parametrize("number,words", [
|
|
16
|
+
(16, "ষোলো"), (29, "ঊনত্রিশ"), (39, "ঊনচল্লিশ"), (44, "চুয়াল্লিশ"), (46, "ছেচল্লিশ"),
|
|
17
|
+
(49, "ঊনপঞ্চাশ"), (53, "তিপ্পান্ন"), (57, "সাতান্ন"), (59, "ঊনষাট"), (62, "বাষট্টি"),
|
|
18
|
+
(66, "ছেষট্টি"), (69, "ঊনসত্তর"), (73, "তিয়াত্তর"), (76, "ছিয়াত্তর"), (79, "ঊনআশি"),
|
|
19
|
+
(82, "বিরাশি"), (88, "অষ্টাশি"), (89, "ঊননব্বই"), (92, "বিরানব্বই"), (97, "সাতানব্বই"),
|
|
20
|
+
(99, "নিরানব্বই"), (100, "একশো"), (350000, "তিন লক্ষ পঞ্চাশ হাজার"),
|
|
21
|
+
(12500000, "এক কোটি পঁচিশ লক্ষ"),
|
|
22
|
+
])
|
|
23
|
+
def test_number_words_match_verified_answers(number, words):
|
|
24
|
+
assert number_to_words(number) == nfc(words)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_number_words_other_shapes():
|
|
28
|
+
assert number_to_words(0) == "শূন্য"
|
|
29
|
+
assert number_to_words("১,০০১") == "এক হাজার এক"
|
|
30
|
+
assert number_to_words(2026) == nfc("দুই হাজার ছাব্বিশ")
|
|
31
|
+
assert number_to_words(250, "লাখ") == nfc("দুইশো পঞ্চাশ")
|
|
32
|
+
assert number_to_words(10**9) == "একশো কোটি"
|
|
33
|
+
assert number_to_words(100000, "লাখ") == "এক লাখ"
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_table_has_100_distinct_words():
|
|
37
|
+
assert len(_UNDER_100) == 100 == len(set(_UNDER_100))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@pytest.mark.parametrize("bad", ["-5", "abc", "", "1.5", str(10**15)])
|
|
41
|
+
def test_number_words_rejects_bad_input(bad):
|
|
42
|
+
with pytest.raises(ValueError):
|
|
43
|
+
number_to_words(bad)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
@pytest.mark.parametrize("number,text", [
|
|
47
|
+
(1234567, "১২,৩৪,৫৬৭"), (50000, "৫০,০০০"), (250000, "২,৫০,০০০"), (1000000, "১০,০০,০০০"),
|
|
48
|
+
(12500000, "১,২৫,০০,০০০"), (987654321, "৯৮,৭৬,৫৪,৩২১"), (4500, "৪,৫০০"),
|
|
49
|
+
(100000, "১,০০,০০০"), (3500000, "৩৫,০০,০০০"), (75000000, "৭,৫০,০০,০০০"),
|
|
50
|
+
])
|
|
51
|
+
def test_lakh_crore_matches_verified_answers(number, text):
|
|
52
|
+
assert format_lakh_crore(number) == text
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def test_lakh_crore_decimals_small_and_english():
|
|
56
|
+
assert format_lakh_crore("125050.50", bangla_digits=False) == "1,25,050.50"
|
|
57
|
+
assert format_lakh_crore(7, bangla_digits=False) == "7"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# Fixed anchors of the revised calendar.
|
|
61
|
+
@pytest.mark.parametrize("date,day,month,year", [
|
|
62
|
+
("2026-04-14", 1, "বৈশাখ", 1433),
|
|
63
|
+
("2026-05-08", 25, "বৈশাখ", 1433), # Rabindra Jayanti
|
|
64
|
+
("2026-05-25", 11, "জ্যৈষ্ঠ", 1433), # Nazrul Jayanti
|
|
65
|
+
("2026-08-06", 22, "শ্রাবণ", 1433),
|
|
66
|
+
("2026-10-17", 1, "কার্তিক", 1433),
|
|
67
|
+
("2026-12-16", 1, "পৌষ", 1433),
|
|
68
|
+
("2027-02-14", 1, "ফাল্গুন", 1433),
|
|
69
|
+
("2027-02-21", 8, "ফাল্গুন", 1433),
|
|
70
|
+
("2027-03-26", 12, "চৈত্র", 1433),
|
|
71
|
+
("2027-04-13", 30, "চৈত্র", 1433),
|
|
72
|
+
])
|
|
73
|
+
def test_bangla_date_anchors(date, day, month, year):
|
|
74
|
+
got = bangla_date(date)
|
|
75
|
+
assert (got["day"], got["month"], got["year"]) == (day, nfc(month), year)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def test_every_day_advances_by_one_across_leap_years():
|
|
79
|
+
date, previous = dt.date(2019, 4, 14), None
|
|
80
|
+
while date < dt.date(2033, 4, 14):
|
|
81
|
+
got = bangla_date(date.isoformat())
|
|
82
|
+
key = (got["year"], got["month_number"], got["day"])
|
|
83
|
+
if previous:
|
|
84
|
+
y, m, d = previous
|
|
85
|
+
assert key in {(y, m, d + 1), (y, m + 1, 1), (y + 1, 1, 1)}, date
|
|
86
|
+
previous, date = key, date + dt.timedelta(days=1)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_falgun_is_longer_in_a_leap_year():
|
|
90
|
+
assert bangla_date("2028-03-14")["day"] == 30 # 2028 is a leap year
|
|
91
|
+
assert bangla_date("2028-03-15")["month_number"] == 12
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_dates_before_the_revision_are_rejected():
|
|
95
|
+
with pytest.raises(ValueError):
|
|
96
|
+
bangla_date("2018-12-16")
|