kleia 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.
kleia-0.1.0/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 The Kleia Authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
+ associated documentation files (the "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
9
+ following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial
12
+ portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15
+ LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
16
+ EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
18
+ USE OR OTHER DEALINGS IN THE SOFTWARE.
kleia-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: kleia
3
+ Version: 0.1.0
4
+ Summary: HTTP client adapters (CLI + stdio MCP) for a running Kleia.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Requires-Dist: httpx>=0.23.0,<1
8
+ Requires-Dist: keyring>=25
9
+ Requires-Dist: mcp>=2.2.0,<2.3
10
+ Requires-Dist: platformdirs>=4.10.0
11
+ Requires-Dist: toon-format>=1.1.0,<2
12
+ Requires-Dist: typer>=0.26.7
13
+ Requires-Python: >=3.14
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Kleia client
17
+
18
+ Command-line client and stdio MCP server for a running **Kleia** instance. Kleia is a read-only reader for an
19
+ [Open Knowledge Format](https://github.com/GoogleCloudPlatform/open-knowledge-format) (OKF) Knowledge Bundle; this
20
+ package lets coding agents and scripts read, search and list the Concepts in a bundle through it.
21
+
22
+ You need a running Kleia to point it at. This package does not include the server.
23
+
24
+ Requires Python 3.14 or newer.
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ uvx kleia --help # run without installing
30
+ pip install kleia # or install
31
+ ```
32
+
33
+ This provides two commands:
34
+
35
+ - `kleia`: the Agent CLI. Output is compact [TOON](https://github.com/toon-format) by default; commands such as
36
+ `read` take `--json` for the complete envelope.
37
+ - `kleia-mcp`: a stdio MCP server exposing the same operations as tools.
38
+
39
+ ## Connect
40
+
41
+ Save your Kleia URL once as a profile, then use any command:
42
+
43
+ ```bash
44
+ kleia configure https://kleia.example.com
45
+ kleia status
46
+ ```
47
+
48
+ If the instance requires sign-in, run `kleia login`. It opens your browser, and the sign-in is stored for the profile
49
+ (`kleia logout` removes it). A Kleia running in public mode needs no sign-in.
50
+
51
+ ## Commands
52
+
53
+ | Command | What it does |
54
+ |---|---|
55
+ | `kleia status` | Compact Source Status of the connected instance |
56
+ | `kleia list-concepts` | List the Concepts in the active bundle |
57
+ | `kleia list-readable` | List every readable file in the bundle |
58
+ | `kleia read` | Read a Concept or document by Concept ID or path |
59
+ | `kleia search "<query>"` | Search the bundle |
60
+ | `kleia relationships` | Incoming and outgoing links for one document |
61
+ | `kleia wait-until-fresh` | Block until the index is fresh |
62
+ | `kleia profiles` | Manage saved connection profiles |
63
+ | `kleia setup` | Install session integrations for Claude Code, Codex and OpenCode in the current directory |
64
+
65
+ Run `kleia <command> --help` for options.
66
+
67
+ ## MCP
68
+
69
+ Add the stdio server to an MCP client, for example:
70
+
71
+ ```json
72
+ {
73
+ "mcpServers": {
74
+ "kleia": {
75
+ "command": "uvx",
76
+ "args": ["--from", "kleia", "kleia-mcp", "--base-url", "http://127.0.0.1:8000"]
77
+ }
78
+ }
79
+ }
80
+ ```
81
+
82
+ A Kleia instance also serves MCP over HTTP at `/mcp`; use that when you would rather connect to the server directly.
83
+
84
+ ## License
85
+
86
+ MIT.
kleia-0.1.0/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Kleia client
2
+
3
+ Command-line client and stdio MCP server for a running **Kleia** instance. Kleia is a read-only reader for an
4
+ [Open Knowledge Format](https://github.com/GoogleCloudPlatform/open-knowledge-format) (OKF) Knowledge Bundle; this
5
+ package lets coding agents and scripts read, search and list the Concepts in a bundle through it.
6
+
7
+ You need a running Kleia to point it at. This package does not include the server.
8
+
9
+ Requires Python 3.14 or newer.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ uvx kleia --help # run without installing
15
+ pip install kleia # or install
16
+ ```
17
+
18
+ This provides two commands:
19
+
20
+ - `kleia`: the Agent CLI. Output is compact [TOON](https://github.com/toon-format) by default; commands such as
21
+ `read` take `--json` for the complete envelope.
22
+ - `kleia-mcp`: a stdio MCP server exposing the same operations as tools.
23
+
24
+ ## Connect
25
+
26
+ Save your Kleia URL once as a profile, then use any command:
27
+
28
+ ```bash
29
+ kleia configure https://kleia.example.com
30
+ kleia status
31
+ ```
32
+
33
+ If the instance requires sign-in, run `kleia login`. It opens your browser, and the sign-in is stored for the profile
34
+ (`kleia logout` removes it). A Kleia running in public mode needs no sign-in.
35
+
36
+ ## Commands
37
+
38
+ | Command | What it does |
39
+ |---|---|
40
+ | `kleia status` | Compact Source Status of the connected instance |
41
+ | `kleia list-concepts` | List the Concepts in the active bundle |
42
+ | `kleia list-readable` | List every readable file in the bundle |
43
+ | `kleia read` | Read a Concept or document by Concept ID or path |
44
+ | `kleia search "<query>"` | Search the bundle |
45
+ | `kleia relationships` | Incoming and outgoing links for one document |
46
+ | `kleia wait-until-fresh` | Block until the index is fresh |
47
+ | `kleia profiles` | Manage saved connection profiles |
48
+ | `kleia setup` | Install session integrations for Claude Code, Codex and OpenCode in the current directory |
49
+
50
+ Run `kleia <command> --help` for options.
51
+
52
+ ## MCP
53
+
54
+ Add the stdio server to an MCP client, for example:
55
+
56
+ ```json
57
+ {
58
+ "mcpServers": {
59
+ "kleia": {
60
+ "command": "uvx",
61
+ "args": ["--from", "kleia", "kleia-mcp", "--base-url", "http://127.0.0.1:8000"]
62
+ }
63
+ }
64
+ }
65
+ ```
66
+
67
+ A Kleia instance also serves MCP over HTTP at `/mcp`; use that when you would rather connect to the server directly.
68
+
69
+ ## License
70
+
71
+ MIT.
@@ -0,0 +1,84 @@
1
+ [project]
2
+ name = "kleia"
3
+ version = "0.1.0"
4
+ description = "HTTP client adapters (CLI + stdio MCP) for a running Kleia."
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ dependencies = [
10
+ "httpx>=0.23.0,<1",
11
+ "keyring>=25",
12
+ "mcp>=2.2.0,<2.3",
13
+ "platformdirs>=4.10.0",
14
+ "toon-format>=1.1.0,<2",
15
+ "typer>=0.26.7",
16
+ ]
17
+
18
+ [project.scripts]
19
+ kleia = "kleia.process:main"
20
+ kleia-mcp = "kleia.agent_mcp.server:main"
21
+
22
+ # -----------------------------------------------------------------------------
23
+ # Build client
24
+ # -----------------------------------------------------------------------------
25
+
26
+ [build-system]
27
+ requires = ["uv_build>=0.11.8,<0.12.0"]
28
+ build-backend = "uv_build"
29
+
30
+ # -----------------------------------------------------------------------------
31
+ # Code quality
32
+ # -----------------------------------------------------------------------------
33
+
34
+ [tool.ruff]
35
+ line-length = 120
36
+
37
+ [tool.ruff.lint]
38
+ select = ["E", "F", "W", "I", "B", "C90", "PL", "SIM", "UP", "RUF"]
39
+ # B008: Typer Option/Argument defaults. E501: Field descriptions.
40
+ ignore = ["PLC0415", "B008", "PLR2004", "E501"]
41
+
42
+ [tool.ruff.lint.per-file-ignores]
43
+ "tests/**" = ["PLR2004"]
44
+
45
+ [tool.ruff.lint.mccabe]
46
+ max-complexity = 30
47
+
48
+ [tool.ruff.lint.pylint]
49
+ max-args = 25
50
+ max-branches = 30
51
+ max-statements = 80
52
+ max-returns = 10
53
+
54
+ [tool.pyright]
55
+ venvPath = "."
56
+ venv = ".venv"
57
+ exclude = [".venv/**", "tests/**"]
58
+
59
+ # -----------------------------------------------------------------------------
60
+ # Tests
61
+ # -----------------------------------------------------------------------------
62
+
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["tests"]
65
+ addopts = "-vv"
66
+
67
+ [dependency-groups]
68
+ dev = [
69
+ "pytest>=9.1.0",
70
+ "pytest-asyncio>=0.24",
71
+ "backend",
72
+ ]
73
+
74
+ [tool.uv.sources]
75
+ backend = { path = "../backend", editable = true }
76
+
77
+ [[tool.uv.index]]
78
+ url = "https://pypi.org/simple/"
79
+ default = true
80
+
81
+ [tool.uv]
82
+ keyring-provider = "subprocess"
83
+ prerelease = "allow"
84
+ index-strategy = "unsafe-best-match"
@@ -0,0 +1 @@
1
+ """Kleia agent client: CLI and stdio MCP over the Kleia REST API."""
@@ -0,0 +1,77 @@
1
+ """Formal Agent CLI ``list-concepts`` and ``list-readable`` commands.
2
+
3
+ Both commands wrap the shared REST operations over ``GET /api/documents``.
4
+ ``list-readable`` returns that Shared Capability Contract directly.
5
+ ``list-concepts`` filters the same listing down to Concepts.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from typing import Any
11
+
12
+ from kleia import rest
13
+ from kleia.target_resolver import resolve_base_url
14
+
15
+
16
+ def run_list_concepts(
17
+ base_url: str | None,
18
+ profile: str | None = None,
19
+ *,
20
+ type_filter: str | None = None,
21
+ tags: str | None = None,
22
+ path_prefix: str | None = None,
23
+ trust_tier: str | None = None,
24
+ effective_status: str | None = None,
25
+ staleness: str | None = None,
26
+ source_resource: str | None = None,
27
+ runtime: str | None = None,
28
+ ) -> dict[str, Any]:
29
+ """Execute the formal ``list-concepts`` command and return the shared dict."""
30
+ resolved_url = resolve_base_url(base_url, profile=profile)
31
+ try:
32
+ return rest.list_concepts(
33
+ resolved_url,
34
+ type_filter=type_filter,
35
+ tags=tags,
36
+ path_prefix=path_prefix,
37
+ trust_tier=trust_tier,
38
+ effective_status=effective_status,
39
+ staleness=staleness,
40
+ source_resource=source_resource,
41
+ runtime=runtime,
42
+ profile=profile,
43
+ )
44
+ except rest.RestError as exc:
45
+ rest.raise_as_cli(exc, command="list-concepts", base_url=base_url, profile=profile)
46
+
47
+
48
+ def run_list_readable(
49
+ base_url: str | None,
50
+ profile: str | None = None,
51
+ *,
52
+ type_filter: str | None = None,
53
+ tags: str | None = None,
54
+ path_prefix: str | None = None,
55
+ trust_tier: str | None = None,
56
+ effective_status: str | None = None,
57
+ staleness: str | None = None,
58
+ source_resource: str | None = None,
59
+ runtime: str | None = None,
60
+ ) -> dict[str, Any]:
61
+ """Execute the formal ``list-readable`` command and return the shared dict."""
62
+ resolved_url = resolve_base_url(base_url, profile=profile)
63
+ try:
64
+ return rest.list_readable(
65
+ resolved_url,
66
+ type_filter=type_filter,
67
+ tags=tags,
68
+ path_prefix=path_prefix,
69
+ trust_tier=trust_tier,
70
+ effective_status=effective_status,
71
+ staleness=staleness,
72
+ source_resource=source_resource,
73
+ runtime=runtime,
74
+ profile=profile,
75
+ )
76
+ except rest.RestError as exc:
77
+ rest.raise_as_cli(exc, command="list-readable", base_url=base_url, profile=profile)
@@ -0,0 +1,10 @@
1
+ """Kleia-connected Agent MCP adapter package.
2
+
3
+ Exposes the same consumption capabilities as the ``kleia`` CLI over
4
+ the Model Context Protocol. The adapter resolves a single Kleia
5
+ backend at startup, then registers tools that call that backend over HTTP
6
+ and return JSON envelopes matching the CLI's stdout envelopes 1:1.
7
+
8
+ The ``kleia-mcp`` console script entrypoint lives at
9
+ :func:`kleia.agent_mcp.server.main`.
10
+ """