Skip to content

feat(core): add deprecate() warn-once helper for v1-compat shims#1899

Closed
felixweinberger wants to merge 1 commit intomainfrom
fweinberger/v2-bc-deprecate-helper
Closed

feat(core): add deprecate() warn-once helper for v1-compat shims#1899
felixweinberger wants to merge 1 commit intomainfrom
fweinberger/v2-bc-deprecate-helper

Conversation

@felixweinberger
Copy link
Copy Markdown
Contributor

Part of the v2 backwards-compatibility series — see reviewer guide.

Shared helper that emits one stderr deprecation warning per key per process. Used by all Layer-1 BC shims so hot paths (per-tool registration) don't spam.

Motivation and Context

Shared helper that emits one stderr deprecation warning per key per process. Used by all Layer-1 BC shims so hot paths (per-tool registration) don't spam.

v1 vs v2 pattern & evidence

v1 pattern:

n/a  infrastructure for shims

v2-native:

n/a

Evidence: n/a

How Has This Been Tested?

  • packages/core/test/util/deprecate.test.ts — warn-once semantics
  • Integration: validated bump-only against 5 OSS repos via the v2-bc-integration validation branch
  • pnpm typecheck:all && pnpm lint:all && pnpm test:all green

Breaking Changes

None — additive @deprecated shim. Removed in v3.

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added or updated documentation as needed

Additional context

Stacks on: none

@felixweinberger felixweinberger added the v2-bc v2 backwards-compatibility series label Apr 15, 2026
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 15, 2026

🦋 Changeset detected

Latest commit: a33c305

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@felixweinberger felixweinberger added this to the v2.0.0-bc milestone Apr 15, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 15, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@1899

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@1899

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@1899

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@1899

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@1899

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@1899

commit: a33c305

@felixweinberger felixweinberger marked this pull request as ready for review April 16, 2026 13:31
@felixweinberger felixweinberger requested a review from a team as a code owner April 16, 2026 13:31
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

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

LGTM — tiny internal helper with test coverage; the inline nit is cosmetic only.

Extended reasoning...

Overview

Adds a 22-line deprecate(key, msg) warn-once helper in packages/core/src/util/deprecate.ts (module-level Set for dedup, console.warn output), a test-only _resetDeprecationWarnings(), a vitest covering warn-once semantics, a changeset, and a one-line export from the core barrel. This is the base PR of the v2-bc shim series.

Security risks

None. It's a stateless wrapper around console.warn with no I/O, no user input handling, and no auth/transport interaction.

Level of scrutiny

Low. Per CLAUDE.md § Public API Exports, packages/core/src/index.ts is the internal barrel (private: true, consumed only by sibling packages), so exporting deprecate here does not expand the end-user public API — it just makes the helper available to the server/client packages that will host the actual shims. The function is also tagged @internal. The repo guideline that abstractions need a concrete callsite is satisfied in spirit by the v2-bc series decomposition (principle 6: decompose by default), and the changeset accurately describes it as internal.

Other factors

Logic is trivially correct and matches the test. _resetDeprecationWarnings is intentionally not re-exported from the barrel. The one inline nit (runtime export placed under the "Core types only" comment) is purely organizational and has zero functional impact — fine to fix in a follow-up or when the next stacked PR touches that file.


// Core types only - implementations are exported via separate entry points
export type { JsonSchemaType, JsonSchemaValidator, jsonSchemaValidator, JsonSchemaValidatorResult } from './validators/types.js';
export { deprecate } from './util/deprecate.js';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Nit: this runtime export lands directly under the // Core types only - implementations are exported via separate entry points comment, which makes that section header read inaccurately. Consider moving it up next to the other ./util/* runtime exports (inMemory, schema, standardSchema) around lines 15-17.

Extended reasoning...

What's off

packages/core/src/index.ts is organized into loose sections. Lines 15-17 group all the runtime re-exports from ./util/*:

export * from './util/inMemory.js';
export * from './util/schema.js';
export * from './util/standardSchema.js';

Further down, the file ends with a section explicitly labeled as type-only:

// Core types only - implementations are exported via separate entry points
export type { JsonSchemaType, JsonSchemaValidator, ... } from './validators/types.js';
export { deprecate } from './util/deprecate.js';   // ← new line

The new deprecate export is a runtime value, not a type, so appending it immediately after the "Core types only" comment contradicts that comment and breaks the existing grouping convention.

Why it matters (mildly)

There is zero functional impact — the symbol is exported correctly either way. The only cost is readability: a future reader scanning the barrel will see a section comment that no longer describes what follows it, and the ./util/* exports are now split across two non-adjacent locations in the file.

Step-by-step

  1. Reader opens index.ts looking for util exports → finds the block at lines 15-17.
  2. deprecate isn't there; it's 35 lines lower, under a comment that says "types only".
  3. The comment now misdescribes its section.

Fix

Move the line up to sit with its siblings:

export * from './util/inMemory.js';
export * from './util/schema.js';
export * from './util/standardSchema.js';
export { deprecate } from './util/deprecate.js';

One-line move, purely cosmetic.

@felixweinberger
Copy link
Copy Markdown
Contributor Author

Closing — the deprecate() runtime helper is no longer used. Per review, BC shims use @deprecated JSDoc only (matching v1's state); no runtime warnings. The C-track PRs that previously stacked on this are now rebased directly onto main.

@felixweinberger felixweinberger deleted the fweinberger/v2-bc-deprecate-helper branch April 16, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2-bc v2 backwards-compatibility series

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant