okf-cli 0.8.0__tar.gz → 0.8.1__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.
Files changed (54) hide show
  1. okf_cli-0.8.1/.github/workflows/publish.yml +40 -0
  2. {okf_cli-0.8.0 → okf_cli-0.8.1}/.github/workflows/test.yml +2 -1
  3. {okf_cli-0.8.0 → okf_cli-0.8.1}/PKG-INFO +26 -2
  4. {okf_cli-0.8.0 → okf_cli-0.8.1}/README.md +25 -1
  5. {okf_cli-0.8.0 → okf_cli-0.8.1}/pyproject.toml +1 -1
  6. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/serve_mcp.py +30 -3
  7. {okf_cli-0.8.0 → okf_cli-0.8.1}/tests/test_mcp.py +26 -2
  8. {okf_cli-0.8.0 → okf_cli-0.8.1}/uv.lock +1 -1
  9. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/operations.md +12 -9
  10. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/quickstart.md +1 -1
  11. {okf_cli-0.8.0 → okf_cli-0.8.1}/.agents/skills/wiki/SKILL.md +0 -0
  12. {okf_cli-0.8.0 → okf_cli-0.8.1}/.gitignore +0 -0
  13. {okf_cli-0.8.0 → okf_cli-0.8.1}/.last-update.json +0 -0
  14. {okf_cli-0.8.0 → okf_cli-0.8.1}/AGENTS.md +0 -0
  15. {okf_cli-0.8.0 → okf_cli-0.8.1}/LICENSE +0 -0
  16. {okf_cli-0.8.0 → okf_cli-0.8.1}/SPEC/OKF_SPEC_V0_1.md +0 -0
  17. {okf_cli-0.8.0 → okf_cli-0.8.1}/SPEC/OKF_SPEC_V0_2.md +0 -0
  18. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/.okfignore +0 -0
  19. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/README.md +0 -0
  20. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/blank-line/no-blank.md +0 -0
  21. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/blank-line/with-blank.md +0 -0
  22. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/computations/revenue.md +0 -0
  23. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/datasets/sales.md +0 -0
  24. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/domain.md +0 -0
  25. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/loose/deep/no-heading.md +0 -0
  26. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/loose/no-desc.md +0 -0
  27. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/loose/no-title.md +0 -0
  28. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/metrics/income-statement.md +0 -0
  29. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/playbooks/incident-response.md +0 -0
  30. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/playbooks/oncall-guide.md +0 -0
  31. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/references/revenue-recognition.md +0 -0
  32. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/smoke-ignore.md +0 -0
  33. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/tables/customers.md +0 -0
  34. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/tables/orders.md +0 -0
  35. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/tables/partitions/2026/q1/jan/january.md +0 -0
  36. {okf_cli-0.8.0 → okf_cli-0.8.1}/example/tables/partitions/daily.md +0 -0
  37. {okf_cli-0.8.0 → okf_cli-0.8.1}/skills/okf-cli/SKILL.md +0 -0
  38. {okf_cli-0.8.0 → okf_cli-0.8.1}/skills/writing-knowledge-base/SKILL.md +0 -0
  39. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/__init__.py +0 -0
  40. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/api.py +0 -0
  41. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/cli.py +0 -0
  42. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/__init__.py +0 -0
  43. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/bundle.py +0 -0
  44. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/list.py +0 -0
  45. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/read.py +0 -0
  46. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/commands/validate.py +0 -0
  47. {okf_cli-0.8.0 → okf_cli-0.8.1}/src/okf/core.py +0 -0
  48. {okf_cli-0.8.0 → okf_cli-0.8.1}/tests/test_api.py +0 -0
  49. {okf_cli-0.8.0 → okf_cli-0.8.1}/tests/test_cli.py +0 -0
  50. {okf_cli-0.8.0 → okf_cli-0.8.1}/tests/test_core.py +0 -0
  51. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/architecture.md +0 -0
  52. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/domain-model.md +0 -0
  53. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/testing.md +0 -0
  54. {okf_cli-0.8.0 → okf_cli-0.8.1}/wiki/workflows.md +0 -0
@@ -0,0 +1,40 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v0.*.*"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ id-token: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-python@v5
20
+ with:
21
+ python-version: "3.11"
22
+ - uses: astral-sh/setup-uv@v3
23
+ - name: Verify tag matches package version
24
+ run: |
25
+ tag="$GITHUB_REF_NAME"
26
+ if [[ ! "$tag" =~ ^v0\.[0-9]+\.[0-9]+$ ]]; then
27
+ echo "Tag $tag must have the form v0.x.x" >&2
28
+ exit 1
29
+ fi
30
+
31
+ tag_version="${tag#v}"
32
+ package_version="$(uv version --short)"
33
+ if [[ "$tag_version" != "$package_version" ]]; then
34
+ echo "Tag version $tag_version does not match pyproject.toml version $package_version" >&2
35
+ exit 1
36
+ fi
37
+ - name: Build distributions
38
+ run: uv build
39
+ - name: Publish distributions to PyPI
40
+ run: uv publish
@@ -10,9 +10,10 @@ jobs:
10
10
  python-version: ["3.11"]
11
11
  steps:
12
12
  - uses: actions/checkout@v4
13
- - uses: astral-sh/setup-uv@v3
13
+ - uses: actions/setup-python@v5
14
14
  with:
15
15
  python-version: ${{ matrix.python-version }}
16
+ - uses: astral-sh/setup-uv@v3
16
17
  - run: uv sync
17
18
  - run: uvx ruff check .
18
19
  - run: uvx ruff format --check .
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: okf-cli
3
- Version: 0.8.0
3
+ Version: 0.8.1
4
4
  Summary: Open Knowledge Format tooling
5
5
  License: MIT License
6
6
 
@@ -71,7 +71,31 @@ uv sync --extra mcp
71
71
  uv run okf serve-mcp example_knowledge_base
72
72
  ```
73
73
 
74
- The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address. The server exposes read-only `list_concepts` and `read_concept` tools. Non-local binds have no built-in authentication; use them only on a trusted network or behind an authenticated proxy.
74
+ The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address; `--host 0.0.0.0` listens on all IPv4 interfaces. The server exposes read-only `list_concepts` and `read_concept` tools. Add `--token <secret>` to require the matching `Authorization: Bearer <secret>` header on MCP requests; without it, requests are unauthenticated. For example:
75
+
76
+ ```bash
77
+ uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
78
+ ```
79
+
80
+ Use HTTPS (typically through a TLS-terminating proxy) when serving beyond localhost. The token is a command-line argument and may be visible in shell history or process listings; use this option only on a trusted network, and do not treat it as a replacement for TLS.
81
+
82
+ #### HTTPS with Caddy
83
+
84
+ When Caddy runs on the same machine, leave the MCP server bound to its default `127.0.0.1` address and let Caddy handle public HTTPS:
85
+
86
+ ```caddyfile
87
+ mcp.example.com {
88
+ reverse_proxy 127.0.0.1:8000
89
+ }
90
+ ```
91
+
92
+ Start the MCP server with authentication enabled:
93
+
94
+ ```bash
95
+ uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
96
+ ```
97
+
98
+ Clients connect to `https://mcp.example.com/mcp` and send `Authorization: Bearer <token>`. Keep port `8000` private; Caddy should be the public entry point. Caddy can provision HTTPS automatically when the domain points to the server and is reachable on the required ports.
75
99
 
76
100
  ## Quick example
77
101
 
@@ -37,7 +37,31 @@ uv sync --extra mcp
37
37
  uv run okf serve-mcp example_knowledge_base
38
38
  ```
39
39
 
40
- The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address. The server exposes read-only `list_concepts` and `read_concept` tools. Non-local binds have no built-in authentication; use them only on a trusted network or behind an authenticated proxy.
40
+ The server binds to `127.0.0.1:8000` by default and listens at `http://127.0.0.1:8000/mcp`. Use `--host` and `--port` to change the bind address; `--host 0.0.0.0` listens on all IPv4 interfaces. The server exposes read-only `list_concepts` and `read_concept` tools. Add `--token <secret>` to require the matching `Authorization: Bearer <secret>` header on MCP requests; without it, requests are unauthenticated. For example:
41
+
42
+ ```bash
43
+ uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
44
+ ```
45
+
46
+ Use HTTPS (typically through a TLS-terminating proxy) when serving beyond localhost. The token is a command-line argument and may be visible in shell history or process listings; use this option only on a trusted network, and do not treat it as a replacement for TLS.
47
+
48
+ #### HTTPS with Caddy
49
+
50
+ When Caddy runs on the same machine, leave the MCP server bound to its default `127.0.0.1` address and let Caddy handle public HTTPS:
51
+
52
+ ```caddyfile
53
+ mcp.example.com {
54
+ reverse_proxy 127.0.0.1:8000
55
+ }
56
+ ```
57
+
58
+ Start the MCP server with authentication enabled:
59
+
60
+ ```bash
61
+ uv run okf serve-mcp example_knowledge_base --token "$OKF_MCP_TOKEN"
62
+ ```
63
+
64
+ Clients connect to `https://mcp.example.com/mcp` and send `Authorization: Bearer <token>`. Keep port `8000` private; Caddy should be the public entry point. Caddy can provision HTTPS automatically when the domain points to the server and is reachable on the required ports.
41
65
 
42
66
  ## Quick example
43
67
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "okf-cli"
3
- version = "0.8.0"
3
+ version = "0.8.1"
4
4
  description = "Open Knowledge Format tooling"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -1,5 +1,6 @@
1
1
  """Serve a conformant OKF bundle over MCP Streamable HTTP."""
2
2
 
3
+ import secrets
3
4
  from pathlib import Path
4
5
  from typing import Any
5
6
 
@@ -9,7 +10,7 @@ from okf import api
9
10
  from okf.core import err_console
10
11
 
11
12
 
12
- def _create_server(bundle_dir: Path) -> Any:
13
+ def _create_server(bundle_dir: Path, token: str | None = None) -> Any:
13
14
  """Create an MCP server exposing read-only bundle tools."""
14
15
  try:
15
16
  from fastmcp import FastMCP
@@ -18,7 +19,23 @@ def _create_server(bundle_dir: Path) -> Any:
18
19
  "MCP support is not installed. Install okf-cli with the 'mcp' extra."
19
20
  ) from exc
20
21
 
21
- mcp = FastMCP(f"OKF bundle: {bundle_dir.name}")
22
+ auth = None
23
+ if token is not None:
24
+ from fastmcp.server.auth import AccessToken, TokenVerifier
25
+
26
+ class _TokenVerifier(TokenVerifier):
27
+ async def verify_token(self, provided_token: str) -> AccessToken | None:
28
+ if not secrets.compare_digest(provided_token, token):
29
+ return None
30
+ return AccessToken(
31
+ token=provided_token,
32
+ client_id="okf-cli",
33
+ scopes=[],
34
+ )
35
+
36
+ auth = _TokenVerifier()
37
+
38
+ mcp = FastMCP(f"OKF bundle: {bundle_dir.name}", auth=auth)
22
39
 
23
40
  @mcp.tool
24
41
  def list_concepts() -> list[dict[str, str]]:
@@ -44,8 +61,18 @@ def serve_mcp(
44
61
  "127.0.0.1", "--host", help="Interface to bind (default: localhost only)"
45
62
  ),
46
63
  port: int = typer.Option(8000, "--port", help="HTTP port to bind"),
64
+ token: str | None = typer.Option(
65
+ None,
66
+ "--token",
67
+ help="Require this bearer token for MCP requests",
68
+ show_default=False,
69
+ ),
47
70
  ) -> None:
48
71
  """Serve an OKF bundle over MCP Streamable HTTP."""
72
+ if token is not None and not token.strip():
73
+ err_console.print("Error: --token must not be empty", style="red")
74
+ raise typer.Exit(code=2)
75
+
49
76
  bundle_dir = directory.resolve()
50
77
  try:
51
78
  report = api.validate(bundle_dir)
@@ -62,7 +89,7 @@ def serve_mcp(
62
89
  raise typer.Exit(code=1)
63
90
 
64
91
  try:
65
- mcp = _create_server(bundle_dir)
92
+ mcp = _create_server(bundle_dir, token=token)
66
93
  except RuntimeError as exc:
67
94
  err_console.print(f"Error: {exc}", style="red")
68
95
  raise typer.Exit(code=1) from exc
@@ -28,6 +28,7 @@ def test_mcp_tools_list_and_read_concepts(tmp_path: Path):
28
28
  bundle_dir = tmp_path / "bundle"
29
29
  _write_bundle(bundle_dir)
30
30
  server = _create_server(bundle_dir)
31
+ assert server.auth is None
31
32
 
32
33
  async def call_tools():
33
34
  async with Client(server) as client:
@@ -62,17 +63,37 @@ def test_mcp_tools_list_and_read_concepts(tmp_path: Path):
62
63
  }
63
64
 
64
65
 
66
+ def test_mcp_token_authentication(tmp_path: Path):
67
+ bundle_dir = tmp_path / "bundle"
68
+ _write_bundle(bundle_dir)
69
+ server = _create_server(bundle_dir, token="secret-token")
70
+
71
+ async def verify_tokens():
72
+ assert server.auth is not None
73
+ valid = await server.auth.verify_token("secret-token")
74
+ invalid = await server.auth.verify_token("wrong-token")
75
+ return valid, invalid
76
+
77
+ valid, invalid = asyncio.run(verify_tokens())
78
+ assert valid is not None
79
+ assert invalid is None
80
+
81
+
65
82
  def test_serve_mcp_runs_streamable_http(tmp_path: Path, monkeypatch):
66
83
  bundle_dir = tmp_path / "bundle"
67
84
  _write_bundle(bundle_dir)
68
85
  run_options = {}
86
+ server_options = {}
69
87
 
70
88
  class FakeServer:
71
89
  def run(self, **kwargs):
72
90
  run_options.update(kwargs)
73
91
 
74
92
  monkeypatch.setattr(
75
- "okf.commands.serve_mcp._create_server", lambda _bundle_dir: FakeServer()
93
+ "okf.commands.serve_mcp._create_server",
94
+ lambda _bundle_dir, token=None: (
95
+ server_options.update(token=token) or FakeServer()
96
+ ),
76
97
  )
77
98
  result = runner.invoke(
78
99
  app,
@@ -83,10 +104,13 @@ def test_serve_mcp_runs_streamable_http(tmp_path: Path, monkeypatch):
83
104
  "0.0.0.0",
84
105
  "--port",
85
106
  "9000",
107
+ "--token",
108
+ "secret-token",
86
109
  ],
87
110
  )
88
111
 
89
112
  assert result.exit_code == 0, result.output
113
+ assert server_options == {"token": "secret-token"}
90
114
  assert run_options == {
91
115
  "transport": "streamable-http",
92
116
  "host": "0.0.0.0",
@@ -99,7 +123,7 @@ def test_serve_mcp_rejects_nonconformant_bundle(tmp_path: Path, monkeypatch):
99
123
  bundle_dir = tmp_path / "bundle"
100
124
  _write_bundle(bundle_dir, conformant=False)
101
125
 
102
- def fail_if_called(_bundle_dir):
126
+ def fail_if_called(_bundle_dir, token=None):
103
127
  raise AssertionError("server must not start for a non-conformant bundle")
104
128
 
105
129
  monkeypatch.setattr("okf.commands.serve_mcp._create_server", fail_if_called)
@@ -657,7 +657,7 @@ wheels = [
657
657
 
658
658
  [[package]]
659
659
  name = "okf-cli"
660
- version = "0.8.0"
660
+ version = "0.8.1"
661
661
  source = { editable = "." }
662
662
  dependencies = [
663
663
  { name = "pyyaml" },
@@ -36,18 +36,21 @@ uv run okf validate example_knowledge_base
36
36
 
37
37
  ## CI/CD
38
38
 
39
- GitHub Actions workflow: `.github/workflows/test.yml`
39
+ GitHub Actions workflows:
40
40
 
41
- Pipeline:
41
+ - `.github/workflows/test.yml` runs on pushes and pull requests: checkout, setup `uv` with Python 3.11, `uv sync`, Ruff checks, and `uv run pytest -q`.
42
+ - `.github/workflows/publish.yml` runs for tags matching `v0.*.*`. It verifies the tag is a plain `v0.x.x` version matching `project.version` in `pyproject.toml`, then runs `uv build` and `uv publish`.
42
43
 
43
- 1. checkout
44
- 1. setup `uv` with Python 3.11
45
- 1. `uv sync`
46
- 1. `uvx ruff check .`
47
- 1. `uvx ruff format --check .`
48
- 1. `uv run pytest -q`
44
+ ### PyPI publishing setup
49
45
 
50
- No deploy pipeline in repo; CI currently focused on correctness tests.
46
+ The publish workflow uses PyPI trusted publishing (GitHub Actions OIDC), so no long-lived PyPI API token is stored in GitHub. In the existing `okf-cli` project on PyPI, configure a trusted publisher with this repository's owner and name, workflow filename `publish.yml`, and no environment (unless the workflow is updated to use one).
47
+
48
+ To release, update `project.version` in `pyproject.toml`, commit that change, then push the matching tag, for example:
49
+
50
+ ```bash
51
+ git tag v0.8.1
52
+ git push origin v0.8.1
53
+ ```
51
54
 
52
55
  ## Repo artifacts and hygiene
53
56
 
@@ -32,7 +32,7 @@ uv run okf serve-mcp out
32
32
  # Default endpoint: http://127.0.0.1:8000/mcp
33
33
  ```
34
34
 
35
- The server exposes read-only `list_concepts` and `read_concept` tools. It binds to localhost by default. Binding to a non-local interface with `--host` exposes the bundle without authentication; use only on a trusted network or behind an authenticated proxy.
35
+ The server exposes read-only `list_concepts` and `read_concept` tools. It binds to localhost by default. Pass `--token <secret>` to require an `Authorization: Bearer <secret>` header on MCP requests; without it requests are unauthenticated. Use HTTPS (for example, through a TLS-terminating proxy) when serving beyond localhost. The token is passed as a command-line argument and may appear in shell history or process listings.
36
36
 
37
37
  ## Python API
38
38
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes