Skip to content

fix(deps): move to @doist/mcp-core 0.4.0, its shared suites and host helpers - #693

Merged
scottlovegrove merged 3 commits into
mainfrom
feat/mcp-core-0.4
Nov 9, 2026
Merged

scottlovegrove merged 3 commits into
mainfrom
feat/mcp-core-0.4

Conversation

@scottlovegrove

@scottlovegrove scottlovegrove commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

What

@doist/mcp-core 0.4.0 ships the shared test suites (todoist/mcp-core#7) and the host's side of the token contract (todoist/mcp-core#8). This adopts both, one commit each.

Test suites

  • src/tools/tool-annotations.test.ts → describeToolAnnotations. All 49 tools' expected titles and hints are unchanged, now keyed by ToolNames. They're checked exactly as a client receives them on tools/list, defaults included. The old test spied on McpServer.prototype.registerTool and matched only partially. The MCP Apps _meta check for find-tasks-by-date stays, now reading the advertised tool through listAdvertisedTools.
  • src/token-footprint.test.ts → describeTokenFootprint. It measures the payload and the instructions from a running server, instead of rebuilding each entry with z.toJSONSchema and local copies of the registrar's title and _meta logic.

HTTP mode (requireValidTodoistToken)

  • The WWW-Authenticate challenge comes from buildBearerChallenge, and the verdict cache from createTokenVerdictCache. They're the same pieces todoist-ai-integrations will use.
  • There's one cache per TTL (5 minutes static, 2 dynamic, or cacheTtlMs), shared by every middleware with that TTL, as the single module-wide cache was before. When full, it drops the oldest verdict, where it used to prune expired entries and then clear everything. clearTokenValidationCache() still empties them all.
  • It still fails open on any validation error, as before. The log line now says "Validation failed, proceeding" rather than "Transient error", since it covers every error.

fix(deps): so the 0.4.0 bump releases, and todoist-ai-integrations gets a single copy of mcp-core.

The budget

Old test Measured from the server
tools/list payload (49 tools) 35,624 35,177
instructions 971 971
Combined 36,595 36,148

DEFAULT_TOKEN_BUDGET moves down from 36,600 to 36,200. The old count sat 5 tokens under the old budget; the real cost now has a similar small margin of 52.

Verification

  • npm run verify passes.
  • The annotations file runs 51 tests: one per tool, the coverage check, and the _meta check.
  • The middleware's tests are unchanged and all pass: 401 and 403 challenges with and without resource_metadata, caching of each verdict, expiry under fake timers, a separate cache per base URL, and failing open. Together with http-app.test.ts that's 60 tests. They pin the behaviour across the refactor. From review, a new test fills the cache past 10,000 tokens and checks that the oldest verdict goes and the rest stay; it fails if the limit is off by one. The base URL test now fails if the cache key drops the base URL, because the two middlewares share a cache again.

- tool-annotations.test.ts keeps all 49 tools' titles and hints, keyed
  by tool name, now checked exactly as a client receives them on
  tools/list instead of partially off a registerTool spy. The MCP Apps
  _meta check reads the advertised tool as well.
- token-footprint.test.ts measures the tools/list payload and
  instructions from a running server, instead of rebuilding each entry
  with copies of the registrar's title and _meta logic. The rebuild
  overcounted by 447 tokens (36,595 against the 36,148 a client
  receives), so the budget moves down from 36,600 to 36,200, a similar
  margin over the real cost.
requireValidTodoistToken takes its WWW-Authenticate challenge from
buildBearerChallenge and its verdict cache from createTokenVerdictCache,
the same pieces todoist-ai-integrations uses. Each middleware now has
its own cache, so its TTL is fixed with it; when full it drops the
oldest verdict rather than pruning and then clearing everything. It
still fails open on any validation error.
@scottlovegrove scottlovegrove self-assigned this Nov 9, 2026

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adopts @doist/mcp-core 0.4.0's shared test suites and host helpers, moving the annotations and token-footprint tests onto the shared implementations and switching the HTTP middleware to buildBearerChallenge and createTokenVerdictCache with per-middleware caches. Annotations and the token budget (now 36,200, a 52-token margin over the server-measured payload) are preserved, and the challenge, fail-open, and cache-clearing behavior carry over unchanged.

Few things worth tightening:

  • The "should use separate cache entries for different baseUrls" test in require-valid-todoist-token.test.ts now passes for the wrong reason: with caches created per middleware instance, two instances with different baseUrls will always make two validateTodoistToken calls regardless of how the cache keys work. Rewrite it to pin the per-instance isolation (or drop it, since that separation is now inherent), so it can actually fail if the contract regresses.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (4)
  • P3 src/middleware/require-valid-todoist-token.ts:119: The new comment correctly says validation fails open on any error, but the console.warn two lines below still labels every failure as 'Transient error'. Non-transient validation failures will be misreported in logs. Align the message, e.g. '[Token validation] Error, proceeding:'.
  • P3 src/middleware/require-valid-todoist-token.ts:45: The module-level caches set only ever grows: every call to requireValidTodoistToken registers a new TokenVerdictCache and nothing ever removes one, even after the middleware is discarded. Any consumer that builds middleware instances dynamically (or recreates an app) retains every cache — and the API tokens stored in them — for the process lifetime. Consider having clearTokenValidationCache delete entries it empties, or exporting a dispose/cleanup on the cache. Low risk today since production creates the middleware once, but it's a slow leak for tests and embedding hosts like todoist-ai-integrations.
  • P3 src/token-footprint.test.ts:98 (removed line): Removing TOKEN_BUDGET leaves AGENTS.md pointing future contributors at an identifier that no longer exists in this file. Update that guidance to reference the new DEFAULT_TOKEN_BUDGET/budget wiring so the next tool-surface change isn't sent looking for a dead symbol.
  • P3 src/middleware/require-valid-todoist-token.ts:94: This PR changes the cache's at-capacity behaviour — from prune-expired-then-clear-all to dropping the oldest verdict — but the existing middleware tests (caching, expiry, per-URL separation, fail-open) never exercise eviction at maxEntries, so the one behaviour this refactor deliberately changed is the only one not pinned. A test that fills the cache to MAX_CACHE_SIZE and asserts the oldest verdict is evicted (and a non-oldest one survives) would complete the "pin the behaviour across the refactor" goal.

Share Feedback • Review Logs

A cache per middleware let the "separate cache entries for different
baseUrls" test pass whatever the cache key was, since its two
middlewares never shared a cache, and the set of caches only ever grew.
There is now one cache per TTL, shared by every middleware with it, as
the single module-wide cache was before: the base URL test fails again
if the key drops the base URL, and the caches stay bounded. The cache
reads Date.now on every call, so fake timers apply whenever it was
made.

Also from review:
- a test fills the cache past 10,000 tokens and checks the oldest
  verdict goes and the others stay; it fails with the limit off by one;
- the fail-open log line says "Validation failed", since it covers any
  error, not only transient ones;
- AGENTS.md names DEFAULT_TOKEN_BUDGET, the constant that exists.
@scottlovegrove scottlovegrove added the 🚢 Ship PR requires passing checks before merge, but no independent human review. label Nov 9, 2026
@scottlovegrove
scottlovegrove merged commit 4f986dd into main Nov 9, 2026
6 checks passed
@scottlovegrove
scottlovegrove deleted the feat/mcp-core-0.4 branch November 9, 2026 13:56
doist-release-bot Bot added a commit that referenced this pull request Nov 9, 2026
## [14.0.2](v14.0.1...v14.0.2) (2026-11-09)

### Bug Fixes

* **deps:** move to @doist/mcp-core 0.4.0, its shared suites and host helpers ([#693](#693)) ([4f986dd](4f986dd)), closes [todoist/mcp-core#7](todoist/mcp-core#7) [todoist/mcp-core#8](todoist/mcp-core#8)
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 14.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 🚢 Ship PR requires passing checks before merge, but no independent human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants