maitabi 1.0.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.
- maitabi-1.0.0/.github/workflows/ci.yml +36 -0
- maitabi-1.0.0/.github/workflows/docker-publish.yml +64 -0
- maitabi-1.0.0/.github/workflows/pypi-publish.yml +38 -0
- maitabi-1.0.0/.gitignore +17 -0
- maitabi-1.0.0/.pre-commit-config.yaml +31 -0
- maitabi-1.0.0/.vscode/mcp.json +45 -0
- maitabi-1.0.0/AGENTS.md +79 -0
- maitabi-1.0.0/Dockerfile +44 -0
- maitabi-1.0.0/LAUNCHGUIDE.md +50 -0
- maitabi-1.0.0/LICENSE +201 -0
- maitabi-1.0.0/Makefile +59 -0
- maitabi-1.0.0/PKG-INFO +204 -0
- maitabi-1.0.0/README.md +182 -0
- maitabi-1.0.0/docs/TOOL_CATALOG.md +164 -0
- maitabi-1.0.0/pyproject.toml +121 -0
- maitabi-1.0.0/scripts/gen_catalog.py +179 -0
- maitabi-1.0.0/skills/maitabi-bus-extractor/SKILL.md +134 -0
- maitabi-1.0.0/skills/maitabi-bus-extractor/references/filter-mapping.md +149 -0
- maitabi-1.0.0/skills/maitabi-cli/SKILL.md +100 -0
- maitabi-1.0.0/skills/maitabi-cli/references/filter-mapping.md +149 -0
- maitabi-1.0.0/skills/maitabi-mcp/SKILL.md +70 -0
- maitabi-1.0.0/skills/maitabi-mcp/references/filter-mapping.md +149 -0
- maitabi-1.0.0/src/maitabi/__init__.py +1 -0
- maitabi-1.0.0/src/maitabi/__main__.py +6 -0
- maitabi-1.0.0/src/maitabi/cli/__init__.py +1 -0
- maitabi-1.0.0/src/maitabi/cli/__main__.py +6 -0
- maitabi-1.0.0/src/maitabi/cli/commands.py +75 -0
- maitabi-1.0.0/src/maitabi/cli/fields.py +108 -0
- maitabi-1.0.0/src/maitabi/cli/main.py +36 -0
- maitabi-1.0.0/src/maitabi/cli/parser.py +75 -0
- maitabi-1.0.0/src/maitabi/config.py +11 -0
- maitabi-1.0.0/src/maitabi/core/days.py +42 -0
- maitabi-1.0.0/src/maitabi/core/enums.py +54 -0
- maitabi-1.0.0/src/maitabi/core/envelope.py +65 -0
- maitabi-1.0.0/src/maitabi/core/errors.py +50 -0
- maitabi-1.0.0/src/maitabi/core/filters.py +66 -0
- maitabi-1.0.0/src/maitabi/core/inputs.py +297 -0
- maitabi-1.0.0/src/maitabi/mcp/server.py +69 -0
- maitabi-1.0.0/src/maitabi/mcp/tools.py +53 -0
- maitabi-1.0.0/src/maitabi/mcp_args.py +38 -0
- maitabi-1.0.0/src/maitabi/py.typed +0 -0
- maitabi-1.0.0/src/maitabi/registry.py +164 -0
- maitabi-1.0.0/src/maitabi/services/bus.py +137 -0
- maitabi-1.0.0/src/maitabi/services/general.py +156 -0
- maitabi-1.0.0/src/maitabi/services/http.py +82 -0
- maitabi-1.0.0/tests/fixtures/mcp_schema.json +902 -0
- maitabi-1.0.0/tests/test_cli.py +112 -0
- maitabi-1.0.0/tests/test_cli_exit_codes.py +72 -0
- maitabi-1.0.0/tests/test_import_isolation.py +44 -0
- maitabi-1.0.0/tests/test_mcp_schema.py +38 -0
- maitabi-1.0.0/tests/test_output_contract.py +225 -0
- maitabi-1.0.0/tests/test_parity.py +78 -0
- maitabi-1.0.0/tests/test_rate_limit.py +51 -0
- maitabi-1.0.0/uv.lock +1501 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
name: Test & build
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout repository
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Install uv
|
|
17
|
+
uses: astral-sh/setup-uv@v5
|
|
18
|
+
with:
|
|
19
|
+
enable-cache: true
|
|
20
|
+
|
|
21
|
+
- name: Set up Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: "3.12"
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies (incl. dev group)
|
|
27
|
+
run: uv sync --group dev
|
|
28
|
+
|
|
29
|
+
- name: Run offline test suite
|
|
30
|
+
run: uv run pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
- name: Build package
|
|
33
|
+
run: uv build
|
|
34
|
+
|
|
35
|
+
- name: Check generated catalog is up to date
|
|
36
|
+
run: uv run python scripts/gen_catalog.py --check
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Publish Docker Image to Docker Hub
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
build-and-push:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
environment:
|
|
16
|
+
name: dockerhub
|
|
17
|
+
url: https://hub.docker.com/r/phonhay103/maitabi
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout repository
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up QEMU (for multi-arch)
|
|
23
|
+
uses: docker/setup-qemu-action@v3
|
|
24
|
+
|
|
25
|
+
- name: Set up Docker Buildx
|
|
26
|
+
uses: docker/setup-buildx-action@v3
|
|
27
|
+
|
|
28
|
+
- name: Log in to Docker Hub
|
|
29
|
+
uses: docker/login-action@v3
|
|
30
|
+
with:
|
|
31
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
32
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
33
|
+
|
|
34
|
+
- name: Extract metadata for Docker
|
|
35
|
+
id: meta
|
|
36
|
+
uses: docker/metadata-action@v5
|
|
37
|
+
with:
|
|
38
|
+
images: ${{ secrets.DOCKERHUB_USERNAME }}/maitabi
|
|
39
|
+
tags: |
|
|
40
|
+
type=raw,value=latest
|
|
41
|
+
type=semver,pattern={{version}}
|
|
42
|
+
type=semver,pattern={{major}}.{{minor}}
|
|
43
|
+
|
|
44
|
+
- name: Build and push Docker image
|
|
45
|
+
uses: docker/build-push-action@v5
|
|
46
|
+
with:
|
|
47
|
+
context: .
|
|
48
|
+
platforms: linux/amd64,linux/arm64
|
|
49
|
+
push: true
|
|
50
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
51
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
52
|
+
annotations: ${{ steps.meta.outputs.annotations }}
|
|
53
|
+
provenance: true
|
|
54
|
+
sbom: true
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
- name: Update Docker Hub Description
|
|
58
|
+
uses: peter-evans/dockerhub-description@v4
|
|
59
|
+
with:
|
|
60
|
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
61
|
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
62
|
+
repository: ${{ secrets.DOCKERHUB_USERNAME }}/maitabi
|
|
63
|
+
short-description: "Maitabi CLI + MCP server: bus tours, trekking tours, calendars (unofficial)."
|
|
64
|
+
readme-filepath: ./README.md
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Publish Python Package to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
workflow_dispatch:
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
pypi-publish:
|
|
13
|
+
name: Build and publish to PyPI
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
environment:
|
|
16
|
+
name: pypi
|
|
17
|
+
url: https://pypi.org/p/maitabi
|
|
18
|
+
permissions:
|
|
19
|
+
id-token: write # Mandatory for Trusted Publisher authentication
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout repository
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Install uv
|
|
25
|
+
uses: astral-sh/setup-uv@v5
|
|
26
|
+
with:
|
|
27
|
+
enable-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Set up Python
|
|
30
|
+
uses: actions/setup-python@v5
|
|
31
|
+
with:
|
|
32
|
+
python-version: "3.12"
|
|
33
|
+
|
|
34
|
+
- name: Build package
|
|
35
|
+
run: uv build
|
|
36
|
+
|
|
37
|
+
- name: Publish package to PyPI
|
|
38
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
maitabi-1.0.0/.gitignore
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Secret scanning on every commit (https://github.com/gitleaks/gitleaks).
|
|
2
|
+
# One-time setup per clone: pre-commit install
|
|
3
|
+
# The hook builds gitleaks with the Go toolchain on first run, so Go must be
|
|
4
|
+
# on PATH; the built binary is cached afterwards.
|
|
5
|
+
# Only staged changes are scanned, and matches are redacted in the output.
|
|
6
|
+
repos:
|
|
7
|
+
- repo: https://github.com/gitleaks/gitleaks
|
|
8
|
+
rev: v8.30.1
|
|
9
|
+
hooks:
|
|
10
|
+
- id: gitleaks
|
|
11
|
+
|
|
12
|
+
# Project's own linters, run through uv so the ruff/ty versions pinned in
|
|
13
|
+
# uv.lock are the ones enforced (same as `make lint`).
|
|
14
|
+
- repo: local
|
|
15
|
+
hooks:
|
|
16
|
+
- id: ruff-check
|
|
17
|
+
name: ruff check
|
|
18
|
+
entry: uv run --frozen ruff check --force-exclude
|
|
19
|
+
language: system
|
|
20
|
+
types: [python]
|
|
21
|
+
- id: ruff-format
|
|
22
|
+
name: ruff format --check
|
|
23
|
+
entry: uv run --frozen ruff format --check --force-exclude
|
|
24
|
+
language: system
|
|
25
|
+
types: [python]
|
|
26
|
+
- id: ty
|
|
27
|
+
name: ty check
|
|
28
|
+
entry: uv run --frozen ty check
|
|
29
|
+
language: system
|
|
30
|
+
pass_filenames: false
|
|
31
|
+
types: [python]
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"servers": {
|
|
3
|
+
"maitabi": {
|
|
4
|
+
"command": "docker",
|
|
5
|
+
"args": [
|
|
6
|
+
"run",
|
|
7
|
+
"-i",
|
|
8
|
+
"--rm",
|
|
9
|
+
"phonhay103/maitabi:latest",
|
|
10
|
+
"mcp"
|
|
11
|
+
],
|
|
12
|
+
"type": "stdio"
|
|
13
|
+
},
|
|
14
|
+
"maitabi-pypi": {
|
|
15
|
+
"type": "stdio",
|
|
16
|
+
"command": "uvx",
|
|
17
|
+
"args": [
|
|
18
|
+
"maitabi",
|
|
19
|
+
"mcp"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"maitabi-uvx-local": {
|
|
23
|
+
"type": "stdio",
|
|
24
|
+
"command": "uvx",
|
|
25
|
+
"args": [
|
|
26
|
+
"--from",
|
|
27
|
+
".",
|
|
28
|
+
"maitabi",
|
|
29
|
+
"mcp"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"maitabi-docker-local": {
|
|
33
|
+
"type": "stdio",
|
|
34
|
+
"command": "docker",
|
|
35
|
+
"args": [
|
|
36
|
+
"run",
|
|
37
|
+
"-i",
|
|
38
|
+
"--rm",
|
|
39
|
+
"maitabi:latest",
|
|
40
|
+
"mcp"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"inputs": []
|
|
45
|
+
}
|
maitabi-1.0.0/AGENTS.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Maitabi Core ↔ MCP ↔ CLI ↔ Skills Sync Guide
|
|
2
|
+
|
|
3
|
+
**Purpose**: Core logic lives once in `core/` + `services/`. MCP (`mcp/`) and CLI (`cli/`) are thin adapters generated from **one action registry** — `registry.py`. The tool catalog (`docs/TOOL_CATALOG.md`) and the per-skill `filter-mapping.md` copies are **generated from that code**, so the old manual Must-Match tables and sync checklists are gone: CI fails if they drift. Three skills stay independent; the `maitabi-mcp` skill is the procedure layer (which tool, in what order, how to read results) and always assumes the server is already connected — it contains zero setup.
|
|
4
|
+
|
|
5
|
+
**One package, three faces.** The installed artifact is `maitabi` (PyPI + image `phonhay103/maitabi`): CLI (`maitabi <bus|general> <command>`), MCP server (`maitabi mcp`), and the three skills. The CLI is the default interface for agents and scripts; MCP is the protocol adapter for clients that speak it; the skills carry the workflows. `dependencies` in `pyproject.toml` stay full (mcp, fastmcp, httpx, pydantic) so a single install serves every interface.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Architecture (All Layers Match — By Construction)
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Core: core/enums.py + core/inputs.py (param source of truth) + core/filters.py
|
|
13
|
+
+ core/days.py + core/errors.py + config.py (env-overridable base URLs)
|
|
14
|
+
Services: services/http.py (shared get_json + rate-limit detect + bounded fan-out)
|
|
15
|
+
+ services/bus.py + services/general.py (return plain dicts)
|
|
16
|
+
Wiring: registry.py — one Action per capability (tool name, CLI command, Input
|
|
17
|
+
model, service, endpoint, MCP doc, CLI help)
|
|
18
|
+
MCP: mcp/tools.py (tool signatures generated from model FieldInfo → flat schema)
|
|
19
|
+
+ mcp/server.py (create_mcp() + run() + standalone main)
|
|
20
|
+
CLI: mcp_args.py (transport flags, no fastmcp import) → cli/fields.py (one
|
|
21
|
+
field plan feeds both sides) → cli/parser.py (two-level: <domain> <command>
|
|
22
|
+
+ `mcp`) + cli/commands.py (one generic handler) + cli/main.py (exit codes)
|
|
23
|
+
Catalog: docs/TOOL_CATALOG.md + skills/{maitabi-cli,maitabi-mcp}/references/filter-mapping.md
|
|
24
|
+
— GENERATED by scripts/gen_catalog.py (--check in CI)
|
|
25
|
+
Skills: skills/maitabi-bus-extractor (raw curl/HTTP, standalone),
|
|
26
|
+
skills/maitabi-cli (terminal only), skills/maitabi-mcp (procedure only)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Rules:
|
|
30
|
+
- Fix/query/parse logic once in `services/` (+ pure helpers in `core/`); adapters only map args → `Input` → service and serialize JSON **at the edge** (one `json.dumps` in the MCP tool, one in the CLI emitter — wire bytes identical).
|
|
31
|
+
- `cli/*` must NEVER import `fastmcp`/`mcp`/`server`/`mcp.*` (keeps CLI importable without MCP deps — enforced by `tests/test_import_isolation.py`).
|
|
32
|
+
- `__init__.py` stays empty (no heavy imports at package import time).
|
|
33
|
+
- **Parameters and their descriptions live only in `core/inputs.py`.** The MCP schema and every CLI flag are derived from `model_fields`; never restate a description in an adapter.
|
|
34
|
+
- **Generated files are never hand-edited**: `docs/TOOL_CATALOG.md` and the two skill `references/filter-mapping.md` copies come from `scripts/gen_catalog.py`. CI runs `--check` and fails when they are stale.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## The 7 Actions
|
|
39
|
+
|
|
40
|
+
Canonical table (MCP tool ↔ CLI subcommand ↔ Input model ↔ service ↔ endpoint) and every parameter/type/default are generated into **`docs/TOOL_CATALOG.md`** — read it there instead of copying it here. Sources: `registry.py` (actions) + `core/inputs.py` (params). ID value tables (departure/area/style/return-day/seat/lodge) live in `skills/maitabi-bus-extractor/references/filter-mapping.md`, copied into the other two skills by the generator.
|
|
41
|
+
|
|
42
|
+
## Contract Guarantees (Enforced by Tests)
|
|
43
|
+
|
|
44
|
+
- **MCP wire schema** — `tests/test_mcp_schema.py` compares `tools/list` against `tests/fixtures/mcp_schema.json`. Byte-identical unless the change is intentional (then regenerate the fixture in the same commit and call it out in the changelog).
|
|
45
|
+
- **Output shape** — `tests/test_output_contract.py` freezes `detail_url` formats, price/availability filters, multi-day fan-out, batch detail, and error payloads (`{"error", "detail"[, "retry_hint"]}`).
|
|
46
|
+
- **Parity** — `tests/test_parity.py`: 7 MCP tools ↔ 7 CLI subcommands ↔ 7 registry actions.
|
|
47
|
+
- **CLI exit codes** — `tests/test_cli_exit_codes.py`: `0` OK, `1` upstream/network error, `2` input error (bad flag / failed validation).
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Workflow (On Every Change)
|
|
52
|
+
|
|
53
|
+
1. Branch →
|
|
54
|
+
2. Edit core: `core/inputs.py` (params/descriptions) and/or `services/*` (endpoint logic; errors via `core/errors.py`) →
|
|
55
|
+
3. New action only: add one `Action` to `registry.py` (MCP tool + CLI subcommand + catalog row appear automatically) →
|
|
56
|
+
4. `make catalog` (regenerates catalog + skill reference copies) →
|
|
57
|
+
5. Update affected skill `SKILL.md` prose/examples (extractor: cURL; cli: commands; mcp: tool flows) →
|
|
58
|
+
6. Test: `make test` (offline) + `make cli-help` + `make smoke` (live) →
|
|
59
|
+
7. PR → 8. Merge → 9. Tag release (`v*` triggers PyPI + Docker Hub) → 10. `npx skills add -g <repo>`
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## File Map
|
|
64
|
+
|
|
65
|
+
| Component | Path |
|
|
66
|
+
|-----------|------|
|
|
67
|
+
| Param source of truth | `src/maitabi/core/inputs.py` |
|
|
68
|
+
| Enums / filters / errors | `src/maitabi/core/{enums,filters,errors}.py` |
|
|
69
|
+
| Services | `src/maitabi/services/{http,bus,general}.py` |
|
|
70
|
+
| Action registry | `src/maitabi/registry.py` |
|
|
71
|
+
| MCP adapter | `src/maitabi/mcp/{tools,server}.py` |
|
|
72
|
+
| CLI adapter | `src/maitabi/cli/{fields,parser,commands,main}.py` |
|
|
73
|
+
| Envelope / query echo | `src/maitabi/core/envelope.py` |
|
|
74
|
+
| Shared MCP transport args | `src/maitabi/mcp_args.py` |
|
|
75
|
+
| Catalog generator | `scripts/gen_catalog.py` → `docs/TOOL_CATALOG.md` + skill copies |
|
|
76
|
+
| Extractor Skill | `skills/maitabi-bus-extractor/SKILL.md` |
|
|
77
|
+
| CLI Skill | `skills/maitabi-cli/SKILL.md` |
|
|
78
|
+
| MCP Skill | `skills/maitabi-mcp/SKILL.md` |
|
|
79
|
+
| Filter Refs (source) | `skills/maitabi-bus-extractor/references/filter-mapping.md` |
|
maitabi-1.0.0/Dockerfile
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Stage 1: Build virtual environment with uv and Python 3.14
|
|
2
|
+
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder
|
|
3
|
+
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
# Enable bytecode compilation
|
|
7
|
+
ENV UV_COMPILE_BYTECODE=1
|
|
8
|
+
ENV UV_LINK_MODE=copy
|
|
9
|
+
|
|
10
|
+
# Copy project configuration and lock file
|
|
11
|
+
COPY pyproject.toml uv.lock ./
|
|
12
|
+
|
|
13
|
+
# Sync dependencies first (without installing the local project package)
|
|
14
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
15
|
+
uv sync --no-dev --no-editable --no-install-project
|
|
16
|
+
|
|
17
|
+
# Copy README and source files, then do the final project install
|
|
18
|
+
COPY README.md ./
|
|
19
|
+
COPY src/ src/
|
|
20
|
+
RUN --mount=type=cache,target=/root/.cache/uv \
|
|
21
|
+
uv sync --no-dev --no-editable
|
|
22
|
+
|
|
23
|
+
# Stage 2: Minimal runtime image with Python 3.14
|
|
24
|
+
FROM python:3.14-slim-bookworm AS runner
|
|
25
|
+
|
|
26
|
+
WORKDIR /app
|
|
27
|
+
|
|
28
|
+
# Copy virtual environment and source code from builder stage
|
|
29
|
+
COPY --from=builder /app/.venv /app/.venv
|
|
30
|
+
COPY --from=builder /app/src /app/src
|
|
31
|
+
|
|
32
|
+
# Set environment variables
|
|
33
|
+
ENV PATH="/app/.venv/bin:$PATH" \
|
|
34
|
+
PYTHONUNBUFFERED=1 \
|
|
35
|
+
PYTHONPATH="/app/src" \
|
|
36
|
+
MCP_TRANSPORT="stdio" \
|
|
37
|
+
HOST="0.0.0.0" \
|
|
38
|
+
PORT="8000"
|
|
39
|
+
|
|
40
|
+
EXPOSE 8000
|
|
41
|
+
|
|
42
|
+
# Run the MCP server over stdio or http streamable
|
|
43
|
+
ENTRYPOINT ["maitabi", "mcp"]
|
|
44
|
+
CMD ["--transport", "stdio"]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Maitabi MCP Server
|
|
2
|
+
|
|
3
|
+
## Tagline
|
|
4
|
+
Search Japanese alpine bus tours, mountain lodges, and trekking packages from Maitabi.
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
Maitabi MCP Server provides AI agents with real-time access to Japan's premier alpine transportation and mountain tour network, Maitabi (まいたび - 毎日新聞旅行 / 毎日あるぺん号). It enables LLMs to search mountain bus departures across the Japanese Alps (Northern, Central, and Southern Alps including Kamikochi, Tateyama Murodo, Hakuba, Yatsugatake, and Mt. Fuji), filter alpine lodge packages, inspect guided trekking itineraries, check live seat availability, and explore departure calendars. Designed for hikers, outdoor enthusiasts, travel concierges, and trip planning agents.
|
|
8
|
+
|
|
9
|
+
## Setup Requirements
|
|
10
|
+
- `MCP_TRANSPORT` (optional): Transport protocol to use (`stdio`, `sse`, or `streamable-http`). Default is `stdio`.
|
|
11
|
+
- `PORT` (optional): Port number for HTTP/SSE transport modes. Default is `8000`.
|
|
12
|
+
- `HOST` (optional): Host address to bind for HTTP/SSE transport modes. Default is `0.0.0.0`.
|
|
13
|
+
- `MCP_PATH` (optional): Path for Streamable HTTP transport mode. Default is `/mcp`.
|
|
14
|
+
|
|
15
|
+
## Category
|
|
16
|
+
Search & Web
|
|
17
|
+
|
|
18
|
+
## Use Cases
|
|
19
|
+
Japan Alpine Trip Planning, Mountain Bus Departure Search, Mountain Lodge Package Discovery, Guided Trekking Itinerary Exploration, Multi-filter Tour Comparison, Departure Calendar Matrix Tracking, Outdoor & Hiking Concierge, Travel Assistant Integration
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
- Search mountain bus departures and alpine lodge packages across the Japanese Alps (bus.maitabi.jp)
|
|
23
|
+
- Search domestic and overseas guided climbing tours and hiking trips (www.maitabi.jp)
|
|
24
|
+
- Support for multiple departure hubs including Tokyo (Takebashi/Shinjuku), Osaka, Kyoto, and Nagoya
|
|
25
|
+
- Filter by seat classes including Standard, Premium, and Double seat configurations
|
|
26
|
+
- Filter by specific mountain huts and lodges (e.g., Enzanso, Nishiho Sanso, Murodo Sanso)
|
|
27
|
+
- Filter tours by date ranges, price range, and live seat availability (excluding full/closed tours)
|
|
28
|
+
- Retrieve complete tour itineraries, bus stop locations, meal plans, guide details, and direct booking links
|
|
29
|
+
- Extract monthly departure calendar matrix and tour counts for any given year and month
|
|
30
|
+
- Zero API key requirement with direct connection to public Maitabi endpoints
|
|
31
|
+
- Seamless compatibility with stdio, SSE, and Streamable HTTP transports
|
|
32
|
+
|
|
33
|
+
## Getting Started
|
|
34
|
+
- "Find mountain bus tours from Tokyo to Kamikochi departing next month with available seats."
|
|
35
|
+
- "Search for trekking packages staying at Enzanso lodge with premium bus seating."
|
|
36
|
+
- "Check the departure calendar for domestic mountain climbing tours in August 2026."
|
|
37
|
+
- "Show me tour details, prices, and itinerary for course number 14241."
|
|
38
|
+
- Tool: list_filters — Fetch available filter dropdown options, departure areas, tour styles, mountain lodges, and live tour counts.
|
|
39
|
+
- Tool: list_district_groups — Fetch mountain area/district groups and tour counts based on active filters.
|
|
40
|
+
- Tool: search_tours — Search mountain bus tours and lodge packages with full filter support (departure, date, seat type, lodge, price, availability).
|
|
41
|
+
- Tool: get_tour_detail — Fetch complete tour schedule, pricing matrix, and bus stop details for a specific bus tour by course_no.
|
|
42
|
+
- Tool: search_general_tours — Search general travel tours and alpine trekking packages across 5 categories on www.maitabi.jp.
|
|
43
|
+
- Tool: get_general_tour_detail — Fetch complete itinerary, meal condition, guide info, and booking links for a general tour by course_no.
|
|
44
|
+
- Tool: get_tour_calendar — Fetch monthly departure calendar matrix and tour availability for a given year and month.
|
|
45
|
+
|
|
46
|
+
## Tags
|
|
47
|
+
maitabi, japan-alps, mountain-bus, trekking, hiking, travel, alpine, kamikochi, tateyama, hakuba, fuji, japan-travel, tour-search, fastmcp, mcp-server
|
|
48
|
+
|
|
49
|
+
## Documentation URL
|
|
50
|
+
https://github.com/phonhay103/maitabi
|
maitabi-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
maitabi-1.0.0/Makefile
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
.PHONY: help install dev dev-http dev-sse test smoke cli-help cli-example docker-build docker-run docker-run-http build catalog catalog-check clean
|
|
2
|
+
|
|
3
|
+
DOCKER_USER ?= phonhay103
|
|
4
|
+
IMAGE_NAME ?= maitabi
|
|
5
|
+
TAG ?= latest
|
|
6
|
+
HOST ?= 0.0.0.0
|
|
7
|
+
PORT ?= 8000
|
|
8
|
+
|
|
9
|
+
help: ## Show this help message
|
|
10
|
+
@echo "Usage: make [target]"
|
|
11
|
+
@echo ""
|
|
12
|
+
@echo "Targets:"
|
|
13
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
|
|
14
|
+
|
|
15
|
+
install: ## Install dependencies using uv
|
|
16
|
+
uv sync
|
|
17
|
+
|
|
18
|
+
dev: ## Run the MCP server locally using stdio transport
|
|
19
|
+
uv run maitabi mcp --transport stdio
|
|
20
|
+
|
|
21
|
+
dev-http: ## Run the MCP server locally using Streamable HTTP transport
|
|
22
|
+
uv run maitabi mcp --transport streamable-http --host $(HOST) --port $(PORT)
|
|
23
|
+
|
|
24
|
+
dev-sse: ## Run the MCP server locally using SSE transport
|
|
25
|
+
uv run maitabi mcp --transport sse --host $(HOST) --port $(PORT)
|
|
26
|
+
|
|
27
|
+
test: ## Run offline test suite (pytest, no network)
|
|
28
|
+
uv run pytest tests/ -v
|
|
29
|
+
|
|
30
|
+
smoke: ## LIVE network smoke check against production API (not part of make test)
|
|
31
|
+
uv run python -c "import asyncio; from maitabi.services.bus import list_filters_service; from maitabi.core.inputs import ListFiltersInput; asyncio.run(list_filters_service(ListFiltersInput())); print('Smoke check passed!')"
|
|
32
|
+
|
|
33
|
+
catalog: ## Regenerate docs/TOOL_CATALOG.md + skill filter-mapping copies
|
|
34
|
+
uv run python scripts/gen_catalog.py
|
|
35
|
+
|
|
36
|
+
catalog-check: ## Fail when generated catalog files are stale (used by CI)
|
|
37
|
+
uv run python scripts/gen_catalog.py --check
|
|
38
|
+
|
|
39
|
+
cli-help: ## Show CLI help
|
|
40
|
+
uv run maitabi --help
|
|
41
|
+
|
|
42
|
+
cli-example: ## Example CLI search (mountain bus tours)
|
|
43
|
+
uv run maitabi bus search-tours --departure 1 --month 8 --area 18 --page 1 | head -c 2000
|
|
44
|
+
|
|
45
|
+
docker-build: ## Build the 2-stage Docker image (Python 3.14)
|
|
46
|
+
docker build -t $(IMAGE_NAME):$(TAG) -t $(DOCKER_USER)/$(IMAGE_NAME):$(TAG) .
|
|
47
|
+
|
|
48
|
+
docker-run: ## Run the MCP server inside Docker container (stdio transport)
|
|
49
|
+
docker run -i --rm $(IMAGE_NAME):$(TAG)
|
|
50
|
+
|
|
51
|
+
docker-run-http: ## Run the MCP server inside Docker container (Streamable HTTP transport)
|
|
52
|
+
docker run -i --rm -p $(PORT):$(PORT) $(IMAGE_NAME):$(TAG) --transport streamable-http --port $(PORT)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
build: ## Build Python package wheel & sdist for PyPI / uvx
|
|
56
|
+
uv build
|
|
57
|
+
|
|
58
|
+
clean: ## Remove build artifacts and cache
|
|
59
|
+
rm -rf .venv __pycache__ .pytest_cache *.egg-info src/*.egg-info dist
|