Skip to content

Commit 7b70845

Browse files
author
Růžička, David
committed
Merge branch 'dr-remove-multi-upstream-support' into 'main'
refactor: narrow upstream_mcp to a single provider See merge request ai-adoption/mcp/mcp4openapi!11
2 parents 82bac90 + a10b7d1 commit 7b70845

31 files changed

Lines changed: 4063 additions & 448 deletions

.planning/PROJECT.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ authenticate, authorize, audit, and proxy every tool call in the company.
3838
- ✓ Auth redaction hardening (Phase 01) - `sanitizeAuthErrorMessage` preserves last-4 Bearer suffix for debuggability; `redactString` fully redacts; token never appears in logs or error responses
3939
- ✓ Upstream tool discovery and proxy (Phase 02) - `tools/list` and `tools/call` forwarded to correct upstream provider; upstream tools namespaced by provider; `NotificationQueue` with TTL eviction for `tools/list_changed` replay on reconnect; `sendToClient` SSE real-time dispatch
4040
- ✓ API key authentication gate (Phase 03) - inbound M2M clients validated via inline env-var API keys before session establishment; `ClientAuthGate` runs after enterprise auth, before any upstream connection; `SessionData.clientPrincipal` populated with resolved identity (`subject`, `authType`, `scopes`); HMAC-SHA256 timing-safe comparison; fail-fast profile-load validator
41+
- ✓ upstream_mcp singular constraint (Phase 03.1) - Profile.upstream_mcp narrowed from UpstreamMcpServerConfig[] to UpstreamMcpServerConfig; Zod schema rejects array shape at parse time with migration hint; all call sites (mcp-server.ts, http-transport.ts, profile-resolver.ts) narrowed; BREAKING CHANGE: profile JSON must use `upstream_mcp: {...}` not `upstream_mcp: [{...}]`
4142

4243
### Active
4344
- [ ] Upstream tool discovery and proxy - tools/list and tools/call forwarded to correct upstream
@@ -109,7 +110,7 @@ authenticate, authorize, audit, and proxy every tool call in the company.
109110
| Tool namespacing by upstream provider | Prevents tool name collisions across providers; makes audit logs and policy rules unambiguous | - Pending |
110111

111112
---
112-
*Last updated: 2026-04-29 after Phase 03 completion*
113+
*Last updated: 2026-05-02 after Phase 03.1 completion — upstream_mcp narrowed from array to singular; BREAKING CHANGE for profile JSON format*
113114

114115
## Evolution
115116

.planning/ROADMAP.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,18 @@ Plans:
7070
- [x] 03-02-PLAN.md - ApiKeyStore interface, InlineApiKeyStore, and factory (AUTH-02; SasankaApiKeyStore deferred to Phase 4)
7171
- [x] 03-03-PLAN.md - ClientAuthGate orchestrator (API key path only), http-transport wiring, session clientPrincipal attachment (AUTH-02, AUTH-03)
7272

73+
### Phase 03.1: Odstranění multi upstream mcp supportu (INSERTED)
74+
75+
**Goal**: Profile.upstream_mcp narrowed end-to-end from UpstreamMcpServerConfig[] to UpstreamMcpServerConfig (singular). The runtime single-provider constraint already exists in profile-loader (D-03 check); this phase relocates it into the type system (Zod + TS), removes the now-dead loader runtime check, and migrates all consumers + test fixtures to the singular shape. Breaking change for end-user profile JSON/YAML using array syntax.
76+
**Requirements**: (none — internal type-narrowing refactor; preserves PROXY-01..04 and SEC-02 without modifying them)
77+
**Depends on:** Phase 03
78+
**Plans:** 3/3 plans complete
79+
80+
Plans:
81+
- [x] 03.1-01-PLAN.md — Source-of-truth types narrowed (profile.ts, http-transport.ts), generated schemas regenerated, resolver/parser/validator in upstream-mcp-config.ts singularised, profile-loader D-02 presence check + D-07 dead-code removal
82+
- [x] 03.1-02-PLAN.md — Call-site cleanup in mcp-server.ts, http-transport.ts, profile-resolver.ts, generic-profile.test.ts, and the in-repo profile fixture (singular access end-to-end; legacy-array tolerance preserved in list-view UX per Open Question 1)
83+
- [x] 03.1-03-PLAN.md — Test fixture migration across 5 test files (~112 sites), D-01 + D-03 negative test additions, dead loader-D-03 + empty-array tests removed; phase gate via full npm test green
84+
7385
### Phase 4: Client Authentication Gate (OIDC JWT)
7486
**Goal**: Clients bearing OIDC JWTs are validated against a JWKS endpoint; resolved identity completes AUTH-03
7587
**Depends on**: Phase 3

.planning/STATE.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ gsd_state_version: 1.0
33
milestone: v1.0
44
milestone_name: milestone
55
status: Ready to plan
6-
stopped_at: Completed 03-03-PLAN.md
7-
last_updated: "2026-04-29T13:36:55.375Z"
6+
stopped_at: Completed 03.1-02-PLAN.md
7+
last_updated: "2026-05-02T08:47:31.771Z"
88
progress:
9-
total_phases: 5
10-
completed_phases: 3
11-
total_plans: 11
12-
completed_plans: 11
9+
total_phases: 6
10+
completed_phases: 4
11+
total_plans: 14
12+
completed_plans: 14
1313
---
1414

1515
# Project State
@@ -19,7 +19,7 @@ progress:
1919
See: .planning/PROJECT.md (updated 2026-03-26)
2020

2121
**Core value:** A security boundary between internal AI clients and all upstream MCP servers - one place to authenticate, authorize, audit, and proxy every tool call.
22-
**Current focus:** Phase 03 — client-authentication-gate
22+
**Current focus:** Phase 03.1odstran-n-multi-upstream-mcp-supportu
2323

2424
## Current Position
2525

@@ -57,6 +57,8 @@ Plan: Not started
5757
| Phase 03-client-authentication-gate P01 | 5min | 3 tasks | 9 files |
5858
| Phase 03-client-authentication-gate P02 | 6min | 3 tasks | 5 files |
5959
| Phase 03-client-authentication-gate P03 | 10min | 3 tasks | 6 files |
60+
| Phase 03.1-odstran-n-multi-upstream-mcp-supportu P01 | 5 | 3 tasks | 8 files |
61+
| Phase 03.1-odstran-n-multi-upstream-mcp-supportu P02 | 8min | 3 tasks | 6 files |
6062

6163
## Accumulated Context
6264

@@ -92,6 +94,14 @@ Recent decisions affecting current work:
9294
- [Phase 03-client-authentication-gate]: [Phase 03-03]: ALL client auth gate exceptions map to HTTP 401 (not 500); warn log records errorType to distinguish ClientAuthGateError from unknown errors without leaking validator internals to clients
9395
- [Phase 03-client-authentication-gate]: [Phase 03-03]: Phase 4 deferral pinned by source-text guard test (no jose/jwks-cache imports or runtime calls); test will start failing intentionally when Phase 4 lands the JWT path, signaling the deferral guard has been lifted
9496
- [Phase 03-client-authentication-gate]: [Phase 03-03]: ClientAuthGate constructed once per profile in getProfileState() (not per-request) so the underlying InlineApiKeyStore HMAC secret persists for constant-time comparison; gate lifecycle ties to ProfileRuntimeState
97+
- [Phase 03.1-odstran-n-multi-upstream-mcp-supportu]: ZodError (not ValidationError) thrown when upstream_mcp: [...] array is present in YAML/JSON profile - Zod schema catches it before loader runtime validation runs
98+
- [Phase 03.1-odstran-n-multi-upstream-mcp-supportu]: validateUpstreamProvider path changed to 'upstream_mcp' (no [N] index) - all error paths are now upstream_mcp.transport.url, upstream_mcp.auth.header_name, etc.
99+
- [Phase 03.1-odstran-n-multi-upstream-mcp-supportu]: hasUpstreamMcpFlag lives in upstream-mcp-config.ts (semantic owner of all upstream_mcp logic) not profile-resolver.ts
100+
- [Phase 03.1-odstran-n-multi-upstream-mcp-supportu]: Legacy-array tolerance preserved at MIGRATION-CLEANUP sites: env-var collector (reads raw JSON pre-Zod) and hasUpstreamMcpFlag (list-view UX) for migration period
101+
102+
### Roadmap Evolution
103+
104+
- Phase 03.1 inserted after Phase 03: Odstranění multi upstream mcp supportu (URGENT)
95105

96106
### Pending Todos
97107

@@ -105,6 +115,6 @@ None yet.
105115

106116
## Session Continuity
107117

108-
Last session: 2026-04-29T13:26:45.700Z
109-
Stopped at: Completed 03-03-PLAN.md
118+
Last session: 2026-05-02T07:13:44.213Z
119+
Stopped at: Completed 03.1-02-PLAN.md
110120
Resume file: None

.planning/phases/03.1-odstran-n-multi-upstream-mcp-supportu/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)