mcp
v0.12.0MCP server for @1c-odata: read-only schema introspection and data queries against 1С:Enterprise OData V3 bases.
MCP (Model Context Protocol) server for 1С:Enterprise REST/OData V3 bases, built on @1c-odata/client and @1c-odata/metadata. Works against any 1С base at runtime via the live $metadata (dynamic mode) — no code generation required. A call the MCP client cancels (notifications/cancelled) aborts the HTTP requests to 1С it has in flight — query, get_entity, count and register_query hand the request's abort signal to each of them, the parallel /$count included; add_connection and set_credentials abort the $metadata download that verifies the credentials, and store nothing unless their write…
Summary extracted from the README.
@1c-odata/mcp
MCP (Model Context Protocol) server for 1С:Enterprise
REST/OData V3 bases, built on @1c-odata/client and @1c-odata/metadata.
Read-only data access. It exposes schema introspection and data queries — no create / update / delete of
1С data. Connections can be managed from the CLI (recommended — the password is typed with no echo) or via the
add_connection / set_credentials / set_label / remove_connection tools. No tool ever returns a stored
password.
Works against any 1С base at runtime via the live $metadata (dynamic mode) — no code generation required.
Tools
| Tool | Purpose |
|---|---|
server_info |
This server's version, data directory, and connection count. No passwords. |
list_connections |
Configured connections (name, label, base URL, login, timezone, password source). No passwords. |
refresh_metadata |
Drop the cached $metadata for a connection and re-download it. |
list_entities |
Entity sets, filtered by kind (catalog / document / register / …) and a name substring. Paginated. |
describe_entity |
One entity: properties (type / nullable / maxLength), keys, navigation properties, value storages, kind. |
list_enums |
Enumeration types and their members. |
query |
Read-only OData query: raw $filter, $select, $expand, $orderby, $top/$skip, optional count — the total from the set's /$count (same $filter, $select and $expand) in a parallel request, never $inlinecount. On a register virtual table in the path with select, 1С counts the rows rolled up by it; where it returns them un-rolled (production УТ bases) the count is below the rows — page while hasMore holds rather than by the count. |
get_entity |
Fetch a single entity by Ref_Key. |
count |
Count rows matching an optional $filter. |
register_query |
Register virtual tables: balance / turnovers / slices / accounting (read-only analytics). select picks fields and, on the aggregating tables of some 1С configurations (БП turnovers — not УТ ТоварыНаСкладах balance), also rolls the rows up; filter narrows the resulting rows; orderBy sorts on the server (with top — a top-N). Paged by 1С itself: each call reads one page (skip / top) and, in a parallel request, 1С's total (with select, rolled up — below the rows where 1С returns them un-rolled); on a big table a page still costs seconds, since 1С computes the whole virtual table every time. |
add_connection |
Add a connection, or update one keeping its base URL and login (writes config; serverTimezone required for a new connection, no default; optional label + password; password stored securely, never returned). Never re-points an existing connection; one it creates never takes ONEC_<NAME>_PASSWORD. |
set_credentials |
Change a connection's login and/or password in place (keeps URL/timezone/label; password never returned). |
set_label |
Set or clear a connection's display label (empty clears it → falls back to the name). |
remove_connection |
Remove a connection and delete its stored password. |
A call the MCP client cancels (notifications/cancelled) aborts the HTTP requests to 1С it has in flight —
query, get_entity, count and register_query hand the request's abort signal to each of them, the
parallel /$count included; add_connection and set_credentials abort the $metadata download that verifies the
credentials, and store nothing unless their write had already begun. The first $metadata download of a connection is not aborted: every call waiting on
that connection shares it.
serve exits once the MCP client closes its end of stdin (the MCP stdio shutdown signal): the calls still running are
aborted with their requests to 1С, unanswered, and so are the connection pool's $metadata downloads in flight. A script feeding requests
through a pipe keeps stdin open until its last answer has come.
Quick start
1. Add a connection (in a terminal)
$ npx @1c-odata/mcp add my-base
Base URL: https://your-1c-host/base/odata/standard.odata/
Login: your-user
Password: ******** # typed with no echo — never stored in shell history or argv
Server timezone (IANA, e.g. Europe/Moscow): Europe/Moscow # required — no default
Label (optional, shown in lists):
Verifying connection… OK
✓ Connection "my-base" saved.
config: ~/.config/1c-odata/config.json
password: OS keychain
The installed binary is 1c-odata-mcp (the name the tool prints in its own hints); the npx @1c-odata/mcp <cmd>
form shown here is the no-install equivalent. Other commands: list (no passwords), remove <name>,
test <name>, label <name> [label] (set/clear the display label), and set-credentials <name> (rotate the
login and/or password — e.g. set-credentials my-base --password-stdin <<<"$NEW").
Non-interactive (scripts / CI) — pass --url to skip the prompts; --timezone is then required. There is no
default zone: the server's IANA timezone decides how every DateTime is read and written, and a wrong one shifts
them all silently. So add and add_connection require it for a new connection and for one moved to another
base URL; an overwrite keeping the base URL (--force, overwrite) keeps the stored zone when none is given.
# password from stdin (not visible in `ps`):
npx @1c-odata/mcp add my-base --url https://host/base/odata/standard.odata/ --login user --timezone Europe/Moscow --password-stdin <<<"$PW"
# or store only the non-secret config and supply the password via env at runtime:
ONEC_MY_BASE_PASSWORD=… npx @1c-odata/mcp add my-base --url https://host/base/odata/standard.odata/ --login user --timezone Europe/Moscow
The interactive add (no --url) needs a real terminal; in a non-TTY context (CI, an agent) it errors and
points you here. An env-supplied password is verified but not copied to storage — keep
ONEC_<NAME>_PASSWORD exported in the environment that runs serve, not only during add. While it is set it
outranks a stored password, so pointing that connection at another base URL or login (add --force,
add_connection with overwrite), storing a password for it and changing its credentials (set-credentials,
set_credentials) are refused — the env password would otherwise go to the new target, or the change would never be
used; unset the variable first. An agent cannot create a connection under a name whose password is in such a variable
(add_connection refuses it): that one is added through the CLI add.
Where an agent may send a password. Every MCP process shares one data directory, while
ONEC_<NAME>_PASSWORD is set per process — an agent in a process without the variable could otherwise write a
target that a process holding it would send the password to. So, whatever its own environment holds:
add_connectionnever points an existing connection at another base URL or login; a person re-points one with the CLIadd <name> --force. An overwrite keeping both (a timezone, a label, a password) is taken.- A connection
add_connectioncreates — a new name, or one re-created afterremove_connection— is marked"addedBy": "agent"inconfig.json, and never takes its password fromONEC_<NAME>_PASSWORD, in any process: give it a password throughadd_connection/set_credentials, or have a person re-add it with the CLIadd --force, which drops the mark.listandlist_connectionsshow the mark. - Such a connection also reads only a password stored for its own server: it is stored under
<name>@<16 hex of sha256(base URL)>(keychain account andcredentials.jsonkey), apart from a person's connection of that name (<name>+<…>, below). A password a person stored — even one aremove_connectioncould not delete from the keychain — is never read for it, nor one stored for another server. - Mixed versions: an MCP process older than this rule neither writes nor keeps the mark — update every process that shares the data directory.
2. Register the server with your MCP client
Add to your client config — .mcp.json (project), ~/.claude.json, or claude_desktop_config.json:
{
"mcpServers": {
"1c-odata": {
"command": "npx",
"args": ["-y", "@1c-odata/mcp", "serve"]
}
}
}
For a custom agent that can't reach the OS keychain, ship a predefined data dir and pass each connection's
password through the env block — reference a variable your shell / secret manager exports rather than a
literal secret in a committed file (${VAR} expansion is supported by Claude Code; other clients may need the
value inlined or their own secret mechanism):
{
"mcpServers": {
"1c-odata": {
"command": "npx",
"args": ["-y", "@1c-odata/mcp", "serve"],
"env": {
"ONEC_MCP_DATA_DIR": "/abs/path/to/agent-data-dir",
"ONEC_MY_BASE_PASSWORD": "${ONEC_MY_BASE_PASSWORD}"
}
}
}
}
Connections load lazily — serve starts instantly and downloads a base's $metadata only on first use, so a
predefined config.json plus ONEC_<NAME>_PASSWORD env vars is enough; nothing connects at boot.
TLS and proxy settings are Node's process-wide env vars (see the root README's
Network configuration), so for the server they belong in the same env
block — the MCP client starts serve without your shell profile, and an export there never reaches it. For a 1С
base behind a corporate / Active Directory CA, trust the OS certificate store, where a domain-joined machine
usually has that CA already — or name the CA file instead with "NODE_EXTRA_CA_CERTS": "/abs/path/to/corp-ca.pem":
"env": {
"NODE_USE_SYSTEM_CA": "1"
}
A connection that fails at the network level reports the underlying cause, e.g.
Network error: fetch failed (UNABLE_TO_GET_ISSUER_CERT_LOCALLY: unable to get local issuer certificate).
Then ask the assistant to list_connections, explore the schema, and query data.
Where data lives
Both files live in one agent-independent data directory, so a connection added once is shared by every
MCP client (Claude Code, Claude Desktop, Codex, ChatGPT, …) — they all spawn the same serve process and
resolve the same directory. Resolution order (first non-blank wins; the result must be absolute — a
relative --data-dir / ONEC_MCP_DATA_DIR is a hard error, not a silent fallback; on Windows that includes a
drive-relative \onec, which needs a drive letter or a UNC prefix):
- the
--data-dir <path>flag, $ONEC_MCP_DATA_DIR(env override — sandboxed / portable / CI),- the per-user default —
~/.config/1c-odataon macOS and Linux (honoring an absolute$XDG_CONFIG_HOME) or%APPDATA%\1c-odataon Windows. macOS deliberately uses the XDG~/.configpath, not~/Library/Application Support, for cross-platform / container consistency.
--data-dir and ONEC_MCP_DATA_DIR may start with your home directory — a bare ~, ~/…, or on Windows also
~\… — and the server expands it itself. That matters because MCP clients launch serve without a shell, so
nothing else would expand ~ in their args / env:
"args": ["-y", "@1c-odata/mcp", "--data-dir", "~/.config/1c-odata-work", "serve"]
~/x and its absolute spelling are the same directory and the same keychain namespace. ~user/… and $HOME
are not expanded and stay a "not absolute" error.
config.json— connection descriptors without passwords (base URL, login, timezone, optional display label, optional shape,"addedBy": "agent"on a connection an agent added, and"passwordKey": "target"on a person's connection whose password is keyed to its server — see below). Safe to read / surface to an LLM.shapeis written by hand (no command takes it); an overwrite (add --force,add_connectionwithoverwrite) keeps it, as it keeps the label.- Passwords — stored in the OS keychain, or in
credentials.jsonwhere it refuses; resolved in priority order env →credentials.json(0600) → OS keychain:ONEC_<NAME>_PASSWORDalways wins — use it for CI / secret managers / agent configs — except on a connection an agent added ("addedBy": "agent"), which never takes it. The name is the connection name upper-cased with every run of non-[A-Z0-9]characters collapsed to a single_(leading/trailing_stripped):my-base→ONEC_MY_BASE_PASSWORD,tvip-trade→ONEC_TVIP_TRADE_PASSWORD,bp_v3→ONEC_BP_V3_PASSWORD.- OS keychain (
@napi-rs/keyring, an optional dependency) — the entry is namespaced per data directory: service1c-odata:<data-dir basename>:<first 8 hex of sha256(canonical data dir)>, with the account keyed to the connection's server — the same keycredentials.jsonuses:<name>+<16 hex of sha256(base URL)>for a connection a person added (e.g. service1c-odata:1c-odata:7149e725, accounttrade+3f2a…),<name>@<the same hash>for one an agent added. A password is therefore only ever read for the server it was stored for: a copy a locked keychain kept, or one another process could not delete, never reaches a server the connection was re-pointed to. The base URL here is the connection's target: no userinfo, scheme and host lower-cased, a default port (:80,:443) and a trailing/dropped, the path as written. A person's connection added before this scheme keeps its password under the bare<name>(nopasswordKeyinconfig.json); the next change of it on the same server — an overwrite,set-credentials— moves the password to the server's key, in the backend it is in (where this process cannot read it —--insecure-storage, a keychain refusing — it stays under<name>). A re-point to another server or login without a password leaves the connection without one: the old password is deleted afterconfig.jsonis saved, and where it would still be read (the same server's key, or<name>) and a locked keychain refuses the delete, the change is undone and refused. Canonical = the absolute path resolved (./..collapsed), lower-cased on Windows. The basename and account are human-readable hints in Keychain Access / Credential Manager; the hash isolates dirs. Two clients on the same data dir share the secret; a different--data-dir/ONEC_MCP_DATA_DIRis a separate namespace. credentials.json(0600) — the fallback when the keychain is unavailable (headless Linux / CI) or--insecure-storageis passed; it lives inside the data dir and is loud about the downgrade. On non-Windows a credentials file with permissions looser than0600is refused on read (with achmod 600hint) so its plaintext is never loaded — and, the file being read before the keychain, that refusal stops every stored password from resolving, keychain ones included. The file comes before the keychain because it holds a password only where the keychain refused the newest write: a write the keychain takes deletes the file copy (and fails where it cannot), so an older copy the keychain still keeps — one a locked keychain or another process (--insecure-storage, no keychain backend) could not delete — never outranks it.
.lock— present only while a process changes connections (add,remove,set-credentials,labeland their MCP tools). Every process sharing the data dir takes it around the whole change —config.jsonand the password together — so concurrent changes from several MCP clients and the CLI never overwrite each other. A change waits up to 10 s for it, then fails naming the process that holds it. A lock left by a process that died is taken over on its own: at once where that process ran on this host, after 60 s where it cannot be checked (another host, another container's pid namespace); one whose pid another program has since taken stays until you delete it, as the error says. Reads never take it. Only processes of a version that takes the lock respect it: after upgrading, restart the MCP clients, so no older server keeps writing without it.
Connection names are an ASCII alias — a letter or digit first, then letters, digits, -, _
(/^[A-Za-z0-9][A-Za-z0-9_-]*$/); a Cyrillic 1С base name needs such an alias. Because the env-var slug
collapses - and _ to the same _, two names differing only in -/_ (e.g. a-b and a_b) would map to
one ONEC_A_B_PASSWORD — add rejects the colliding second name, so pick a distinct one.
Upgrading from ≤ 0.4.x. Keychain secrets are now namespaced per data directory (see above). A password stored by an earlier version under the old flat
1c-odataservice is not migrated and won't be found —listreports its source asnone. Re-add it (1c-odata-mcp add <name>) or exportONEC_<NAME>_PASSWORD.config.json,credentials.json, and env passwords are unaffected. Likewise, moving the data dir re-hashes the keychain service and orphans keychain-stored secrets — thecredentials.jsonfile travels with the dir and env passwords are independent, so both survive a move.
Paging
query and register_query page with skip / top; page on while pagination.hasMore holds, the next skip being
pagination.skip + pagination.returned (the byte budget may return fewer rows than top). A page 1С's answer
leaves unplaced carries pagination.ambiguous (absent otherwise) and ends the paging: "skipIgnoredOrCountShort" — at a
skip, 1С sent as many rows as it counted (or, ignoring $top, more), so it either ignored $skip or counts fewer rows
than it has; "skipUnverified" (query only) — at a skip, 1С ignored $top and no count was asked for. Such a page is
not to be joined to the pages before it: narrow the request instead.
Output size
Every read tool keeps its result within a byte budget so a large query can't overflow the model's context:
row sets are truncated to a usable sample (the response carries truncated / hasMore and a hint to narrow
the request), and an oversized individual field (e.g. a base64 ValueStorage) is capped with a marker. One
row is always returned even if it alone exceeds the budget, so you still see the shape (narrow with select
or compact); get_entity instead refuses an over-budget entity and points you to query + $select. Tune
it with env vars (all optional):
| Variable | Default | Meaning |
|---|---|---|
ONEC_MCP_DEFAULT_TOP |
50 |
Page size when a call omits top. |
ONEC_MCP_MAX_TOP |
1000 |
Hard ceiling on a call's top. |
ONEC_MCP_MAX_BYTES |
24000 |
Per-result byte budget for the returned rows. |
Pass compact: true to query / get_entity / register_query to also drop 1С *_Type annotation
companions (and @odata noise) and fit more rows per response. Caveat: that also removes composite-type
discriminators such as Value_Type / Ref_Type, so omit it when you need to know which entity a *_Key
references.
Security
- No tool ever returns a stored password.
list_connectionsshows only where each password lives. - Prefer the CLI for entering a password (no-echo prompt) or the
ONEC_<NAME>_PASSWORDenv var, so the secret never reaches the model's context, the transcript, orps. - The MCP
add_connection/set_credentialstools accept an optionalpassword, but passing it there places it in the model context/transcript — omit it (and use the CLI/env) unless you accept that trade-off. - All tool output and error text is redacted of URL userinfo;
config.jsoncarries no secrets; the fallback credentials file is0600and lives outside the project.