Commit Graph
31 Commits
Author SHA1 Message Date
randRuFlo 536a7315bd fix(mcp): retire superseded sessions instead of refusing at maxSessions (#4674)
Every initialize created a session, but the server answers every client
through one currentSession, so a superseded session is never addressed again.
It still held a slot until the 30-minute expiry, and 100 short-lived SDK
clients (connect, listTools, close) were enough to make the next initialize
fail with "Maximum sessions (100) reached".

SessionManager.reserveCapacity(keepId) closes the least recently active
session other than keepId when the manager is full. The server calls it
before creating a session, keeping the current one. Capacity and expiry are
unchanged, and nothing is closed while there is room.

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-11-04 02:07:21 -05:00
rUvandr bd77bced5f fix(security): bearer parsing, verification-code bias, protocol stripping; release 3.66.2 (#4624)
* fix(security): linear bearer parsing, unbiased verification codes, nested-protocol stripping

- @claude-flow/mcp: HTTP and WebSocket transports parse Authorization: Bearer
  with a prefix compare instead of /^Bearer\s+(.+)$/i, which backtracked
  quadratically on long whitespace runs (CodeQL js/polynomial-redos).
- ruflo-chatgpt-federation: same parser fix in authContext.
- @claude-flow/security: generateVerificationCode draws digits with
  randomInt(10); byte % 10 favoured 0-5 (js/biased-cryptographic-random).
- @claude-flow/security: sanitizeString strips javascript:/vbscript:/data:
  until stable, so javajavascript:script: no longer reassembles javascript:
  (js/incomplete-url-scheme-check).
- cli terminal_create: session ids from crypto randomBytes, not Math.random.

Co-Authored-By: RuFlo <ruv@ruv.net>

* chore(release): 3.66.2 — mcp 3.1.5, security 3.0.6

Co-Authored-By: RuFlo <ruv@ruv.net>

* chore(ruflo-chatgpt-federation): 0.2.5 for the bearer parser fix

Co-Authored-By: RuFlo <ruv@ruv.net>

* test(ruflo-chatgpt-federation): smoke expects 0.2.5

Co-Authored-By: RuFlo <ruv@ruv.net>

---------

Co-authored-by: r <r@x>
2026-10-31 14:11:42 -04:00
Dragan Spiridonov 4d6fc66b86 fix(mcp): an unset token entry does not crash the WebSocket upgrade (#4522)
Follow-up to #4516. `auth.tokens` built as `[process.env.X]` with X unset put
undefined in the list; upgradeHasValidToken hashed it and threw inside
verifyClient on any upgrade carrying a Bearer value (an uncaught exception a
client without the token could trigger), and with `[TOKEN, undefined]` the
real token could not connect either. Unset and empty entries now match
nothing.
2026-10-26 15:20:30 -04:00
rUvandr fc323f5108 fix(mcp): network transports start with a per-user token by default; WebSocket tokens work (#4516)
mcp start -t http|websocket with no token now uses ~/.claude-flow/mcp-http-token (0600,
created on first use) unless RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1. The standalone
WebSocket transport authenticates the upgrade (Authorization: Bearer or ?token=); the
unreachable message-level 'authenticate' gate no longer fails every request, and the CLI
accepts --auth-token with websocket.

Co-authored-by: r <r@x>
2026-10-26 14:05:50 -04:00
Agustin Torres 1505a24033 Replace the models api.anthropic.com retired (#4512)
Replaced retired Claude model ids with Anthropic's recommended replacements at the places that send them or set them as defaults: the MCP sampling request, the CLI default provider config, and the provider quick-test requests.

Notice anthropic-retired-models-2026-10 about api.anthropic.com's API describes the change. It was read from a file and is not signed by the provider.
2026-10-26 12:10:53 -04:00
rUvandr c0f205629b fix(mcp): token-less HTTP/WebSocket transports refuse web pages, rebound hosts and open non-loopback binds (#4510)
Without a token the transports now check Host (loopback bind) and Origin (exact
allow-list, '*' does not count) on requests and WebSocket upgrades, and both refuse
to listen beyond loopback unless allowUnauthenticated is set.

Co-authored-by: r <r@x>
2026-10-26 11:33:00 -04:00
DexandDextheking1 47720bd684 fix(mcp): use crypto randomUUID for session ids (#4418)
Co-authored-by: Dextheking1 <Dextheking1@users.noreply.github.com>
2026-10-23 08:24:22 -04:00
stanleyandRuFlo cf8b6928ef feat(mcp): make HTTP and session rate limits configurable (#3694)
* feat(mcp): make HTTP and session rate limits configurable

The per-session token bucket (50, refill 5/s), the server-wide bucket
(100/s, burst 200) and the HTTP per-IP limit (120 per 60s) were
hardcoded, and HttpTransportConfig.rateLimit was unreachable because
MCPServerConfig had no field for it.

Add rateLimit and sessionRateLimit to MCPServerConfig and pass them to
the transport and rate limiter. Expose them on `mcp start` as
--rate-limit-per-ip, --rate-limit-window-ms, --rate-limit-per-session,
--rate-limit-global-rps and --rate-limit-global-burst (env
RUFLO_MCP_RATE_LIMIT_*), with bounded integer validation. A session
burst is still capped by the server-wide burst, so raising the session
limit above it needs --rate-limit-global-burst too. Defaults are
unchanged.

The HTTP 429 body now carries the JSON-RPC id of the rejected request
instead of null.

The CLI leaves the limits unset unless a flag or env value is given, so
the @claude-flow/mcp defaults stay the single source.

Co-Authored-By: RuFlo <ruv@ruv.net>

* fix(mcp): drop the request id from the HTTP 429 body

main now parses the JSON body after the rate limiter and auth gate, so
req.body is never set when the limiter rejects and the id echo always
fell back to null. Restore the static 429 message rather than parse
bodies for clients that are being throttled.

Also stub resolveMcpHttpAuthToken in the mcp start test mock, which
`mcp start` now calls.

* fix(mcp): refuse raised rate limits on a non-loopback host without a token

* refactor(mcp): keep raisedRateLimits module-private

---------

Co-authored-by: RuFlo <ruv@ruv.net>
2026-10-19 23:05:20 -04:00
rUv 21953adcb0 Merge pull request #4019 from rudycelekli/fix/mcp-inflight-resource-cache-20261010
fix(mcp): fence stale resource cache writes after invalidation
2026-10-10 17:11:22 -07:00
rUv 3a03b524c2 Merge pull request #3969 from rudycelekli/fix/active100-mcp-task-cancel-20261010
fix(mcp): preserve cancellation when an aborted executor resolves
2026-10-10 11:50:02 -07:00
Rudy Celekli 9c23f9f298 fix(mcp): fence cache writes after resource invalidation
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
2026-10-10 11:33:00 -04:00
rUv ad916b455b Merge pull request #3970 from rudycelekli/fix/active100-sampling-timer-20261010
fix(mcp): clear sampling deadlines after provider settlement
2026-10-10 07:42:41 -07:00
rUv aade0c3a7e Merge pull request #3974 from rudycelekli/campaign/ruflo-resource-cache-invalidation-20261010
fix(mcp): invalidate notified resource caches without subscribers
2026-10-10 07:42:38 -07:00
Rudy Celekli f9261f0b9b fix(mcp): invalidate notified resources without subscribers
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
2026-10-10 00:06:59 -04:00
Rudy Celekli 55e439d063 fix(mcp): remove stale discovery indexes when overriding tools
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
2026-10-10 00:06:59 -04:00
Rudy Celekli 819b757a8a fix(mcp): clear sampling deadlines after provider settlement
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
2026-10-09 22:46:39 -04:00
Rudy Celekli a0866ccf24 fix(mcp): preserve cancellation when an aborted executor resolves
Signed-off-by: Rudy Celekli <47457359+rudycelekli@users.noreply.github.com>
2026-10-09 22:46:38 -04:00
ruv 2a5fb089e7 Merge PR #3885 (shared resilience batch) into release/3.55.0 2026-10-07 13:04:16 -04:00
ruv f54359456e fix(mcp): refuse unauthenticated HTTP on non-loopback hosts; optional bearer-token auth
- startHttpServer refuses a non-loopback --host unless RUFLO_MCP_HTTP_TOKEN /
  --auth-token-file / --auth-token is set, or RUFLO_MCP_ALLOW_UNAUTHENTICATED_HTTP=1.
  The gate now runs before any import or bind.
- New optional bearer-token auth wired into the HTTP transport: constant-time
  compare, bare 401, no token logging, applied before the body parser; only
  GET/HEAD /health stays public and reveals liveness only. Auth enabled with no
  tokens now fails closed (previously any Bearer value was accepted).
- Wiring tests through MCPServerManager.start() (mutation-checked) and transport
  tests covering bypass attempts; README + mcp start help document the env vars.

Loopback without a token stays unauthenticated by design (documented).

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-10-07 10:13:37 -04:00
Rudy Celekli 66436ccf0c fix(mcp): reserve new connections before async acquisition yields
Net change of ruvnet/ruflo#3673 (release-metadata commits omitted; the
integration branch carries one shared version bump).
2026-10-07 10:03:14 -04:00
Rudy Celekli 60be232302 fix(mcp): flag handler errors in tool result envelopes 2026-09-26 19:52:22 -04:00
Rudy Celekli 9ba1cfda75 fix(mcp): prevent late HTTP timeout responses 2026-09-25 14:09:58 -04:00
ruv 392e71912e fix(mcp): rate-limit authenticated HTTP routes 2026-08-14 19:04:54 -04:00
dajiaohuang 6b8f0d0b5a fix(mcp): share state across HTTP transports 2026-08-14 17:10:34 -04:00
dajiaohuang 2dbb790a0b fix(mcp): restore HTTP protocol and CLI tools 2026-08-14 17:10:34 -04:00
rUv 495a451cf6 feat: add ADR-324 agentic policy engine (#2822)
* feat(memory): typed provenance in AgentDB (ADR-323)

Corrects and implements the 2026-07-28 dream-cycle research proposal
(PR #2804, closed as superseded) for typed memory provenance in
AgentDB, addressing MemIR/MemSyco-Bench's "provenance-role collapse"
and memory-induced sycophancy findings.

The dream-cycle PR's proposed schema change targeted the wrong table
(`vector_indexes`, which is per-namespace HNSW index metadata, not
per-entry) and its filename collided with the already-merged
`ADR-322-metaharness-flywheel-integration.md` (#2817) — both corrected
here as ADR-323 against `memory_entries`, the real per-record table.

- memory-initializer.ts: `provenance_type` column (user_claim |
  agent_output | system_observation | tool_result | unknown, default
  unknown) on `memory_entries`, migrated for existing DBs via
  `ensureSchemaColumns()`. `storeEntry()`/`searchEntries()` accept and
  validate `provenanceType`/`provenanceFilter`.
- memory-bridge.ts: same wiring for the native better-sqlite3 AgentDB
  v3 path (`bridgeStoreEntry`/`bridgeSearchEntries`).
- commands/memory.ts: `memory store --provenance <type>`, `memory
  search --provenance-filter <types>` (comma-separated, OR semantics).
- mcp-tools/memory-tools.ts + cli-core/mcp-tools/memory-defs.ts:
  `memory_store`'s `provenance_type` param, `memory_search`'s
  `provenance_filter` param (kept in sync across both tool-def sets).

Found and fixed during implementation: an initial design skipped the
RaBitQ/HNSW acceleration paths entirely whenever a provenance filter
was requested (neither carries provenance_type on their candidates).
This reproducibly crashed the CLI process on exit (a libuv assertion
on Windows) after printing correct results. Fixed by never skipping
those paths — RaBitQ now fetches provenance_type in its existing
per-candidate query, HNSW does one batched (namespace, key) lookup
afterward — eliminating the crash across repeated runs. See ADR-323's
"Implementation note" for detail.

7 new end-to-end tests (adr-323-memory-provenance.test.ts), including
a repeated-run regression guard for the crash. Full existing memory
suite re-verified with no regressions (one pre-existing, environment-
specific #2558 test failure confirmed identical against unmodified
main — better-sqlite3's native bridge is unavailable in this dev
environment, unrelated to this change).

Closes the follow-up from dream-cycle PR #2804 (closed as superseded).

Co-Authored-By: claude-flow <ruv@ruv.net>

* fix(memory): enforce provenance across retrieval paths

* feat: add agentic policy engine

* fix: align Codex MCP integration

* fix: keep MetaHarness dependencies optional

* fix: declare MetaHarness as optional peers

* fix: sync workspace lockfile

* fix: document policy tool selection guidance

* test: cover governed in-process flywheel

* ci: make MetaHarness absence drill deterministic
2026-07-28 22:12:19 -04:00
ReuvenandRuFlo d065b2d654 fix #1874 + add MCP protocol-compliance smoke layer
The bug
───────

@claude-flow/mcp and @claude-flow/shared returned protocolVersion as
{ major, minor, patch } in the initialize response. The MCP spec
requires a YYYY-MM-DD string. Claude Code's Zod validator rejects
the object form with 'Invalid input: expected string, received
object', so HTTP MCP transport users couldn't connect at all.

Fix
───

  - MCPProtocolVersion type: interface with major/minor/patch →
    type alias for string (both packages).
  - Server constants: '2025-11-25' (mcp) and '2024-11-05' (shared).
  - Existing unit test in mcp.test.ts also corrected — it was
    asserting the wrong shape, so test + prod agreed on a non-spec
    format. This is the most important finding from the
    'why did validation miss this' investigation.
  - README example updated to spec-compliant string.

Why validation missed it (the gap)
──────────────────────────────────

  - Layer 1 (smoke): no smoke test boots the actual HTTP MCP
    server, sends a real initialize request, and validates the
    wire format. The existing tests only exercise tool execution.
  - Layer 2 (witness): tracks fix presence, can't catch
    'always-wrong-from-the-start' bugs that have no good baseline.
  - Layer 3 (history): same — no marker, no signal.
  - The unit test was self-consistent with the buggy production
    code. Both used { major, minor, patch }. Nothing measured
    against the upstream MCP spec or a real client validator.

Closing the gap
───────────────

  plugins/ruflo-core/scripts/test-mcp-protocol.mjs
    Boots the HTTP MCP server, sends initialize, asserts response
    shape against the spec:
      - protocolVersion is a string matching YYYY-MM-DD
      - capabilities is an object
      - serverInfo has { name, version } strings
    Final assertion mirrors what Claude Code's Zod would accept.

  v3-ci.yml: new mcp-protocol-smoke job (Linux + macOS), gated
  before witness-verify. Three layers of regression guard now
  cover this class.

  verification/witness-fixes.json: registers #1874-mcp and
  #1874-shared. Witness now attests the spec strings are present in
  both dist files; future regressions to the object form are caught
  by witness-verify, not just user reports.

Impact
──────

  84/84 fixes verified in the regenerated manifest (was 82).
  Anyone running ruflo mcp start -t http with the new build can now
  connect Claude Code without the Zod rejection.

Closes #1874

Co-Authored-By: RuFlo <ruv@ruv.net>
2026-05-09 13:17:38 -04:00
rUvandClaude Opus 4.5 6ad7a378d0 fix(hooks): Fix checkpoint hooks to handle plain file paths
- Updated standard-checkpoint-hooks.sh to accept both JSON and plain paths
- Fixed pre-edit and post-edit functions to detect input format
- Fixed v3 CLI hook flags (-f -> --file, -c -> --command, etc.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 02:54:48 +00:00
rUvandClaude Sonnet 4 1764e25886 checkpoint: File edit:
🚀 Generated with [Claude Code](https://claude.com/claude-code)
📊 V3 Development Progress Checkpoint

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-01-05 22:28:29 +00:00
rUvandClaude Sonnet 4 44de76a1a4 checkpoint: File edit:
🚀 Generated with [Claude Code](https://claude.com/claude-code)
📊 V3 Development Progress Checkpoint

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-01-05 22:13:14 +00:00
rUvandClaude Sonnet 4 9b33e1b2a0 checkpoint: Manual test
🚀 Generated with [Claude Code](https://claude.com/claude-code)
📊 V3 Development Progress Checkpoint

Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
2026-01-05 22:05:06 +00:00