Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .ci/governance-lock.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
{
"toolset_version": "1.0",
"toolset_version": "2.0",
"canonical_tools": [
"evo.content.search",
"evo.content.get",
"evo.content.root_tree",
"evo.content.descendants",
"evo.content.tree",
"evo.content.ancestors",
"evo.content.children",
"evo.content.siblings",
"evo.model.list",
"evo.model.get"
"evo.model.get",
"evo.elements.list",
"evo.elements.get",
"evo.write.content.update",
"evo.write.content.create",
"evo.write.content.publish",
"evo.write.elements.save",
"evo.write.cache.clear"
],
"spec_version": "1.0-contract",
"spec_version": "2.0-contract",
"runtime_status": "Gate C baseline validated in demo runtime; RC-1 hardening pending",
"spec_public_contract_hash": "752772e83d65c41fe55bd6ddef3359a8ab04f0e3efe67d4901e79870d1967e7b",
"model_allowlists_hash": "4aed463f34f34da8231a6499bd58bcc11755d0bdb9bb69f86d9610b51e92b42d",
"golden_fixtures_hash": "d015d5fdab8c8f2f5267cdf47046e6580c730edc7c50cc4515eb4dfd2265c147",
"updated_at": "2026-09-29T11:20:48+00:00"
"golden_fixtures_hash": "f00e4c054f00221cb2087bfaf9aafa32481b6c0d576672fde8556506d1536aea",
"updated_at": "2026-11-18T07:39:01+00:00"
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased — Toolset 2.0

- Canonical tools: consolidated navigation into tree and siblings, with 14 Evo tools in discovery.
- Published input and output schemas now describe supported filters, TV projection and result envelopes.
- Document updates are atomic with TVs and explicitly enforce publication permissions.

## [Unreleased]
### Added
- Personal access tokens (`auth.mode = pat`, now the default): `emcp_tokens` table, `Authorization: Bearer emcp_...` endpoint at `/{api_prefix}/{server}` without sApi, self-service **Tools → MCP tokens** manager page, `emcp:token:create|list|revoke` commands.
Expand Down
13 changes: 3 additions & 10 deletions DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Contract boundary:
- `OPERATIONS.md` is the day-2 operator runbook (profiles, health checks, triage).

Status marker:
- Contract target: `SPEC 1.0-contract`.
- Contract target: `SPEC 2.0-contract`.
- Runtime baseline in current repository: `Gate C baseline implemented (full validation pending)`.

## 1) Overview
Expand Down Expand Up @@ -376,18 +376,11 @@ Canonical source for tool names/params/examples/errors is `TOOLSET.md`.
Primary domain profile is document tree access via `SiteContent`:
- `evo.content.search`
- `evo.content.get`
- `evo.content.root_tree`
- `evo.content.descendants`
- `evo.content.tree`
- `evo.content.ancestors`
- `evo.content.children`
- `evo.content.siblings`

Optional (implemented) tree tools:
- `evo.content.neighbors`
- `evo.content.prev_siblings`
- `evo.content.next_siblings`
- `evo.content.children_range`
- `evo.content.siblings_range`
[Toolset 2.0 migration](TOOLSET.md#migration-from-toolset-10).

TV support is part of the contract:
- `with_tvs` maps to `withTVs`
Expand Down
13 changes: 3 additions & 10 deletions DOCS.uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Contract boundary:
- `OPERATIONS.md` є day-2 runbook для операторів (profiles, health checks, triage).

Status marker:
- Цільовий контракт: `SPEC 1.0-contract`.
- Цільовий контракт: `SPEC 2.0-contract`.
- Runtime baseline в поточному репозиторії: `Gate C baseline implemented (full validation pending)`.

## 1) Огляд
Expand Down Expand Up @@ -376,18 +376,11 @@ tool задає сам, зберігаються). Це підказки для
Головний доменний профіль: робота з деревом документів через `SiteContent`:
- `evo.content.search`
- `evo.content.get`
- `evo.content.root_tree`
- `evo.content.descendants`
- `evo.content.tree`
- `evo.content.ancestors`
- `evo.content.children`
- `evo.content.siblings`

Опційні (вже реалізовані) tree tools:
- `evo.content.neighbors`
- `evo.content.prev_siblings`
- `evo.content.next_siblings`
- `evo.content.children_range`
- `evo.content.siblings_range`
[Toolset 2.0 migration](TOOLSET.md#migration-from-toolset-10).

Підтримка TV входить у контракт:
- `with_tvs` мапиться на `withTVs`
Expand Down
23 changes: 22 additions & 1 deletion OPERATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This runbook is for operators of eMCP environments.
It complements `DOCS.md`/`DOCS.uk.md` with day-2 operational checks.

## 0) Runtime Status Marker
- Target profile: `SPEC 1.0-contract`.
- Target profile: `SPEC 2.0-contract`.
- Current runtime baseline: `Gate C baseline implemented`.
- Meaning: manager/API transport path and async dispatch endpoints are implemented; production hardening and full integration coverage remain in progress.

Expand Down Expand Up @@ -217,3 +217,24 @@ Optional live sTask lifecycle proof:
- `EMCP_STASK_WORKER_CMD="php artisan stask:worker"`
- `EMCP_STASK_WORKER_CWD="/path/to/evo/core"`
- optional `EMCP_STASK_POLL_ATTEMPTS` (default: `20`).

## Toolset 2.0 on a disposable SQLite demo

The migration from toolset 1.0 is in [TOOLSET.md](TOOLSET.md#migration-from-toolset-10).
Install eMCP and DocumentManager 1.1 or later. To exercise a local pre-release pair,
use Composer path repositories for both checkouts and assign the DocumentManager
checkout version 1.1.0 in the path repository's options.versions.

For the write and migration regression test, start the demo web process on
loopback with PAT auth and write tools enabled. Issue a local admin PAT with
mcp:read, mcp:call and mcp:write. The test creates fixtures and triggers in the
database. Run it only on a disposable installation:

```sh
EMCP_LOCAL_MUTATION_TEST=1 \
EMCP_LOCAL_MCP_URL=http://127.0.0.1:8787/mcp/content \
EMCP_LOCAL_SQLITE=/absolute/path/to/demo.sqlite \
EMCP_LOCAL_CORE=/absolute/path/to/demo/core \
EMCP_LOCAL_ADMIN_TOKEN="$DEMO_PAT" \
composer run test:integration:toolset-v2
```
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,8 @@ eMCP is the MCP platform layer for the Evo ecosystem:
This keeps the core declarative and neutral: one MCP foundation for multiple orchestration concepts.

## Evo Domain Tools
- Implemented now: `evo.content.search|get|root_tree|descendants|ancestors|children|siblings`
- Optional (implemented): `evo.content.neighbors|prev_siblings|next_siblings|children_range|siblings_range`
- Implemented now: `evo.content.search|get|tree|ancestors|siblings`
- [Migration from toolset 1.0](TOOLSET.md#migration-from-toolset-10).
- TV-aware queries via structured `with_tvs`, `tv_filters`, `tv_order`
- `evo.model.list|get` implemented with per-model explicit allowlist projection and sensitive-field defense-in-depth blacklist

Expand Down
4 changes: 2 additions & 2 deletions README.uk.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ eMCP є MCP platform layer для екосистеми Evo:
Це дає нейтральну декларативну основу: один MCP фундамент для різних orchestration-концепцій.

## Evo Domain Tools
- Реалізовано зараз: `evo.content.search|get|root_tree|descendants|ancestors|children|siblings`
- Опційні (вже реалізовані): `evo.content.neighbors|prev_siblings|next_siblings|children_range|siblings_range`
- Реалізовано зараз: `evo.content.search|get|tree|ancestors|siblings`
- [Перенесення старих викликів](TOOLSET.md#migration-from-toolset-10).
- TV-aware запити через структуровані `with_tvs`, `tv_filters`, `tv_order`
- `evo.model.list|get` реалізовано з явним per-model allowlist projection і додатковим sensitive blacklist захистом

Expand Down
27 changes: 8 additions & 19 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Цей документ фіксує **обовʼязкові технічні контракти** для реалізації `eMCP`.

Status markers:
- `SPEC Version`: `1.0-contract`
- `SPEC Version`: `2.0-contract`
- `Runtime Status`: `Gate C baseline validated in demo runtime; RC-1 hardening pending`

Normative hierarchy:
Expand All @@ -16,11 +16,11 @@ Current validation snapshot (2026-03-03):
- `make demo-all` PASS (install + smoke + runtime integration).
- `php artisan emcp:test` PASS for `initialize` and `tools/list`.
- Runtime HTTP integration PASS for `/api/v1/mcp/{server}`.
- Verified content-read tool flow in runtime (`evo.content.search`, `evo.content.root_tree`, `evo.content.get`).
- Verified content-read tool flow in runtime (`evo.content.search`, `evo.content.tree`, `evo.content.get`).
- One-click verification writes `demo/logs.md` with request/response evidence, negative transport/security probes (`401/403/413/415/409/429`) and model-safety sanity (`evo.model.get(User)` without sensitive fields).
- `demo/logs.md` also captures local `sTask` lifecycle proof (`queued -> completed`) in demo runtime.
- CI/local test baseline now includes: `ScopePolicy`/`ServerRegistry` unit checks, async failover behavior checks, SiteContent tree/TV contract checks, security guardrail checks, docs/config/commands consistency checks, upstream adapter smoke checks.
- Optional advanced tree tools (`neighbors`, `prev/next siblings`, `children/siblings range`) are implemented and covered by contract/runtime integration tests.
- Tree and sibling modes are defined in TOOLSET.md for version 2.0.
- Streaming policy now enforces proxy/FPM-safe SSE headers (`Content-Type: text/event-stream`, `Cache-Control: no-cache, no-transform`, `X-Accel-Buffering: no`) with dedicated tests.
- CI includes migration matrix automation for `sqlite/mysql/pgsql`.
- CI/check flow now produces reproducible benchmark and leaderboard artifacts.
Expand Down Expand Up @@ -535,7 +535,7 @@ Safety:
`initialize` response MUST include:
- `serverInfo.platform = "eMCP"`.
- `serverInfo.platformVersion = <current-package-version>`.
- `capabilities.evo.toolsetVersion = "1.0"` (or current toolset version).
- `capabilities.evo.toolsetVersion = "2.0"` (or current toolset version).
- This metadata is part of the public contract and required for version-aware ecosystem integrations.
- Missing metadata is a breaking contract change.

Expand Down Expand Up @@ -577,26 +577,15 @@ The project MUST NOT mix styles for the same failure class.
`eMCP` MUST ship (or provide canonical stubs for) tool names:
- `evo.content.search`
- `evo.content.get`
- `evo.content.root_tree`
- `evo.content.descendants`
- `evo.content.tree`
- `evo.content.ancestors`
- `evo.content.children`
- `evo.content.siblings`

Behavior mapping to Evo model API:
- `evo.content.search` -> `SiteContent` query + optional `scopeActive|scopePublished|scopeWithoutProtected|scopeWithTVs|scopeTvFilter|scopeTvOrderBy|scopeTagsData|scopeOrderByDate`.
- `evo.content.root_tree` -> `scopeGetRootTree(depth)` + `withTVs(..., ':', true)` + `toTree`.
- `evo.content.descendants` -> `scopeDescendantsOf(id)` (optional depth cap via `where('depth', '<', maxDepth + 1)`).
- `evo.content.tree` uses closure-table descendants for deeper traversal and direct parent selection for one level.
- `evo.content.ancestors` -> `scopeAncestorsOf(id)` + default `orderBy('depth', 'desc')`.
- `evo.content.children` -> direct children (`parent = id`) or `getChildren()`.
- `evo.content.siblings` -> `scopeSiblingsOf(id)` and related sibling selectors when requested.

Advanced optional tools (implemented, non-canonical):
- `evo.content.neighbors` -> `scopeNeighborsOf(id)`.
- `evo.content.prev_siblings` -> `scopePrevSiblingsOf(id)`.
- `evo.content.next_siblings` -> `scopeNextSiblingsOf(id)`.
- `evo.content.children_range` -> `scopeChildrenRangeOf(id, from, to)`.
- `evo.content.siblings_range` -> `scopeSiblingsRangeOf(id, from, to)`.
- `evo.content.siblings` resolves the visible anchor and uses its parent and (menuindex, ID) for selection.

## 10.3 `SiteContent` request/validation contract
Input for `evo.content.*` MUST be structured JSON (not raw SQL fragments):
Expand Down Expand Up @@ -835,7 +824,7 @@ Required keys:
- GET returns 405.
- `tools/list`, `resources/read`, `tools/call` contracts.
- Streaming response headers/content type.
- `evo.content.search/get/root_tree/descendants/ancestors` on real `SiteContent`.
- `evo.content.search/get/tree/ancestors/siblings` on real `SiteContent`.
- TV filters/order and default TV fallback (`:d`) on controlled fixtures.
- Trace id propagation from request -> response -> audit.
- Golden fixtures for canonical tools (`initialize`, `tools/list`, `evo.content.search`, `evo.content.get`) MUST pass in CI.
Expand Down
89 changes: 60 additions & 29 deletions TOOLSET.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# TOOLSET — eMCP Canonical Tool Contract v1
# TOOLSET — eMCP Canonical Tool Contract v2

## 1. Scope
This file defines the public contract for eMCP domain tools.

Contract id:
- `platform`: `eMCP`
- `toolsetVersion`: `1.0`
- `toolsetVersion`: `2.0`

Normative relation:
- `SPEC.md` defines platform/runtime rules.
Expand All @@ -22,33 +22,35 @@ Normative relation:
`initialize` response MUST include:
- `serverInfo.platform = "eMCP"`
- `serverInfo.platformVersion = "<package-version>"`
- `capabilities.evo.toolsetVersion = "1.0"`
- `capabilities.evo.toolsetVersion = "2.0"`

This platform metadata is part of the public v1 contract.
This platform metadata is part of the public contract.
Absence or incompatible change of this metadata is a breaking change (`MAJOR`).

## 4. Canonical Tool Names (v1)
## 4. Canonical Tool Names (v2)

### 4.1 `evo.content.*`
- `evo.content.search`
- `evo.content.get`
- `evo.content.root_tree`
- `evo.content.descendants`
- `evo.content.tree`
- `evo.content.ancestors`
- `evo.content.children`
- `evo.content.siblings`

Post-MVP optional:
- `evo.content.neighbors`
- `evo.content.prev_siblings`
- `evo.content.next_siblings`
- `evo.content.children_range`
- `evo.content.siblings_range`

### 4.2 `evo.model.*`
- `evo.model.list`
- `evo.model.get`

### 4.3 `evo.elements.*`
- `evo.elements.list`
- `evo.elements.get`

### 4.4 `evo.write.*`
- `evo.write.content.update`
- `evo.write.content.create`
- `evo.write.content.publish`
- `evo.write.elements.save`
- `evo.write.cache.clear`

## 5. Common Tool Call Envelope
MCP `tools/call` payload:

Expand Down Expand Up @@ -95,20 +97,19 @@ Arguments:
- `id` int required
- `with_tvs` string[] optional

### 6.3 `evo.content.root_tree`
Arguments:
- `depth` int optional
- `with_tvs` string[] optional
- `limit` int required
- `offset` int optional
### 6.3 `evo.content.tree`
- `id` required, with 0 representing the virtual site root.
- `depth` defaults to 1. The configured depth cap allows one extra level from the virtual root.
- `menuindex_from` and `menuindex_to` are optional inclusive bounds available at depth 1.
- `with_tvs`, required `limit` and optional `offset` apply to a flat list sorted by parent, menuindex and ID.

### 6.4 `evo.content.descendants|ancestors|children|siblings`
Arguments:
- `id` int required
- `depth` int optional (where relevant)
- `with_tvs` string[] optional
- `limit` int required
- `offset` int optional
### 6.4 `evo.content.siblings` and `evo.content.ancestors`
- Siblings requires a positive `id`; `direction` is `all` (default), `before`, `after` or `adjacent`.
- Before and after are nearest first by the total order (menuindex, ID); adjacent returns at most the nearest visible record on each side, previous first.
- Only all accepts inclusive `menuindex_from` and `menuindex_to`. All, before and after require `limit` and accept `offset`; adjacent accepts neither.
- Ancestors requires a positive `id` and accepts optional `depth`. Omit depth for the complete visible path up to the server result limit. The result is ordered farthest to nearest. A server-limited path keeps the nearest ancestors and sets `meta.truncated`.
- All five content tools accept `with_tvs` as a list of TV names. Use the suffix `:d` to request the default when no value is stored.
- A missing, trashed or inaccessible anchor gives an empty list for tree, siblings and ancestors.

### 6.5 `evo.model.list`
Arguments:
Expand All @@ -130,6 +131,12 @@ Arguments:
- `model` string required (must be in allowlist)
- `id` int required

### 6.7 Elements and write tools
Element reads use the edit permission for the selected type. List returns names and metadata; get also returns the code field and honors ID before exact name.
Element saves use the corresponding new or save permission and the server's code-write policy.

Document update requires save_document. An actual change to published, pub_date or unpub_date also requires publish_document. Dates are non-negative integer timestamps; zero clears a date. Rejected publication changes and failures within the edit transaction leave both document fields and TVs unchanged. TV names must belong to the destination template. The result reports requested field and TV names whose stored values changed.

## 7. Response Contract
Tool responses SHOULD return:
- `items` array for list-like tools
Expand All @@ -145,7 +152,7 @@ Example:
"limit": 20,
"offset": 0,
"count": 0,
"toolsetVersion": "1.0"
"toolsetVersion": "2.0"
}
}
```
Expand Down Expand Up @@ -174,3 +181,27 @@ Canonical mapping:
- large responses MUST be paginated
- `limit` cannot exceed configured `max_result_items`
- serialized result cannot exceed configured `max_result_bytes`

## Migration from toolset 1.0

Upgrade to [DocumentManager 1.1.0](https://github.com/evolution-cms/DocumentManager/releases/tag/1.1.0) or a later 1.x release before switching to Toolset 2.0. This release provides the atomic document and TV update API. Composer resolves the published dependency without a local path repository.
The names below are relative to the `evo.content.` prefix.

| v1 call | v2 call |
| --- | --- |
| `root_tree(depth=d)` | `tree(id=0, depth=d+1)`; use depth 2 for the old default. |
| `children(id)` | `tree(id, depth=1)` |
| `descendants(id, depth=d)` | `tree(id, depth=d)`; use depth 1 for omitted or null depth. |
| `children_range(id, from, to)` | `tree(id, depth=1, menuindex_from=from, menuindex_to=to)` |
| `siblings(id)` | `siblings(id, direction=all)` |
| `prev_siblings(id)` | `siblings(id, direction=before)` |
| `next_siblings(id)` | `siblings(id, direction=after)` |
| `neighbors(id)` | `siblings(id, direction=adjacent)`; omit limit and offset. |
| `siblings_range(id, from, to)` | `siblings(id, direction=all, menuindex_from=from, menuindex_to=to)` |
| `ancestors(id, depth, limit, offset)` | `ancestors(id, depth)`; slice client-side if needed and honor meta.truncated. |
| `search(...)`, `get(...)` | Same names and arguments, now with the supported TV and search options in the schema. |

- Carry over `with_tvs` and `limit`/`offset` where supported. Restart root-tree paging at offset 0 because v1 sorted only by ID.
- Sibling directions compare `(menuindex, id)`. Equal menu positions are ordered by ID. Adjacent finds the closest accessible record on either side even across position gaps; v1 neighbors used exact positions ±1. Restart paging when equal positions could change the result set.
- Model, element and write names are unchanged. For document updates, a forbidden publication change now rejects the whole request, and the returned change lists describe persisted changes. Send TVs by name on the target template.
- Refresh the client’s tool discovery after switching versions. A client that still needs the v1 semantics should finish its migration against the v1 release before the server is upgraded.
Loading
Loading