teafyi 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.
- teafyi-0.1.0/.gitignore +9 -0
- teafyi-0.1.0/LICENSE +21 -0
- teafyi-0.1.0/PKG-INFO +92 -0
- teafyi-0.1.0/README.md +52 -0
- teafyi-0.1.0/pyproject.toml +88 -0
- teafyi-0.1.0/skills/tea-tools/SKILL.md +51 -0
- teafyi-0.1.0/src/teafyi/__init__.py +14 -0
- teafyi-0.1.0/src/teafyi/api.py +64 -0
- teafyi-0.1.0/src/teafyi/cli.py +56 -0
- teafyi-0.1.0/src/teafyi/mcp_server.py +65 -0
- teafyi-0.1.0/src/teafyi/py.typed +0 -0
- teafyi-0.1.0/tests/__init__.py +0 -0
- teafyi-0.1.0/tests/test_api.py +40 -0
- teafyi-0.1.0/uv.lock +1137 -0
teafyi-0.1.0/.gitignore
ADDED
teafyi-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FYIPedia
|
|
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.
|
teafyi-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: teafyi
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Tea knowledge API client — search tea varieties, processing methods, and terms from TeaFYI.
|
|
5
|
+
Project-URL: Homepage, https://teafyi.com
|
|
6
|
+
Project-URL: Documentation, https://teafyi.com/developers/
|
|
7
|
+
Project-URL: Repository, https://github.com/fyipedia/teafyi
|
|
8
|
+
Project-URL: Issues, https://github.com/fyipedia/teafyi/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/fyipedia/teafyi/releases
|
|
10
|
+
Author: FYIPedia
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: black-tea,caffeine,green-tea,herbal-tea,matcha,oolong,steeping,tea,tea-ceremony,teaware
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Developers
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: httpx>=0.27; extra == 'all'
|
|
29
|
+
Requires-Dist: mcp>=1.0; extra == 'all'
|
|
30
|
+
Requires-Dist: rich>=13.0; extra == 'all'
|
|
31
|
+
Requires-Dist: typer>=0.15; extra == 'all'
|
|
32
|
+
Provides-Extra: api
|
|
33
|
+
Requires-Dist: httpx>=0.27; extra == 'api'
|
|
34
|
+
Provides-Extra: cli
|
|
35
|
+
Requires-Dist: rich>=13.0; extra == 'cli'
|
|
36
|
+
Requires-Dist: typer>=0.15; extra == 'cli'
|
|
37
|
+
Provides-Extra: mcp
|
|
38
|
+
Requires-Dist: mcp>=1.0; extra == 'mcp'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# teafyi
|
|
42
|
+
|
|
43
|
+
Tea knowledge API client for developers -- search tea varieties, processing methods, and terminology from [TeaFYI](https://teafyi.com).
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install teafyi[api] # API client (httpx)
|
|
49
|
+
pip install teafyi[cli] # + CLI (typer, rich)
|
|
50
|
+
pip install teafyi[mcp] # + MCP server
|
|
51
|
+
pip install teafyi[all] # Everything
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Quick Start
|
|
55
|
+
|
|
56
|
+
```python
|
|
57
|
+
from teafyi.api import TeaFYI
|
|
58
|
+
|
|
59
|
+
with TeaFYI() as api:
|
|
60
|
+
results = api.search("matcha")
|
|
61
|
+
print(results)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## CLI
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
teafyi search "matcha"
|
|
68
|
+
teafyi search "oolong"
|
|
69
|
+
teafyi search "gongfu ceremony"
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## MCP Server
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Add to Claude Desktop config
|
|
76
|
+
python -m teafyi.mcp_server
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Tools: `tea_search`
|
|
80
|
+
|
|
81
|
+
## API Endpoints
|
|
82
|
+
|
|
83
|
+
| Method | Endpoint | Description |
|
|
84
|
+
|--------|----------|-------------|
|
|
85
|
+
| `search(query)` | `GET /api/search/?q=...` | Search teas, varieties, and terms |
|
|
86
|
+
|
|
87
|
+
## Links
|
|
88
|
+
|
|
89
|
+
- [TeaFYI](https://teafyi.com) -- Tea encyclopedia with categories, varieties, processing methods, and more
|
|
90
|
+
- [PyPI](https://pypi.org/project/teafyi/)
|
|
91
|
+
- [GitHub](https://github.com/fyipedia/teafyi)
|
|
92
|
+
- [FYIPedia](https://fyipedia.com) -- Open-source developer tools ecosystem
|
teafyi-0.1.0/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# teafyi
|
|
2
|
+
|
|
3
|
+
Tea knowledge API client for developers -- search tea varieties, processing methods, and terminology from [TeaFYI](https://teafyi.com).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install teafyi[api] # API client (httpx)
|
|
9
|
+
pip install teafyi[cli] # + CLI (typer, rich)
|
|
10
|
+
pip install teafyi[mcp] # + MCP server
|
|
11
|
+
pip install teafyi[all] # Everything
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```python
|
|
17
|
+
from teafyi.api import TeaFYI
|
|
18
|
+
|
|
19
|
+
with TeaFYI() as api:
|
|
20
|
+
results = api.search("matcha")
|
|
21
|
+
print(results)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## CLI
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
teafyi search "matcha"
|
|
28
|
+
teafyi search "oolong"
|
|
29
|
+
teafyi search "gongfu ceremony"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## MCP Server
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Add to Claude Desktop config
|
|
36
|
+
python -m teafyi.mcp_server
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Tools: `tea_search`
|
|
40
|
+
|
|
41
|
+
## API Endpoints
|
|
42
|
+
|
|
43
|
+
| Method | Endpoint | Description |
|
|
44
|
+
|--------|----------|-------------|
|
|
45
|
+
| `search(query)` | `GET /api/search/?q=...` | Search teas, varieties, and terms |
|
|
46
|
+
|
|
47
|
+
## Links
|
|
48
|
+
|
|
49
|
+
- [TeaFYI](https://teafyi.com) -- Tea encyclopedia with categories, varieties, processing methods, and more
|
|
50
|
+
- [PyPI](https://pypi.org/project/teafyi/)
|
|
51
|
+
- [GitHub](https://github.com/fyipedia/teafyi)
|
|
52
|
+
- [FYIPedia](https://fyipedia.com) -- Open-source developer tools ecosystem
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "teafyi"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Tea knowledge API client — search tea varieties, processing methods, and terms from TeaFYI."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [{ name = "FYIPedia" }]
|
|
9
|
+
keywords = [
|
|
10
|
+
"tea",
|
|
11
|
+
"green-tea",
|
|
12
|
+
"black-tea",
|
|
13
|
+
"oolong",
|
|
14
|
+
"matcha",
|
|
15
|
+
"herbal-tea",
|
|
16
|
+
"tea-ceremony",
|
|
17
|
+
"teaware",
|
|
18
|
+
"caffeine",
|
|
19
|
+
"steeping",
|
|
20
|
+
]
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
|
+
"Intended Audience :: Developers",
|
|
24
|
+
"License :: OSI Approved :: MIT License",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Programming Language :: Python :: 3.14",
|
|
31
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
32
|
+
"Typing :: Typed",
|
|
33
|
+
"Environment :: Console",
|
|
34
|
+
]
|
|
35
|
+
dependencies = []
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
api = ["httpx>=0.27"]
|
|
39
|
+
cli = ["typer>=0.15", "rich>=13.0"]
|
|
40
|
+
mcp = ["mcp>=1.0"]
|
|
41
|
+
all = ["teafyi[api,cli,mcp]"]
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
teafyi = "teafyi.cli:app"
|
|
45
|
+
|
|
46
|
+
[project.entry-points."mcp.servers"]
|
|
47
|
+
teafyi = "teafyi.mcp_server:mcp"
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://teafyi.com"
|
|
51
|
+
Documentation = "https://teafyi.com/developers/"
|
|
52
|
+
Repository = "https://github.com/fyipedia/teafyi"
|
|
53
|
+
Issues = "https://github.com/fyipedia/teafyi/issues"
|
|
54
|
+
Changelog = "https://github.com/fyipedia/teafyi/releases"
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = ["hatchling"]
|
|
58
|
+
build-backend = "hatchling.build"
|
|
59
|
+
|
|
60
|
+
[tool.hatch.build.targets.wheel]
|
|
61
|
+
packages = ["src/teafyi"]
|
|
62
|
+
|
|
63
|
+
[tool.pytest.ini_options]
|
|
64
|
+
testpaths = ["tests"]
|
|
65
|
+
addopts = "-v --tb=short"
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
target-version = "py310"
|
|
69
|
+
line-length = 100
|
|
70
|
+
|
|
71
|
+
[tool.ruff.lint]
|
|
72
|
+
select = ["E", "F", "I", "UP", "B", "SIM", "RUF"]
|
|
73
|
+
ignore = ["RUF022"]
|
|
74
|
+
|
|
75
|
+
[tool.mypy]
|
|
76
|
+
python_version = "3.10"
|
|
77
|
+
strict = true
|
|
78
|
+
|
|
79
|
+
[dependency-groups]
|
|
80
|
+
dev = [
|
|
81
|
+
"httpx>=0.27",
|
|
82
|
+
"mcp>=1.0",
|
|
83
|
+
"mypy>=1.19.1",
|
|
84
|
+
"pytest>=9.0.2",
|
|
85
|
+
"rich>=13.0",
|
|
86
|
+
"ruff>=0.15.4",
|
|
87
|
+
"typer>=0.15",
|
|
88
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: tea-tools
|
|
3
|
+
description: Search 200+ tea varieties across 6 categories (white, green, oolong, black, dark, herbal) with chemistry, brewing guides, and origin data.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Tea Tools
|
|
7
|
+
|
|
8
|
+
Tea variety search and reference powered by [teafyi](https://teafyi.com/) -- a comprehensive tea knowledge platform covering 200+ varieties across 6 oxidation-based categories.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
Install the MCP server:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install "teafyi[mcp]"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Add to your `claude_desktop_config.json`:
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"teafyi": {
|
|
24
|
+
"command": "python",
|
|
25
|
+
"args": ["-m", "teafyi.mcp_server"]
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Available Tools
|
|
32
|
+
|
|
33
|
+
| Tool | Description |
|
|
34
|
+
|------|-------------|
|
|
35
|
+
| `tea_search` | Search tea varieties, categories, regions, processing methods, and terminology |
|
|
36
|
+
|
|
37
|
+
## When to Use
|
|
38
|
+
|
|
39
|
+
- Looking up tea varieties and their flavor profiles
|
|
40
|
+
- Researching tea categories by oxidation level (white → green → oolong → black → dark)
|
|
41
|
+
- Finding optimal brewing parameters (temperature, time, leaf-to-water ratio)
|
|
42
|
+
- Exploring tea chemistry (L-theanine, catechins, caffeine, theaflavins)
|
|
43
|
+
- Learning about tea origins and terroir (Darjeeling, Wuyi, Uji, Assam, etc.)
|
|
44
|
+
|
|
45
|
+
## Links
|
|
46
|
+
|
|
47
|
+
- [200+ Tea Varieties](https://teafyi.com/teas/)
|
|
48
|
+
- [6 Tea Categories](https://teafyi.com/categories/)
|
|
49
|
+
- [Tea Regions](https://teafyi.com/regions/)
|
|
50
|
+
- [API Documentation](https://teafyi.com/developers/)
|
|
51
|
+
- [PyPI Package](https://pypi.org/project/teafyi/)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"""teafyi — Tea knowledge API client for developers.
|
|
2
|
+
|
|
3
|
+
Search tea varieties, processing methods, and terminology from TeaFYI.
|
|
4
|
+
|
|
5
|
+
Usage::
|
|
6
|
+
|
|
7
|
+
from teafyi.api import TeaFYI
|
|
8
|
+
|
|
9
|
+
with TeaFYI() as api:
|
|
10
|
+
results = api.search("matcha")
|
|
11
|
+
print(results)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
__version__ = "0.1.0"
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""HTTP API client for teafyi.com REST endpoints.
|
|
2
|
+
|
|
3
|
+
Requires the ``api`` extra: ``pip install teafyi[api]``
|
|
4
|
+
|
|
5
|
+
Usage::
|
|
6
|
+
|
|
7
|
+
from teafyi.api import TeaFYI
|
|
8
|
+
|
|
9
|
+
with TeaFYI() as api:
|
|
10
|
+
results = api.search("matcha")
|
|
11
|
+
print(results)
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import httpx
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class TeaFYI:
|
|
22
|
+
"""API client for the teafyi.com REST API.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
base_url: API base URL. Defaults to ``https://teafyi.com``.
|
|
26
|
+
timeout: Request timeout in seconds. Defaults to ``10.0``.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
base_url: str = "https://teafyi.com",
|
|
32
|
+
timeout: float = 10.0,
|
|
33
|
+
) -> None:
|
|
34
|
+
self._client = httpx.Client(base_url=base_url, timeout=timeout)
|
|
35
|
+
|
|
36
|
+
# -- HTTP helpers ----------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
def _get(self, path: str, **params: Any) -> dict[str, Any]:
|
|
39
|
+
resp = self._client.get(path, params={k: v for k, v in params.items() if v is not None})
|
|
40
|
+
resp.raise_for_status()
|
|
41
|
+
result: dict[str, Any] = resp.json()
|
|
42
|
+
return result
|
|
43
|
+
|
|
44
|
+
# -- Endpoints -------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
def search(self, query: str) -> dict[str, Any]:
|
|
47
|
+
"""Search teas, varieties, and glossary terms.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
query: Search term (e.g. ``"matcha"``, ``"oolong"``).
|
|
51
|
+
"""
|
|
52
|
+
return self._get("/api/search/", q=query)
|
|
53
|
+
|
|
54
|
+
# -- Context manager -------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
def close(self) -> None:
|
|
57
|
+
"""Close the underlying HTTP connection."""
|
|
58
|
+
self._client.close()
|
|
59
|
+
|
|
60
|
+
def __enter__(self) -> TeaFYI:
|
|
61
|
+
return self
|
|
62
|
+
|
|
63
|
+
def __exit__(self, *_: object) -> None:
|
|
64
|
+
self.close()
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Command-line interface for teafyi.
|
|
2
|
+
|
|
3
|
+
Requires the ``cli`` extra: ``pip install teafyi[cli]``
|
|
4
|
+
|
|
5
|
+
Usage::
|
|
6
|
+
|
|
7
|
+
teafyi search "matcha"
|
|
8
|
+
teafyi search "oolong"
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import typer
|
|
14
|
+
from rich.console import Console
|
|
15
|
+
from rich.table import Table
|
|
16
|
+
|
|
17
|
+
app = typer.Typer(
|
|
18
|
+
name="teafyi",
|
|
19
|
+
help="Tea knowledge API client — search tea varieties, processing methods, and terms.",
|
|
20
|
+
no_args_is_help=True,
|
|
21
|
+
)
|
|
22
|
+
console = Console()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@app.command()
|
|
26
|
+
def search(
|
|
27
|
+
query: str = typer.Argument(help="Search term (e.g. 'matcha', 'oolong', 'gongfu')"),
|
|
28
|
+
) -> None:
|
|
29
|
+
"""Search teas, varieties, and glossary terms from TeaFYI."""
|
|
30
|
+
from teafyi.api import TeaFYI
|
|
31
|
+
|
|
32
|
+
with TeaFYI() as api:
|
|
33
|
+
data = api.search(query)
|
|
34
|
+
|
|
35
|
+
results = data.get("results", [])
|
|
36
|
+
if not results:
|
|
37
|
+
console.print(f"[yellow]No results found for '{query}'[/yellow]")
|
|
38
|
+
return
|
|
39
|
+
|
|
40
|
+
table = Table(title=f"Search: {query}")
|
|
41
|
+
table.add_column("Type", style="cyan", no_wrap=True)
|
|
42
|
+
table.add_column("Name", style="bold")
|
|
43
|
+
table.add_column("URL")
|
|
44
|
+
|
|
45
|
+
for item in results:
|
|
46
|
+
table.add_row(
|
|
47
|
+
item.get("type", ""),
|
|
48
|
+
item.get("name", ""),
|
|
49
|
+
item.get("url", ""),
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
console.print(table)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
if __name__ == "__main__":
|
|
56
|
+
app()
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""MCP server for teafyi — tea knowledge tools for AI assistants.
|
|
2
|
+
|
|
3
|
+
Requires the ``mcp`` extra: ``pip install teafyi[mcp]``
|
|
4
|
+
|
|
5
|
+
Run as a standalone server::
|
|
6
|
+
|
|
7
|
+
python -m teafyi.mcp_server
|
|
8
|
+
|
|
9
|
+
Or configure in ``claude_desktop_config.json``::
|
|
10
|
+
|
|
11
|
+
{
|
|
12
|
+
"mcpServers": {
|
|
13
|
+
"teafyi": {
|
|
14
|
+
"command": "python",
|
|
15
|
+
"args": ["-m", "teafyi.mcp_server"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
from mcp.server.fastmcp import FastMCP
|
|
24
|
+
|
|
25
|
+
mcp = FastMCP("teafyi")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@mcp.tool()
|
|
29
|
+
def tea_search(query: str) -> str:
|
|
30
|
+
"""Search teas, varieties, processing methods, and glossary terms from TeaFYI.
|
|
31
|
+
|
|
32
|
+
Covers green tea, black tea, oolong, white tea, pu-erh, matcha, herbal teas,
|
|
33
|
+
tea ceremony traditions, teaware, and more.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
query: Search term (e.g. "matcha", "oolong", "gongfu ceremony").
|
|
37
|
+
"""
|
|
38
|
+
from teafyi.api import TeaFYI
|
|
39
|
+
|
|
40
|
+
with TeaFYI() as api:
|
|
41
|
+
data = api.search(query)
|
|
42
|
+
|
|
43
|
+
results = data.get("results", [])
|
|
44
|
+
if not results:
|
|
45
|
+
return f"No results found for '{query}'."
|
|
46
|
+
|
|
47
|
+
lines = [
|
|
48
|
+
f"## Tea Search: {query}",
|
|
49
|
+
"",
|
|
50
|
+
f"Found {len(results)} result(s):",
|
|
51
|
+
"",
|
|
52
|
+
"| Type | Name | URL |",
|
|
53
|
+
"|------|------|-----|",
|
|
54
|
+
]
|
|
55
|
+
for item in results:
|
|
56
|
+
item_type = item.get("type", "")
|
|
57
|
+
name = item.get("name", "")
|
|
58
|
+
url = item.get("url", "")
|
|
59
|
+
lines.append(f"| {item_type} | {name} | {url} |")
|
|
60
|
+
|
|
61
|
+
return "\n".join(lines)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if __name__ == "__main__":
|
|
65
|
+
mcp.run()
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"""Tests for teafyi.api — API client initialization and URL construction."""
|
|
2
|
+
|
|
3
|
+
from teafyi.api import TeaFYI
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestTeaFYIInit:
|
|
7
|
+
def test_default_base_url(self) -> None:
|
|
8
|
+
client = TeaFYI()
|
|
9
|
+
assert str(client._client.base_url) == "https://teafyi.com"
|
|
10
|
+
client.close()
|
|
11
|
+
|
|
12
|
+
def test_custom_base_url(self) -> None:
|
|
13
|
+
client = TeaFYI(base_url="https://custom.example.com")
|
|
14
|
+
assert str(client._client.base_url) == "https://custom.example.com"
|
|
15
|
+
client.close()
|
|
16
|
+
|
|
17
|
+
def test_default_timeout(self) -> None:
|
|
18
|
+
client = TeaFYI()
|
|
19
|
+
assert client._client.timeout.connect == 10.0
|
|
20
|
+
client.close()
|
|
21
|
+
|
|
22
|
+
def test_custom_timeout(self) -> None:
|
|
23
|
+
client = TeaFYI(timeout=30.0)
|
|
24
|
+
assert client._client.timeout.connect == 30.0
|
|
25
|
+
client.close()
|
|
26
|
+
|
|
27
|
+
def test_context_manager(self) -> None:
|
|
28
|
+
with TeaFYI() as api:
|
|
29
|
+
assert str(api._client.base_url) == "https://teafyi.com"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class TestTeaFYIURLConstruction:
|
|
33
|
+
def test_search_url_path(self) -> None:
|
|
34
|
+
"""Verify search method would call the correct path (without making HTTP requests)."""
|
|
35
|
+
client = TeaFYI()
|
|
36
|
+
# Build the request manually to verify URL construction
|
|
37
|
+
request = client._client.build_request("GET", "/api/search/", params={"q": "matcha"})
|
|
38
|
+
assert "/api/search/" in str(request.url)
|
|
39
|
+
assert "q=matcha" in str(request.url)
|
|
40
|
+
client.close()
|