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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
updated_date: '2026-12-02T14:04:19Z'
updated_date: '2026-12-04T16:58:19Z'
title: Pin pyArchimate to one minor series (2.4.x) but give the MCP SDK a range
date: '2026-07-27T21:38:00Z'
title: Pin pyArchimate to one minor series (2.3.x) but give the MCP SDK a range
id: decision-006
status: accepted
---
Expand All @@ -28,6 +28,14 @@ symbol was removed, yet two silent behaviour changes broke 16 tests:
stopped moving a connection's first and last segment by default. A loose pin would
have shipped both to users without a single import error. 2.x also requires
Python 3.11 (`enum.StrEnum`).

The 2.3 → 2.4 evaluation (ARC-066, 2026-12-04) was the quiet case: no imported
symbol moved and no test changed. 2.4 adds post-routing crossing reduction to
`auto_route`, on by default (`RoutingConfig(reduce_crossings=True)`), and
deprecates `LayoutConfig.algorithm` / `routing_style`, which the MCP never sets.
Routes still differ from 2.3, which is exactly what the evaluation exists to look
at; the default was kept on measured evidence (fewer crossings at near-equal
routing time).
<!-- SECTION:CONTEXT:END -->
## Decision
<!-- SECTION:DECISION:BEGIN -->
Expand All @@ -37,9 +45,9 @@ Python 3.11 (`enum.StrEnum`).
ceiling follows upstream's own v1/v2 branch split at 1.25.0: v2 renames
`FastMCP` to `MCPServer` and moves low-level `Server` handlers to constructor
parameters. Do not reintroduce the three-part shape.
- **`pyArchimate~=2.3.0`** — three-part, 2.3.x only. Every minor bump earns an
evaluation task (as 1.11.2 did in ARC-012, 1.12.0 in ARC-028 and 2.3.0 in
ARC-065) rather than arriving silently.
- **`pyArchimate~=2.4.0`** — three-part, 2.4.x only. Every minor bump earns an
evaluation task (as 1.11.2 did in ARC-012, 1.12.0 in ARC-028, 2.3.0 in
ARC-065 and 2.4.0 in ARC-066) rather than arriving silently.
- **`pydantic>=2.11.0,<3.0.0`** and **`lxml>=6.1.0,<7.0.0`** — ranges to the next
major, the ordinary case.
- **`requires-python` follows pyArchimate's floor** (`>=3.11` since 2.x), together
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ would be worse than straight lines.
- `layout.py` imports pyArchimate's **internal** layout surface (`LayoutConfig`,
`RoutingConfig`, `auto_layout`, `auto_route` from `pyArchimate.view.layout`),
which carries no stability guarantee. This is the direct cause of the tight
`~=2.3.0` pin; see decision-006.
`~=2.4.0` pin; see decision-006.
- Never run upstream `auto_layout` **after** routing: it preserves waypoints
byte-for-byte, so moving nodes underneath them strands every bendpoint in empty
canvas.
Expand Down
60 changes: 60 additions & 0 deletions .backlog/tasks/arc-066 - Upgrade-to-pyArchimate-2.4.x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
id: ARC-066
title: Upgrade to pyArchimate 2.4.x
status: Done
assignee:
- '@claude'
created_date: '2026-12-04T16:54:18Z'
updated_date: '2026-12-04T17:02:57Z'
labels: []
dependencies: []
priority: high
type: task
ordinal: 55000
---

## Description

<!-- SECTION:DESCRIPTION:BEGIN -->
pyArchimate 2.4.0 (2026-12-04) is out and the pin `~=2.3.0` blocks it. Decision-006 requires every minor bump to get an evaluation, because layout.py imports the internal `pyArchimate.view.layout` surface. 2.4 changes routing: `auto_route` now runs post-routing crossing reduction by default (`RoutingConfig(reduce_crossings=True)`), adds `RoutingReport.crossings`, and deprecates `LayoutConfig.algorithm` / `routing_style` (the MCP sets neither). Routes differ from 2.3 wherever crossings could be reduced, and routing is ~1.1x slower, which matters for ARC-065.08.
<!-- SECTION:DESCRIPTION:END -->

## Acceptance Criteria
<!-- AC:BEGIN -->
- [x] #1 pyproject.toml pins pyArchimate~=2.4.0 (three-part, per decision-006) and uv.lock resolves 2.4.x
- [x] #2 Full suite and ruff check/format pass on 2.4, with any test changes justified by documented upstream behaviour changes
- [x] #3 The routing wrapper still holds its contract on 2.4: no node moves, rewritten connections are reported, failures restore the view
- [x] #4 The MCP emits no DeprecationWarning from pyArchimate 2.4 in the test suite
- [x] #5 CLAUDE.md, README, docs/USER_GUIDE.md, docs/TECHNICAL_ARCHITECTURE.md, CHANGELOG.md and decision-006 name 2.4.x and record the evaluation
<!-- AC:END -->

## Implementation Plan

<!-- SECTION:PLAN:BEGIN -->
1. Bump pin to ~=2.4.0, refresh comment, uv lock/sync.
2. Run ruff + full suite (with -W error::DeprecationWarning for pyArchimate) and triage failures against the 2.4 release notes.
3. Check routing wrapper contract (node pinning, remove_all_bendpoints tracking, restore on failure) under reduce_crossings=True; keep upstream default unless a guarantee breaks.
4. Measure routing time on the existing benchmark views vs 2.3; record in LAYOUT_IMPROVEMENT_PLAN.
5. Docs: CLAUDE.md, README, USER_GUIDE, TECHNICAL_ARCHITECTURE, CHANGELOG, decision-006.
<!-- SECTION:PLAN:END -->

## Implementation Notes

<!-- SECTION:NOTES:BEGIN -->
Verified 2026-12-04 on pyArchimate 2.4.0 (uv.lock 2.3.0 -> 2.4.0; lxml 6.1.1 -> 6.2.1 pulled by pyArchimate's new floor). No imported symbol moved; no test or code change needed.
ruff check + format clean. Suite 236/236 on 3.11, 3.12, 3.13; also 236/236 with -W error::DeprecationWarning (the MCP never sets the deprecated LayoutConfig.algorithm/routing_style).
Routing wrapper: upstream _reduce_crossings runs on the same conn_refs list after remove_all_bendpoints and before add_bendpoint, so change tracking stays exact; allow_node_move=False pinning and restore-on-failure tests all pass.
Kept reduce_crossings=True (upstream default): fewer excess crossings on every fixture, ~1-2% slower on large views, up to ~20% on small. Measurements in docs/LAYOUT_IMPROVEMENT_PLAN.md; does not help ARC-065.08.
README names no pyArchimate version, so nothing to change there.
Possible follow-up (not done, needs approval): surface upstream RoutingReport.crossings in ViewDetail.routing.

Committed 8c65cb2 on branch pyArchimate2.4.x; PR #2 stacked on PR #1 (base pyArchimate2.3.x), to be retargeted to main after #1 merges.

Upstream: reopened byrondelgado/mcp-archimate#8 (2.3.x, base dev) and opened byrondelgado/mcp-archimate#9 (2.4.x, base dev, contains #8's commits; merge #8 first). PR #2 on origin corrected to say retarget to dev (PR #1's base), not main.
<!-- SECTION:NOTES:END -->

## Final Summary

<!-- SECTION:FINAL_SUMMARY:BEGIN -->
Upgraded to pyArchimate 2.4.x: pin ~=2.4.0 (still three-part per decision-006), uv.lock regenerated. 2.4 needed no code or test change; its new default crossing reduction in auto_route is kept, measured to cut excess crossings on every fixture (chain 200: 1,645 -> 1,094) at near-equal routing time. Docs: CLAUDE.md, USER_GUIDE, TECHNICAL_ARCHITECTURE, LAYOUT_IMPROVEMENT_PLAN (new 2.4 measurement table), CHANGELOG Unreleased (pin + fewer crossings), decision-006 (retitled to 2.4.x, records the evaluation) and decision-011. Verified: ruff clean; 236/236 on Python 3.11-3.13, also with DeprecationWarnings as errors. Follow-ups: ARC-065.08 (large-view routing speed) unaffected; optionally expose RoutingReport.crossings.
<!-- SECTION:FINAL_SUMMARY:END -->
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

Upgrade to pyArchimate 2.3.
Upgrade to pyArchimate 2.4.

**Breaking, twice:** Python 3.11 is now the minimum; and a refused
`layout_engine="pyarchimate"` layout reports `error.details.protruding_nodes`
Expand All @@ -31,11 +31,18 @@ instead of `error.details.oversized_nodes`. See Changed.

### Changed

- **pyArchimate 2.3.x, and Python 3.11 or later.** The pin moves from
`pyArchimate~=1.12.0` to `pyArchimate~=2.3.0`, still deliberately limited to
- **pyArchimate 2.4.x, and Python 3.11 or later.** The pin moves from
`pyArchimate~=1.12.0` to `pyArchimate~=2.4.0`, still deliberately limited to
one minor series because the server uses pyArchimate's internal layout
module. pyArchimate 2.x requires Python 3.11, so Python 3.10 is no longer
supported; CI covers 3.11 to 3.13.
- **Fewer connection crossings.** pyArchimate 2.4's router untangles edge
fans, removes avoidable double crossings and spreads close parallel
segments after routing, so routes from `auto_layout_view` and
`auto_route_view` differ from 2.3 wherever a crossing could be avoided. On
the 200-node chain fixture excess crossings drop from 1,645 to 1,094 and
double crossings from 410 to 234; routing time is unchanged on large views
and up to ~20% slower on small ones.
- **The `pyarchimate` layout engine accepts wide nodes and Groupings.**
pyArchimate 2.3 widens a grid column or row for a node larger than one cell,
so such views no longer overlap and are no longer refused. The grid is now
Expand Down
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

A Model Context Protocol (MCP) server for ArchiMate enterprise-architecture modeling, built on FastMCP and backed by the `pyArchimate` library (pinned to `~=2.3.0`). The server manages **one in-memory ArchiMate model per process** (the "active model"); every tool and resource operates on it. Creating or loading a model replaces the current one.
A Model Context Protocol (MCP) server for ArchiMate enterprise-architecture modeling, built on FastMCP and backed by the `pyArchimate` library (pinned to `~=2.4.0`). The server manages **one in-memory ArchiMate model per process** (the "active model"); every tool and resource operates on it. Creating or loading a model replaces the current one.

## Commands

Expand Down Expand Up @@ -134,13 +134,13 @@ The pin *shapes* in `pyproject.toml` are deliberate and differ per package:

- `mcp>=1.28.1,<2.0.0` — an explicit range, deliberately **not** a three-part `~=`. `~=1.21.1` silently capped the SDK for eight months; do not reintroduce that shape. The `<2` ceiling follows upstream's own v1/v2 branch split (v2 renames `FastMCP` to `MCPServer` and moves low-level `Server` handlers to constructor params).
- The `[cli]` extra is **dev-only** (`[dependency-groups].dev`), not a runtime dependency. The whole SDK import surface is two lines in `mcp_app.py` (`FastMCP`, `ToolAnnotations`), so dropping the extra keeps `uvx mcp-archimate` installs lean; nothing in the package or tests imports typer/rich/click.
- `pyArchimate~=2.3.0` — deliberately a three-part `~=` (2.3.x only), *unlike* `mcp`. 2.x also raised the Python floor to 3.11 (`enum.StrEnum`); `requires-python`, ruff's target and the CI matrix follow it. `layout.py` imports pyArchimate's **internal** layout surface (`LayoutConfig`, `RoutingConfig`, `auto_layout`, `auto_route` from `pyArchimate.view.layout`), which carries no stability guarantee, so every minor bump earns an evaluation task rather than arriving silently.
- `pyArchimate~=2.4.0` — deliberately a three-part `~=` (2.4.x only), *unlike* `mcp`. 2.x also raised the Python floor to 3.11 (`enum.StrEnum`); `requires-python`, ruff's target and the CI matrix follow it. `layout.py` imports pyArchimate's **internal** layout surface (`LayoutConfig`, `RoutingConfig`, `auto_layout`, `auto_route` from `pyArchimate.view.layout`), which carries no stability guarantee, so every minor bump earns an evaluation task rather than arriving silently.

### pyArchimate API constraints (pinned 2.3.x)
### pyArchimate API constraints (pinned 2.4.x)

The manager is written against specific pyArchimate patterns (established on 1.12.x, unchanged in 2.3.x) — documented in detail in `docs/TECHNICAL_ARCHITECTURE.md`. Key points:
The manager is written against specific pyArchimate patterns (established on 1.12.x, unchanged through 2.4.x) — documented in detail in `docs/TECHNICAL_ARCHITECTURE.md`. Key points:

- Create concepts with `model.add(concept_type=..., name=...)` and `model.add_relationship(rel_type=..., source=..., target=...)`. Calls like `model.add_element()`, `model.get_elem()`, `model.add_view()` **do not exist** in 1.12.x or 2.3.x.
- Create concepts with `model.add(concept_type=..., name=...)` and `model.add_relationship(rel_type=..., source=..., target=...)`. Calls like `model.add_element()`, `model.get_elem()`, `model.add_view()` **do not exist** in 1.12.x through 2.4.x.
- Relationship types use pyArchimate names *without* the `Relationship` suffix (`Serving`, `Assignment`, `Influence`).
- `model.read(path)` needs a filesystem path — a temp file is used for string content.
- Native Archi export works on a *copy* of the model so writer compatibility adjustments never mutate the active model; folder IDs are stabilized so repeated exports diff cleanly; `influenceStrength` is rewritten to Archi's native `strength` attribute; `AndJunction`/`OrJunction` are converted to Archi's single `Junction` concept with a `type="and"/"or"` attribute; pyArchimate viewpoint slugs are rewritten to Archi's canonical viewpoint ids (`ARCHI_VIEWPOINT_ID_BY_SLUG`); top-level folder labels match stock Archi ("Technology & Physical", "Implementation & Migration"). Exchange (`archimate`) exports keep view properties: the 2.x writer declares their `propertyDefinition`s, so the 1.12-era `_strip_dangling_view_properties` repair was removed (ARC-065.04); `test_exchange_round_trip_keeps_view_properties_and_the_coverage_marker` and the `_dangling_exchange_idrefs` checks catch an upstream regression. **Never write to stdout anywhere in the server**: stdio transport uses stdout as the JSON-RPC channel; stray prints corrupt framing and hang clients (use `logging`, which goes to stderr).
Expand Down
18 changes: 18 additions & 0 deletions docs/LAYOUT_IMPROVEMENT_PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,24 @@ This document captures the layout direction for the MCP ArchiMate server. It is
> End to end, `auto_layout_view` on the chain fixtures: 43 nodes 77 ms
> (`internal`) vs 115 ms (`pyarchimate`); 200 nodes 9.9 s vs 3.1 s. Large-view
> routing time is the open follow-up (ARC-065.08).
>
> **Status update (2026-12-04, pyArchimate 2.4.0, ARC-066).** 2.4 adds a
> post-routing crossing-reduction pass to `auto_route`, on by default
> (`RoutingConfig(reduce_crossings=True)`; `False` reproduces the 2.3 routes).
> The MCP keeps the upstream default. Measured on 2.4.0 after an `internal`
> layout, upstream routing only, `crossing_summary` metrics:
>
> | View | Time off → on | Excess crossings off → on | Double pairs off → on |
> | --- | --- | --- | --- |
> | random 60 / 90 | 0.53 → 0.69 s | 40 → 14 | 29 → 31 |
> | random 100 / 200 | 3.50 → 4.19 s | 704 → 601 | 346 → 329 |
> | chain 43 / 42 | 0.15 → 0.13 s | 27 → 20 | 4 → 0 |
> | chain 200 / 199 | 10.65 → 10.81 s | 1,645 → 1,094 | 410 → 234 |
> | chain 300 / 299 | 26.01 → 26.39 s | 5,279 → 4,335 | 1,404 → 1,037 |
>
> Fewer excess crossings on every fixture, for at most ~20% more time on small
> views and ~1–2% on the large ones. It does not move the large-view numbers
> ARC-065.08 is about.

## Current Problem Statement

Expand Down
2 changes: 1 addition & 1 deletion docs/TECHNICAL_ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The server is a single-process FastMCP application. It manages one active `pyArc

## pyArchimate Usage

The implementation is pinned to the `pyArchimate~=2.3.0` API (2.x requires Python 3.11+). The pin is deliberately a three-part `~=` (2.3.x only), unlike the `mcp` range: `layout.py` imports pyArchimate's *internal* layout surface (`LayoutConfig`, `RoutingConfig`, `auto_layout`, `auto_route` from `pyArchimate.view.layout`), which carries no stability guarantee, so every minor bump earns an evaluation task rather than arriving silently.
The implementation is pinned to the `pyArchimate~=2.4.0` API (2.x requires Python 3.11+). The pin is deliberately a three-part `~=` (2.4.x only), unlike the `mcp` range: `layout.py` imports pyArchimate's *internal* layout surface (`LayoutConfig`, `RoutingConfig`, `auto_layout`, `auto_route` from `pyArchimate.view.layout`), which carries no stability guarantee, so every minor bump earns an evaluation task rather than arriving silently.

The manager uses these API patterns:

Expand Down
6 changes: 3 additions & 3 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ The server currently manages one active model per server process. Creating or lo
The project's runtime dependencies are:

- `mcp` (>= 1.28.1, < 2.0.0)
- `pyArchimate` (2.3.x)
- `pyArchimate` (2.4.x)
- `pydantic`
- `lxml`

Expand Down Expand Up @@ -783,7 +783,7 @@ Returns `data.is_valid`, `data.invalid_connection_ids`, `data.invalid_node_ids`,

Errors: `ModelNotFoundError`.

Note for existing users: since pyArchimate 1.12.x (the pin is now 2.3.x), the underlying orphan-connection check actually reports results. Earlier 1.11.x releases could not, so `validate_model` was effectively always valid on that dimension. A model that carries orphan visual connections — typically hand-edited or produced by another tool — may now report `is_valid: false` where it previously reported `true`. The same result feeds `build_quality_report`, `inspect_active_model`, the `pyarchimate://activemodel/validation` resource, and the export quality gate, so such a model can now be blocked by `quality_gate="strict"`. Models built through this server's own tools are unaffected: deleting an element or relationship also removes its view nodes and connections.
Note for existing users: since pyArchimate 1.12.x (the pin is now 2.4.x), the underlying orphan-connection check actually reports results. Earlier 1.11.x releases could not, so `validate_model` was effectively always valid on that dimension. A model that carries orphan visual connections — typically hand-edited or produced by another tool — may now report `is_valid: false` where it previously reported `true`. The same result feeds `build_quality_report`, `inspect_active_model`, the `pyarchimate://activemodel/validation` resource, and the export quality gate, so such a model can now be blocked by `quality_gate="strict"`. Models built through this server's own tools are unaffected: deleting an element or relationship also removes its view nodes and connections.

#### `validate_semantics`

Expand Down Expand Up @@ -878,7 +878,7 @@ Returns `data.element_types_by_category`, `data.relationship_types`, `data.viewp

Both namespaces are accepted, and they **overlap without either containing the other**: `capability`, `migration`, `organization`, `physical`, `stakeholder`, `strategy` and `technology` appear in both, while `business` is a slug only and `business_process_cooperation` is an Archi id only. There is no rule of thumb that gets this right — a plausible-looking name such as `business_process` is in neither list. Read the value from this tool rather than inferring it from a viewpoint's English name. Invalid values are rejected before the view is created or changed, and the error returns the same two catalogues in `error.details`.

The catalogue exposed by the MCP with the currently pinned pyArchimate 2.3.x contains 63 element types and 11 relationship types. It covers ArchiMate concepts used in Archi's Strategy, Business, Application, Technology, Motivation, Implementation, Other, Relations, and Views model tree folders. Diagram-only Archi annotations are not ArchiMate model concepts and are not in this catalogue: Notes are supported as *visual* view annotations through [`add_note_to_view`](#add_note_to_view) rather than as a type you can pass to `add_element`, and Legends are not supported. Because the catalogue is derived from the installed library rather than hardcoded, call this tool rather than assuming the lists below never change.
The catalogue exposed by the MCP with the currently pinned pyArchimate 2.4.x contains 63 element types and 11 relationship types. It covers ArchiMate concepts used in Archi's Strategy, Business, Application, Technology, Motivation, Implementation, Other, Relations, and Views model tree folders. Diagram-only Archi annotations are not ArchiMate model concepts and are not in this catalogue: Notes are supported as *visual* view annotations through [`add_note_to_view`](#add_note_to_view) rather than as a type you can pass to `add_element`, and Legends are not supported. Because the catalogue is derived from the installed library rather than hardcoded, call this tool rather than assuming the lists below never change.

#### `summarize_model`, `summarize_view`, `count_by_type`, and `list_orphan_elements`

Expand Down
Loading