mcbp-core 0.1.6__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.
- mcbp_core-0.1.6/LICENSE +21 -0
- mcbp_core-0.1.6/PKG-INFO +81 -0
- mcbp_core-0.1.6/README.md +61 -0
- mcbp_core-0.1.6/mcbp_core/__init__.py +10 -0
- mcbp_core-0.1.6/mcbp_core/client.py +852 -0
- mcbp_core-0.1.6/mcbp_core/errors.py +124 -0
- mcbp_core-0.1.6/mcbp_core/masking.py +802 -0
- mcbp_core-0.1.6/mcbp_core/tools.py +645 -0
- mcbp_core-0.1.6/mcbp_core.egg-info/PKG-INFO +81 -0
- mcbp_core-0.1.6/mcbp_core.egg-info/SOURCES.txt +20 -0
- mcbp_core-0.1.6/mcbp_core.egg-info/dependency_links.txt +1 -0
- mcbp_core-0.1.6/mcbp_core.egg-info/requires.txt +7 -0
- mcbp_core-0.1.6/mcbp_core.egg-info/top_level.txt +1 -0
- mcbp_core-0.1.6/pyproject.toml +40 -0
- mcbp_core-0.1.6/setup.cfg +4 -0
- mcbp_core-0.1.6/tests/test_client.py +708 -0
- mcbp_core-0.1.6/tests/test_description_en.py +45 -0
- mcbp_core-0.1.6/tests/test_executors.py +255 -0
- mcbp_core-0.1.6/tests/test_masking.py +674 -0
- mcbp_core-0.1.6/tests/test_metadata_cache.py +105 -0
- mcbp_core-0.1.6/tests/test_readable_metadata.py +160 -0
- mcbp_core-0.1.6/tests/test_registry.py +141 -0
mcbp_core-0.1.6/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MCBP.PLUS
|
|
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.
|
mcbp_core-0.1.6/PKG-INFO
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcbp-core
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: Shared async HTTP client + typed errors for BAS MCBP_AI (used by backend and mcp-server)
|
|
5
|
+
Author: MCBP.PLUS
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://mcbp.plus
|
|
8
|
+
Project-URL: Repository, https://github.com/kzavrazhnyi/mcbp-mcp-server
|
|
9
|
+
Keywords: bas,1c,erp,mcbp,httpx
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Requires-Dist: httpx>=0.27
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest>=8.3; extra == "dev"
|
|
16
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
|
|
17
|
+
Requires-Dist: respx>=0.21; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff>=0.7; extra == "dev"
|
|
19
|
+
Dynamic: license-file
|
|
20
|
+
|
|
21
|
+
# mcbp-core
|
|
22
|
+
|
|
23
|
+
Async HTTP client and shared tool registry for the **BAS / 1C `MCBP_AI`** service (`/ai/v1`).
|
|
24
|
+
|
|
25
|
+
This is the engine shared by two front-ends: the [`mcbp`](https://pypi.org/project/mcbp/)
|
|
26
|
+
MCP server and a FastAPI web chat. It holds everything that knows about BAS — routes, filters,
|
|
27
|
+
response shapes, typed errors — so those front-ends hold none of it.
|
|
28
|
+
|
|
29
|
+
> **Requires a server-side component.** `mcbp-core` talks to the `MCBP_AI` HTTP service, a BSL
|
|
30
|
+
> module installed into a BAS/1C configuration through Конфігуратор. That module is licensed
|
|
31
|
+
> separately and is not part of this package. Without it there is nothing to connect to.
|
|
32
|
+
|
|
33
|
+
The MCBP+ configuration and the `MCBP_AI` service module are proprietary works of
|
|
34
|
+
**[MCBP.PLUS](https://mcbp.plus)** and are distributed separately. This MIT licence covers the
|
|
35
|
+
Python package only.
|
|
36
|
+
|
|
37
|
+
## What it gives you
|
|
38
|
+
|
|
39
|
+
- **`MCBPClient`** — one pooled `httpx.AsyncClient` over the BAS publication: HTTP Basic auth,
|
|
40
|
+
retries on `503`, an in-memory metadata cache, and an offline mock mode for tests.
|
|
41
|
+
- **Typed errors** — the `{"error": {"code", "message"}}` envelope BAS returns is mapped to
|
|
42
|
+
exception classes (`ParameterError`, `NotFoundError`, `KeyMismatchError`, `PlusRequiredError`, …),
|
|
43
|
+
so callers branch on type instead of re-parsing text.
|
|
44
|
+
- **A tool registry** — 13 `ToolSpec`s (JSON Schema + async executor) covering catalogs, documents,
|
|
45
|
+
registers, metadata introspection and the gated write routes. Both front-ends register from this
|
|
46
|
+
one list, so their surfaces cannot drift apart.
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from mcbp_core.client import ConnectionConfig, MCBPClient
|
|
52
|
+
from mcbp_core.tools import tool_specs
|
|
53
|
+
|
|
54
|
+
client = MCBPClient(ConnectionConfig(
|
|
55
|
+
base_url="http://host/base/hs/mcbp_ai", # without the /ai/v1 suffix — the client adds it
|
|
56
|
+
user="ai_service", password="***", mock=False,
|
|
57
|
+
))
|
|
58
|
+
await client.startup()
|
|
59
|
+
try:
|
|
60
|
+
rows = await client.list_catalog(type_="Номенклатура", cursor=None, limit=50, q="кабель")
|
|
61
|
+
finally:
|
|
62
|
+
await client.shutdown()
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Selecting the tools a front-end should expose:
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
read_only = tool_specs(surface="mcp") # 10 specs
|
|
69
|
+
everything = tool_specs(surface="mcp", include_write=True) # 13 specs
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Tool descriptions are Ukrainian by default; `ToolSpec.description_en` carries the English variant
|
|
73
|
+
used by the MCP surface.
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
Python 3.11+.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT — see `LICENSE`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# mcbp-core
|
|
2
|
+
|
|
3
|
+
Async HTTP client and shared tool registry for the **BAS / 1C `MCBP_AI`** service (`/ai/v1`).
|
|
4
|
+
|
|
5
|
+
This is the engine shared by two front-ends: the [`mcbp`](https://pypi.org/project/mcbp/)
|
|
6
|
+
MCP server and a FastAPI web chat. It holds everything that knows about BAS — routes, filters,
|
|
7
|
+
response shapes, typed errors — so those front-ends hold none of it.
|
|
8
|
+
|
|
9
|
+
> **Requires a server-side component.** `mcbp-core` talks to the `MCBP_AI` HTTP service, a BSL
|
|
10
|
+
> module installed into a BAS/1C configuration through Конфігуратор. That module is licensed
|
|
11
|
+
> separately and is not part of this package. Without it there is nothing to connect to.
|
|
12
|
+
|
|
13
|
+
The MCBP+ configuration and the `MCBP_AI` service module are proprietary works of
|
|
14
|
+
**[MCBP.PLUS](https://mcbp.plus)** and are distributed separately. This MIT licence covers the
|
|
15
|
+
Python package only.
|
|
16
|
+
|
|
17
|
+
## What it gives you
|
|
18
|
+
|
|
19
|
+
- **`MCBPClient`** — one pooled `httpx.AsyncClient` over the BAS publication: HTTP Basic auth,
|
|
20
|
+
retries on `503`, an in-memory metadata cache, and an offline mock mode for tests.
|
|
21
|
+
- **Typed errors** — the `{"error": {"code", "message"}}` envelope BAS returns is mapped to
|
|
22
|
+
exception classes (`ParameterError`, `NotFoundError`, `KeyMismatchError`, `PlusRequiredError`, …),
|
|
23
|
+
so callers branch on type instead of re-parsing text.
|
|
24
|
+
- **A tool registry** — 13 `ToolSpec`s (JSON Schema + async executor) covering catalogs, documents,
|
|
25
|
+
registers, metadata introspection and the gated write routes. Both front-ends register from this
|
|
26
|
+
one list, so their surfaces cannot drift apart.
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
from mcbp_core.client import ConnectionConfig, MCBPClient
|
|
32
|
+
from mcbp_core.tools import tool_specs
|
|
33
|
+
|
|
34
|
+
client = MCBPClient(ConnectionConfig(
|
|
35
|
+
base_url="http://host/base/hs/mcbp_ai", # without the /ai/v1 suffix — the client adds it
|
|
36
|
+
user="ai_service", password="***", mock=False,
|
|
37
|
+
))
|
|
38
|
+
await client.startup()
|
|
39
|
+
try:
|
|
40
|
+
rows = await client.list_catalog(type_="Номенклатура", cursor=None, limit=50, q="кабель")
|
|
41
|
+
finally:
|
|
42
|
+
await client.shutdown()
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Selecting the tools a front-end should expose:
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
read_only = tool_specs(surface="mcp") # 10 specs
|
|
49
|
+
everything = tool_specs(surface="mcp", include_write=True) # 13 specs
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Tool descriptions are Ukrainian by default; `ToolSpec.description_en` carries the English variant
|
|
53
|
+
used by the MCP surface.
|
|
54
|
+
|
|
55
|
+
## Requirements
|
|
56
|
+
|
|
57
|
+
Python 3.11+.
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT — see `LICENSE`.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""mcbp-core — shared BAS MCBP_AI HTTP client, typed errors, and tool registry.
|
|
2
|
+
|
|
3
|
+
No dependency on any specific host application (backend FastAPI app, mcp-server, ...).
|
|
4
|
+
Consumers build a `ConnectionConfig` from their own settings and pass it to `MCBPClient`;
|
|
5
|
+
`mcbp_core.tools.tool_specs()` gives every caller the same `ToolSpec` registry: 13 tools, of
|
|
6
|
+
which the 10 read-only ones are returned by default. `include_write=True` adds `write_object`,
|
|
7
|
+
`save_context` and `patch_object`; `surface=` narrows the list to one front-end.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
__version__ = "0.1.6"
|