python-1c-mcp 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.
- python_1c_mcp-0.1.0/LICENSE +21 -0
- python_1c_mcp-0.1.0/PKG-INFO +335 -0
- python_1c_mcp-0.1.0/README.md +151 -0
- python_1c_mcp-0.1.0/README.pypi.md +307 -0
- python_1c_mcp-0.1.0/pyproject.toml +67 -0
- python_1c_mcp-0.1.0/setup.cfg +4 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/__init__.py +3 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/connection.py +130 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/entity_set.py +19 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/server.py +150 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/tools/__init__.py +1 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp/tools/handlers.py +139 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/PKG-INFO +335 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/SOURCES.txt +18 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/dependency_links.txt +1 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/entry_points.txt +2 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/requires.txt +9 -0
- python_1c_mcp-0.1.0/src/python_1c_mcp.egg-info/top_level.txt +1 -0
- python_1c_mcp-0.1.0/tests/test_connection.py +75 -0
- python_1c_mcp-0.1.0/tests/test_tools.py +83 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Artem Gulyaev
|
|
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.
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-1c-mcp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Read-only MCP server for 1C:Enterprise standard OData (8.3.5+)
|
|
5
|
+
Author-email: Artem Gulyaev <itsuppartem@yandex.ru>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/itsuppartem/python_1c_mcp
|
|
8
|
+
Project-URL: Repository, https://github.com/itsuppartem/python_1c_mcp
|
|
9
|
+
Project-URL: Issues, https://github.com/itsuppartem/python_1c_mcp/issues
|
|
10
|
+
Keywords: 1c,odata,mcp,1c-enterprise,model-context-protocol
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: python-1c-odata>=0.6.0
|
|
20
|
+
Requires-Dist: mcp>=2.0
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == "dev"
|
|
24
|
+
Requires-Dist: ruff>=0.8; extra == "dev"
|
|
25
|
+
Requires-Dist: mypy>=1.13; extra == "dev"
|
|
26
|
+
Requires-Dist: aiohttp>=3.9.0; extra == "dev"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
English | [Русский](#russkiy)
|
|
30
|
+
|
|
31
|
+
# python-1c-mcp
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/python-1c-mcp/)
|
|
34
|
+
[](https://github.com/itsuppartem/python_1c_mcp)
|
|
35
|
+
[](https://github.com/itsuppartem/python_1c_mcp/actions/workflows/test.yml)
|
|
36
|
+
[](https://github.com/itsuppartem/python_1c_mcp/blob/main/LICENSE)
|
|
37
|
+
|
|
38
|
+
Read-only [Model Context Protocol](https://modelcontextprotocol.io/) server for **1C:Enterprise standard OData** (`standard.odata`, platform **8.3.5+**).
|
|
39
|
+
|
|
40
|
+
Built on [python-1c-odata](https://github.com/itsuppartem/python_1c_odata). Exposes schema discovery and OData queries to LLM agents in Claude Desktop, Cursor, and other MCP hosts.
|
|
41
|
+
|
|
42
|
+
Homepage / repo: https://github.com/itsuppartem/python_1c_mcp
|
|
43
|
+
|
|
44
|
+
## Read-only scope
|
|
45
|
+
|
|
46
|
+
This server provides **read-only** access only:
|
|
47
|
+
|
|
48
|
+
- List and describe entity sets from `$metadata`
|
|
49
|
+
- Query entity sets (`$filter`, `$select`, `$top`, `$skip`, `$orderby`, `$inlinecount`)
|
|
50
|
+
- Fetch a single record by `Ref_Key`
|
|
51
|
+
|
|
52
|
+
There are **no** create, update, delete, post, or unpost tools.
|
|
53
|
+
|
|
54
|
+
**Honest limits:** standard OData 3.0 publication only. No 8.2, 7.7, SOAP, COM, or proprietary APIs. Oldest publication is 8.3.5 Atom (`ONEC_FORMAT=atom` or `auto`). JSON is the default (`8.3.6+`).
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install python-1c-mcp
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Python 3.10+. Depends on `python-1c-odata` 0.6.0+ and `mcp` 2.0+. From a clone:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/itsuppartem/python_1c_mcp.git
|
|
66
|
+
cd python_1c_mcp
|
|
67
|
+
pip install -e ".[dev]"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Connect to 1C
|
|
71
|
+
|
|
72
|
+
This server talks to a **published standard OData** interface on 1C:Enterprise **8.3.5+**. It does not open Designer, the thick/thin client, SOAP `/ws/`, custom HTTP services (`/hs/`), COM, 8.2, or 7.7. If OData is not published, there is no other way for this MCP to “log into 1C”.
|
|
73
|
+
|
|
74
|
+
On the 1C side:
|
|
75
|
+
|
|
76
|
+
1. Publish the infobase on the web server (Apache or IIS) from Designer: **Administration → Publish on web server**.
|
|
77
|
+
2. Enable the standard OData interface for that publication (`enableStandardOData` / the OData checkbox). The service path is `/odata/standard.odata`.
|
|
78
|
+
3. Create or pick a user who is allowed to use that publication (HTTP Basic). This is the web-service login, not an interactive Designer session.
|
|
79
|
+
|
|
80
|
+
URL shape from the four variables:
|
|
81
|
+
|
|
82
|
+
`{ONEC_SERVER}/{ONEC_INFOBASE}/odata/standard.odata`
|
|
83
|
+
|
|
84
|
+
Example: `ONEC_SERVER=http://1c.example`, `ONEC_INFOBASE=trade` → `http://1c.example/trade/odata/standard.odata`.
|
|
85
|
+
|
|
86
|
+
8.3.5 publications speak Atom only — set `ONEC_FORMAT=atom` (or `auto`). 8.3.6+ can use the default JSON.
|
|
87
|
+
|
|
88
|
+
Auth is HTTP Basic: `ONEC_USER` / `ONEC_PASSWORD` (or `user:pass@` inside `ONEC_URL`). Then add the MCP JSON below in Cursor or Claude Desktop.
|
|
89
|
+
|
|
90
|
+
## Connection (environment variables)
|
|
91
|
+
|
|
92
|
+
| Variable | Required | Description |
|
|
93
|
+
|----------|----------|-------------|
|
|
94
|
+
| `ONEC_SERVER` | Yes* | Server base URL, e.g. `http://1c.example` |
|
|
95
|
+
| `ONEC_INFOBASE` | Yes* | Publication name, e.g. `trade` |
|
|
96
|
+
| `ONEC_USER` | Yes* | OData user |
|
|
97
|
+
| `ONEC_PASSWORD` | Yes* | OData password |
|
|
98
|
+
| `ONEC_URL` | Alt. | Single URL: `http://user:pass@host/publication` (overrides the four vars above) |
|
|
99
|
+
| `ONEC_FORMAT` | No | Response format: `json` (default), `atom`, or `auto` |
|
|
100
|
+
| `ONEC_DEBUG` | No | If `true` / `1` / `yes` / `on`, log HTTP requests to stderr |
|
|
101
|
+
|
|
102
|
+
\* Either set `ONEC_URL` **or** all four of `ONEC_SERVER`, `ONEC_INFOBASE`, `ONEC_USER`, `ONEC_PASSWORD`.
|
|
103
|
+
|
|
104
|
+
The server validates configuration at startup and exits with a clear stderr message if settings are missing.
|
|
105
|
+
|
|
106
|
+
## MCP configuration
|
|
107
|
+
|
|
108
|
+
### Claude Desktop / Cursor
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
112
|
+
"mcpServers": {
|
|
113
|
+
"1c-odata": {
|
|
114
|
+
"command": "python",
|
|
115
|
+
"args": ["-m", "python_1c_mcp.server"],
|
|
116
|
+
"env": {
|
|
117
|
+
"ONEC_SERVER": "http://1c.example",
|
|
118
|
+
"ONEC_INFOBASE": "trade",
|
|
119
|
+
"ONEC_USER": "odata_user",
|
|
120
|
+
"ONEC_PASSWORD": "secret"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Alternatively, use the console script:
|
|
128
|
+
|
|
129
|
+
```json
|
|
130
|
+
{
|
|
131
|
+
"mcpServers": {
|
|
132
|
+
"1c-odata": {
|
|
133
|
+
"command": "python-1c-mcp",
|
|
134
|
+
"env": {
|
|
135
|
+
"ONEC_URL": "http://odata_user:secret@1c.example/trade"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Tools
|
|
143
|
+
|
|
144
|
+
| Tool | Parameters | Description |
|
|
145
|
+
|------|------------|-------------|
|
|
146
|
+
| `list_entity_sets` | — | All entity set names from `$metadata` (truncated after 500) |
|
|
147
|
+
| `describe_entity_set` | `entity_set` | Keys, properties, navigation for one set (e.g. `Catalog_Товары`) |
|
|
148
|
+
| `odata_query` | `entity_set`, `odata_filter`, `select`, `top`, `skip`, `orderby`, `inlinecount` | Read-only collection query. `top` default 20, max 100 |
|
|
149
|
+
| `get_entity` | `entity_set`, `ref_key`, `select` | Single record by `Ref_Key` GUID |
|
|
150
|
+
| `get_metadata` | `raw_xml` | Summary (count + sample names) or truncated raw `$metadata` XML |
|
|
151
|
+
|
|
152
|
+
## Resources
|
|
153
|
+
|
|
154
|
+
| URI | Description |
|
|
155
|
+
|-----|-------------|
|
|
156
|
+
| `1c://entity-sets` | Plain-text list of entity set names |
|
|
157
|
+
| `1c://metadata` | `$metadata` XML (truncated if large) |
|
|
158
|
+
|
|
159
|
+
## What is still missing
|
|
160
|
+
|
|
161
|
+
| Missing | Notes |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| Write tools | no create / edit / delete / post / unpost — this package is read-only |
|
|
164
|
+
| 8.2 / 7.7 / SOAP / COM / `/hs/` / OData 4 | out of scope. Oldest publication we speak is 8.3.5 Atom |
|
|
165
|
+
|
|
166
|
+
## Development
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
python -m venv .venv
|
|
170
|
+
source .venv/bin/activate
|
|
171
|
+
pip install -e ".[dev]"
|
|
172
|
+
pytest
|
|
173
|
+
ruff check src tests
|
|
174
|
+
mypy src
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## License
|
|
178
|
+
|
|
179
|
+
MIT — Artem Gulyaev
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
<h2 id="russkiy">Русский</h2>
|
|
184
|
+
|
|
185
|
+
# python-1c-mcp
|
|
186
|
+
|
|
187
|
+
[English](#python-1c-mcp) | Русский
|
|
188
|
+
|
|
189
|
+
[](https://pypi.org/project/python-1c-mcp/)
|
|
190
|
+
[](https://github.com/itsuppartem/python_1c_mcp)
|
|
191
|
+
[](https://github.com/itsuppartem/python_1c_mcp/actions/workflows/test.yml)
|
|
192
|
+
[](https://github.com/itsuppartem/python_1c_mcp/blob/main/LICENSE)
|
|
193
|
+
|
|
194
|
+
Сервер [Model Context Protocol](https://modelcontextprotocol.io/) **только для чтения** стандартного OData **1С:Предприятие** (`standard.odata`, платформа **8.3.5+**).
|
|
195
|
+
|
|
196
|
+
Собран на [python-1c-odata](https://github.com/itsuppartem/python_1c_odata). Отдаёт агентам LLM в Claude Desktop, Cursor и других MCP-хостах схему и запросы OData.
|
|
197
|
+
|
|
198
|
+
Репозиторий: https://github.com/itsuppartem/python_1c_mcp
|
|
199
|
+
|
|
200
|
+
## Область только чтения
|
|
201
|
+
|
|
202
|
+
Сервер даёт доступ **только на чтение**:
|
|
203
|
+
|
|
204
|
+
- Список и описание наборов сущностей из `$metadata`
|
|
205
|
+
- Запросы к наборам (`$filter`, `$select`, `$top`, `$skip`, `$orderby`, `$inlinecount`)
|
|
206
|
+
- Одна запись по `Ref_Key`
|
|
207
|
+
|
|
208
|
+
Инструментов создания, изменения, удаления, проведения и отмены проведения **нет**.
|
|
209
|
+
|
|
210
|
+
**Честные границы:** только стандартная публикация OData 3.0. Нет 8.2, 7.7, SOAP, COM и закрытых API. Самая старая публикация — Atom 8.3.5 (`ONEC_FORMAT=atom` или `auto`). По умолчанию JSON (`8.3.6+`).
|
|
211
|
+
|
|
212
|
+
## Установка
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
pip install python-1c-mcp
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Нужен Python 3.10+. Зависимости: `python-1c-odata` 0.6.0+ и `mcp` 2.0+. Из клона:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
git clone https://github.com/itsuppartem/python_1c_mcp.git
|
|
222
|
+
cd python_1c_mcp
|
|
223
|
+
pip install -e ".[dev]"
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Подключение к 1С
|
|
227
|
+
|
|
228
|
+
Сервер ходит в **опубликованный стандартный OData** на 1С:Предприятие **8.3.5+**. Он не открывает Конфигуратор, толстый/тонкий клиент, SOAP `/ws/`, произвольные HTTP-сервисы (`/hs/`), COM, 8.2 и 7.7. Если OData не опубликован, другим способом «войти в 1С» этот MCP не умеет.
|
|
229
|
+
|
|
230
|
+
На стороне 1С:
|
|
231
|
+
|
|
232
|
+
1. Опубликуйте информационную базу на веб-сервере (Apache или IIS) из Конфигуратора: **Администрирование → Публикация на веб-сервере**.
|
|
233
|
+
2. Включите стандартный интерфейс OData у этой публикации (`enableStandardOData` / флажок OData). Путь сервиса — `/odata/standard.odata`.
|
|
234
|
+
3. Заведите или выберите пользователя с правом на эту публикацию (HTTP Basic). Это логин веб-сервиса, не интерактивный сеанс Конфигуратора.
|
|
235
|
+
|
|
236
|
+
Форма URL из четырёх переменных:
|
|
237
|
+
|
|
238
|
+
`{ONEC_SERVER}/{ONEC_INFOBASE}/odata/standard.odata`
|
|
239
|
+
|
|
240
|
+
Пример: `ONEC_SERVER=http://1c.example`, `ONEC_INFOBASE=trade` → `http://1c.example/trade/odata/standard.odata`.
|
|
241
|
+
|
|
242
|
+
Публикации 8.3.5 говорят только Atom — задайте `ONEC_FORMAT=atom` (или `auto`). С 8.3.6 можно оставить JSON по умолчанию.
|
|
243
|
+
|
|
244
|
+
Авторизация — HTTP Basic: `ONEC_USER` / `ONEC_PASSWORD` (или `user:pass@` внутри `ONEC_URL`). Затем добавьте JSON MCP ниже в Cursor или Claude Desktop.
|
|
245
|
+
|
|
246
|
+
## Подключение (переменные окружения)
|
|
247
|
+
|
|
248
|
+
| Переменная | Обязательна | Описание |
|
|
249
|
+
|------------|-------------|----------|
|
|
250
|
+
| `ONEC_SERVER` | Да* | Базовый URL сервера, например `http://1c.example` |
|
|
251
|
+
| `ONEC_INFOBASE` | Да* | Имя публикации, например `trade` |
|
|
252
|
+
| `ONEC_USER` | Да* | Пользователь OData |
|
|
253
|
+
| `ONEC_PASSWORD` | Да* | Пароль OData |
|
|
254
|
+
| `ONEC_URL` | Альтернатива | Один URL: `http://user:pass@host/publication` (перекрывает четыре переменные выше) |
|
|
255
|
+
| `ONEC_FORMAT` | Нет | Формат ответа: `json` (по умолчанию), `atom` или `auto` |
|
|
256
|
+
| `ONEC_DEBUG` | Нет | Если `true` / `1` / `yes` / `on`, HTTP-запросы пишутся в stderr |
|
|
257
|
+
|
|
258
|
+
\* Задайте либо `ONEC_URL`, **либо** все четыре: `ONEC_SERVER`, `ONEC_INFOBASE`, `ONEC_USER`, `ONEC_PASSWORD`.
|
|
259
|
+
|
|
260
|
+
Сервер проверяет настройки при старте и выходит с понятным сообщением в stderr, если чего-то не хватает.
|
|
261
|
+
|
|
262
|
+
## Настройка MCP
|
|
263
|
+
|
|
264
|
+
### Claude Desktop / Cursor
|
|
265
|
+
|
|
266
|
+
```json
|
|
267
|
+
{
|
|
268
|
+
"mcpServers": {
|
|
269
|
+
"1c-odata": {
|
|
270
|
+
"command": "python",
|
|
271
|
+
"args": ["-m", "python_1c_mcp.server"],
|
|
272
|
+
"env": {
|
|
273
|
+
"ONEC_SERVER": "http://1c.example",
|
|
274
|
+
"ONEC_INFOBASE": "trade",
|
|
275
|
+
"ONEC_USER": "odata_user",
|
|
276
|
+
"ONEC_PASSWORD": "secret"
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
Либо консольный скрипт:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"mcpServers": {
|
|
288
|
+
"1c-odata": {
|
|
289
|
+
"command": "python-1c-mcp",
|
|
290
|
+
"env": {
|
|
291
|
+
"ONEC_URL": "http://odata_user:secret@1c.example/trade"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Инструменты
|
|
299
|
+
|
|
300
|
+
| Инструмент | Параметры | Описание |
|
|
301
|
+
|------------|-----------|----------|
|
|
302
|
+
| `list_entity_sets` | — | Все имена наборов из `$metadata` (обрезка после 500) |
|
|
303
|
+
| `describe_entity_set` | `entity_set` | Ключи, свойства, навигация одного набора (например `Catalog_Товары`) |
|
|
304
|
+
| `odata_query` | `entity_set`, `odata_filter`, `select`, `top`, `skip`, `orderby`, `inlinecount` | Запрос коллекции только на чтение. `top` по умолчанию 20, максимум 100 |
|
|
305
|
+
| `get_entity` | `entity_set`, `ref_key`, `select` | Одна запись по GUID `Ref_Key` |
|
|
306
|
+
| `get_metadata` | `raw_xml` | Сводка (число + примеры имён) или обрезанный XML `$metadata` |
|
|
307
|
+
|
|
308
|
+
## Ресурсы
|
|
309
|
+
|
|
310
|
+
| URI | Описание |
|
|
311
|
+
|-----|----------|
|
|
312
|
+
| `1c://entity-sets` | Текстовый список имён наборов |
|
|
313
|
+
| `1c://metadata` | XML `$metadata` (обрезается, если большой) |
|
|
314
|
+
|
|
315
|
+
## Чего нет
|
|
316
|
+
|
|
317
|
+
| Нет | Комментарий |
|
|
318
|
+
| --- | --- |
|
|
319
|
+
| Инструменты записи | нет create / edit / delete / post / unpost — пакет только для чтения |
|
|
320
|
+
| 8.2 / 7.7 / SOAP / COM / `/hs/` / OData 4 | вне задачи. Самая старая публикация — Atom 8.3.5 |
|
|
321
|
+
|
|
322
|
+
## Разработка
|
|
323
|
+
|
|
324
|
+
```bash
|
|
325
|
+
python -m venv .venv
|
|
326
|
+
source .venv/bin/activate
|
|
327
|
+
pip install -e ".[dev]"
|
|
328
|
+
pytest
|
|
329
|
+
ruff check src tests
|
|
330
|
+
mypy src
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
## Лицензия
|
|
334
|
+
|
|
335
|
+
MIT — Артём Гуляев
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# python-1c-mcp
|
|
2
|
+
|
|
3
|
+
English | [Русский](README.ru.md)
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/python-1c-mcp/)
|
|
6
|
+
[](https://github.com/itsuppartem/python_1c_mcp)
|
|
7
|
+
[](https://github.com/itsuppartem/python_1c_mcp/actions/workflows/test.yml)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
|
|
10
|
+
Read-only [Model Context Protocol](https://modelcontextprotocol.io/) server for **1C:Enterprise standard OData** (`standard.odata`, platform **8.3.5+**).
|
|
11
|
+
|
|
12
|
+
Built on [python-1c-odata](https://github.com/itsuppartem/python_1c_odata). Exposes schema discovery and OData queries to LLM agents in Claude Desktop, Cursor, and other MCP hosts.
|
|
13
|
+
|
|
14
|
+
Homepage / repo: https://github.com/itsuppartem/python_1c_mcp
|
|
15
|
+
|
|
16
|
+
## Read-only scope
|
|
17
|
+
|
|
18
|
+
This server provides **read-only** access only:
|
|
19
|
+
|
|
20
|
+
- List and describe entity sets from `$metadata`
|
|
21
|
+
- Query entity sets (`$filter`, `$select`, `$top`, `$skip`, `$orderby`, `$inlinecount`)
|
|
22
|
+
- Fetch a single record by `Ref_Key`
|
|
23
|
+
|
|
24
|
+
There are **no** create, update, delete, post, or unpost tools.
|
|
25
|
+
|
|
26
|
+
**Honest limits:** standard OData 3.0 publication only. No 8.2, 7.7, SOAP, COM, or proprietary APIs. Oldest publication is 8.3.5 Atom (`ONEC_FORMAT=atom` or `auto`). JSON is the default (`8.3.6+`).
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install python-1c-mcp
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Python 3.10+. Depends on `python-1c-odata` 0.6.0+ and `mcp` 2.0+. From a clone:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
git clone https://github.com/itsuppartem/python_1c_mcp.git
|
|
38
|
+
cd python_1c_mcp
|
|
39
|
+
pip install -e ".[dev]"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Connect to 1C
|
|
43
|
+
|
|
44
|
+
This server talks to a **published standard OData** interface on 1C:Enterprise **8.3.5+**. It does not open Designer, the thick/thin client, SOAP `/ws/`, custom HTTP services (`/hs/`), COM, 8.2, or 7.7. If OData is not published, there is no other way for this MCP to “log into 1C”.
|
|
45
|
+
|
|
46
|
+
On the 1C side:
|
|
47
|
+
|
|
48
|
+
1. Publish the infobase on the web server (Apache or IIS) from Designer: **Administration → Publish on web server**.
|
|
49
|
+
2. Enable the standard OData interface for that publication (`enableStandardOData` / the OData checkbox). The service path is `/odata/standard.odata`.
|
|
50
|
+
3. Create or pick a user who is allowed to use that publication (HTTP Basic). This is the web-service login, not an interactive Designer session.
|
|
51
|
+
|
|
52
|
+
URL shape from the four variables:
|
|
53
|
+
|
|
54
|
+
`{ONEC_SERVER}/{ONEC_INFOBASE}/odata/standard.odata`
|
|
55
|
+
|
|
56
|
+
Example: `ONEC_SERVER=http://1c.example`, `ONEC_INFOBASE=trade` → `http://1c.example/trade/odata/standard.odata`.
|
|
57
|
+
|
|
58
|
+
8.3.5 publications speak Atom only — set `ONEC_FORMAT=atom` (or `auto`). 8.3.6+ can use the default JSON.
|
|
59
|
+
|
|
60
|
+
Auth is HTTP Basic: `ONEC_USER` / `ONEC_PASSWORD` (or `user:pass@` inside `ONEC_URL`). Then add the MCP JSON below in Cursor or Claude Desktop.
|
|
61
|
+
|
|
62
|
+
## Connection (environment variables)
|
|
63
|
+
|
|
64
|
+
| Variable | Required | Description |
|
|
65
|
+
|----------|----------|-------------|
|
|
66
|
+
| `ONEC_SERVER` | Yes* | Server base URL, e.g. `http://1c.example` |
|
|
67
|
+
| `ONEC_INFOBASE` | Yes* | Publication name, e.g. `trade` |
|
|
68
|
+
| `ONEC_USER` | Yes* | OData user |
|
|
69
|
+
| `ONEC_PASSWORD` | Yes* | OData password |
|
|
70
|
+
| `ONEC_URL` | Alt. | Single URL: `http://user:pass@host/publication` (overrides the four vars above) |
|
|
71
|
+
| `ONEC_FORMAT` | No | Response format: `json` (default), `atom`, or `auto` |
|
|
72
|
+
| `ONEC_DEBUG` | No | If `true` / `1` / `yes` / `on`, log HTTP requests to stderr |
|
|
73
|
+
|
|
74
|
+
\* Either set `ONEC_URL` **or** all four of `ONEC_SERVER`, `ONEC_INFOBASE`, `ONEC_USER`, `ONEC_PASSWORD`.
|
|
75
|
+
|
|
76
|
+
The server validates configuration at startup and exits with a clear stderr message if settings are missing.
|
|
77
|
+
|
|
78
|
+
## MCP configuration
|
|
79
|
+
|
|
80
|
+
### Claude Desktop / Cursor
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"mcpServers": {
|
|
85
|
+
"1c-odata": {
|
|
86
|
+
"command": "python",
|
|
87
|
+
"args": ["-m", "python_1c_mcp.server"],
|
|
88
|
+
"env": {
|
|
89
|
+
"ONEC_SERVER": "http://1c.example",
|
|
90
|
+
"ONEC_INFOBASE": "trade",
|
|
91
|
+
"ONEC_USER": "odata_user",
|
|
92
|
+
"ONEC_PASSWORD": "secret"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Alternatively, use the console script:
|
|
100
|
+
|
|
101
|
+
```json
|
|
102
|
+
{
|
|
103
|
+
"mcpServers": {
|
|
104
|
+
"1c-odata": {
|
|
105
|
+
"command": "python-1c-mcp",
|
|
106
|
+
"env": {
|
|
107
|
+
"ONEC_URL": "http://odata_user:secret@1c.example/trade"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## Tools
|
|
115
|
+
|
|
116
|
+
| Tool | Parameters | Description |
|
|
117
|
+
|------|------------|-------------|
|
|
118
|
+
| `list_entity_sets` | — | All entity set names from `$metadata` (truncated after 500) |
|
|
119
|
+
| `describe_entity_set` | `entity_set` | Keys, properties, navigation for one set (e.g. `Catalog_Товары`) |
|
|
120
|
+
| `odata_query` | `entity_set`, `odata_filter`, `select`, `top`, `skip`, `orderby`, `inlinecount` | Read-only collection query. `top` default 20, max 100 |
|
|
121
|
+
| `get_entity` | `entity_set`, `ref_key`, `select` | Single record by `Ref_Key` GUID |
|
|
122
|
+
| `get_metadata` | `raw_xml` | Summary (count + sample names) or truncated raw `$metadata` XML |
|
|
123
|
+
|
|
124
|
+
## Resources
|
|
125
|
+
|
|
126
|
+
| URI | Description |
|
|
127
|
+
|-----|-------------|
|
|
128
|
+
| `1c://entity-sets` | Plain-text list of entity set names |
|
|
129
|
+
| `1c://metadata` | `$metadata` XML (truncated if large) |
|
|
130
|
+
|
|
131
|
+
## What is still missing
|
|
132
|
+
|
|
133
|
+
| Missing | Notes |
|
|
134
|
+
| --- | --- |
|
|
135
|
+
| Write tools | no create / edit / delete / post / unpost — this package is read-only |
|
|
136
|
+
| 8.2 / 7.7 / SOAP / COM / `/hs/` / OData 4 | out of scope. Oldest publication we speak is 8.3.5 Atom |
|
|
137
|
+
|
|
138
|
+
## Development
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
python -m venv .venv
|
|
142
|
+
source .venv/bin/activate
|
|
143
|
+
pip install -e ".[dev]"
|
|
144
|
+
pytest
|
|
145
|
+
ruff check src tests
|
|
146
|
+
mypy src
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## License
|
|
150
|
+
|
|
151
|
+
MIT — Artem Gulyaev
|