Repository navigation
fix(deps): move to @doist/mcp-core 0.4.0, its shared suites and host helpers - #693
Merged
Merged
Conversation
- 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.
doistbot
reviewed
Nov 9, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
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.tsnow passes for the wrong reason: with caches created per middleware instance, two instances with differentbaseUrls will always make twovalidateTodoistTokencalls 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)
src/middleware/require-valid-todoist-token.ts:119: The new comment correctly says validation fails open on any error, but the
console.warntwo 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:'.src/middleware/require-valid-todoist-token.ts:45: The module-level
cachesset only ever grows: every call torequireValidTodoistTokenregisters a newTokenVerdictCacheand 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 havingclearTokenValidationCachedelete 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.src/token-footprint.test.ts:98 (removed line): Removing
TOKEN_BUDGETleaves AGENTS.md pointing future contributors at an identifier that no longer exists in this file. Update that guidance to reference the newDEFAULT_TOKEN_BUDGET/budgetwiring so the next tool-surface change isn't sent looking for a dead symbol.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 toMAX_CACHE_SIZEand asserts the oldest verdict is evicted (and a non-oldest one survives) would complete the "pin the behaviour across the refactor" goal.
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.
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)
Contributor
|
🎉 This PR is included in version 14.0.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@doist/mcp-core0.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 byToolNames. They're checked exactly as a client receives them ontools/list, defaults included. The old test spied onMcpServer.prototype.registerTooland matched only partially. The MCP Apps_metacheck forfind-tasks-by-datestays, now reading the advertised tool throughlistAdvertisedTools.src/token-footprint.test.ts→describeTokenFootprint. It measures the payload and the instructions from a running server, instead of rebuilding each entry withz.toJSONSchemaand local copies of the registrar's title and_metalogic.HTTP mode (
requireValidTodoistToken)WWW-Authenticatechallenge comes frombuildBearerChallenge, and the verdict cache fromcreateTokenVerdictCache. They're the same pieces todoist-ai-integrations will use.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.fix(deps):so the 0.4.0 bump releases, and todoist-ai-integrations gets a single copy of mcp-core.The budget
tools/listpayload (49 tools)DEFAULT_TOKEN_BUDGETmoves 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 verifypasses._metacheck.resource_metadata, caching of each verdict, expiry under fake timers, a separate cache per base URL, and failing open. Together withhttp-app.test.tsthat'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.