-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(server-auth-legacy): add frozen v1 Authorization-Server package #1908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
felixweinberger
wants to merge
5
commits into
main
Choose a base branch
from
fweinberger/v2-bc-server-auth-legacy
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7cac712
feat(compat): add @modelcontextprotocol/server-auth-legacy package
felixweinberger cee3ec3
test: port v1 server/auth handler/provider/middleware tests
felixweinberger e7e1b52
test: complete v1 test port — add bearerAuth.test.ts + router metadat…
felixweinberger 126b89a
chore(server-auth-legacy): mark express peer dependency optional
felixweinberger 51eabff
fix(server-auth-legacy): make express a required peer; clarify OAuth …
felixweinberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@modelcontextprotocol/server-auth-legacy': patch | ||
| --- | ||
|
|
||
| Add `@modelcontextprotocol/server-auth-legacy`, a deprecated, frozen copy of the v1 SDK's `src/server/auth/` Authorization Server helpers (`mcpAuthRouter`, `ProxyOAuthServerProvider`, OAuth handlers/middleware/errors). Provided solely for v1 → v2 migration; new code should use a dedicated IdP plus the Resource Server helpers in `@modelcontextprotocol/express`. | ||
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # @modelcontextprotocol/server-auth-legacy | ||
|
|
||
| <!-- prettier-ignore --> | ||
| > [!WARNING] | ||
| > **Deprecated.** This package is a frozen copy of the v1 SDK's `src/server/auth/` Authorization Server helpers (`mcpAuthRouter`, `ProxyOAuthServerProvider`, etc.). It exists solely to ease migration from `@modelcontextprotocol/sdk` v1 and will not receive new features or non-critical bug fixes. | ||
|
|
||
| The v2 SDK no longer ships an OAuth Authorization Server implementation. MCP servers are Resource Servers; running your own AS is an anti-pattern for most deployments. | ||
|
|
||
| ## Migration | ||
|
|
||
| - **Resource Server glue** (`requireBearerAuth`, `mcpAuthMetadataRouter`, Protected Resource Metadata): use the first-class helpers in `@modelcontextprotocol/express`. | ||
| - **Authorization Server**: use a dedicated IdP (Auth0, Keycloak, Okta, etc.) or a purpose-built OAuth library. | ||
|
|
||
| ## Usage (legacy) | ||
|
|
||
| ```ts | ||
| import express from 'express'; | ||
| import { mcpAuthRouter, ProxyOAuthServerProvider } from '@modelcontextprotocol/server-auth-legacy'; | ||
|
|
||
| const app = express(); | ||
| app.use(mcpAuthRouter({ provider, issuerUrl: new URL('https://example.com') })); | ||
| ``` |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // @ts-check | ||
|
|
||
| import baseConfig from '@modelcontextprotocol/eslint-config'; | ||
|
|
||
| export default [ | ||
| ...baseConfig, | ||
| { | ||
| settings: { | ||
| 'import/internal-regex': '^@modelcontextprotocol/core' | ||
| } | ||
| } | ||
| ]; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| { | ||
| "name": "@modelcontextprotocol/server-auth-legacy", | ||
| "private": false, | ||
| "version": "2.0.0-alpha.2", | ||
|
felixweinberger marked this conversation as resolved.
|
||
| "description": "Frozen v1 OAuth Authorization Server helpers (mcpAuthRouter, ProxyOAuthServerProvider) for the Model Context Protocol TypeScript SDK. Deprecated; use a dedicated OAuth server in production.", | ||
| "deprecated": "The MCP SDK no longer ships an Authorization Server implementation. This package is a frozen copy of the v1 src/server/auth helpers for migration purposes only and will not receive new features. Use a dedicated OAuth Authorization Server (e.g. an IdP) and the Resource Server helpers in @modelcontextprotocol/express instead.", | ||
| "license": "MIT", | ||
| "author": "Anthropic, PBC (https://anthropic.com)", | ||
| "homepage": "https://modelcontextprotocol.io", | ||
| "bugs": "https://github.com/modelcontextprotocol/typescript-sdk/issues", | ||
| "type": "module", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/modelcontextprotocol/typescript-sdk.git" | ||
| }, | ||
| "engines": { | ||
| "node": ">=20" | ||
| }, | ||
| "keywords": [ | ||
| "modelcontextprotocol", | ||
| "mcp", | ||
| "oauth", | ||
| "express", | ||
| "legacy" | ||
| ], | ||
| "types": "./dist/index.d.mts", | ||
| "exports": { | ||
| ".": { | ||
| "types": "./dist/index.d.mts", | ||
| "import": "./dist/index.mjs" | ||
| } | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "typecheck": "tsgo -p tsconfig.json --noEmit", | ||
| "build": "tsdown", | ||
| "build:watch": "tsdown --watch", | ||
| "prepack": "npm run build", | ||
| "lint": "eslint src/ && prettier --ignore-path ../../.prettierignore --check .", | ||
| "lint:fix": "eslint src/ --fix && prettier --ignore-path ../../.prettierignore --write .", | ||
| "check": "pnpm run typecheck && pnpm run lint", | ||
| "test": "vitest run", | ||
| "test:watch": "vitest" | ||
| }, | ||
| "dependencies": { | ||
| "cors": "catalog:runtimeServerOnly", | ||
| "express-rate-limit": "^8.2.1", | ||
| "pkce-challenge": "catalog:runtimeShared", | ||
| "zod": "catalog:runtimeShared" | ||
| }, | ||
| "peerDependencies": { | ||
| "express": "catalog:runtimeServerOnly" | ||
| }, | ||
| "devDependencies": { | ||
| "@modelcontextprotocol/core": "workspace:^", | ||
| "@modelcontextprotocol/tsconfig": "workspace:^", | ||
| "@modelcontextprotocol/vitest-config": "workspace:^", | ||
| "@modelcontextprotocol/eslint-config": "workspace:^", | ||
| "@eslint/js": "catalog:devTools", | ||
| "@types/cors": "catalog:devTools", | ||
| "@types/express": "catalog:devTools", | ||
| "@types/express-serve-static-core": "catalog:devTools", | ||
| "@types/supertest": "catalog:devTools", | ||
| "@typescript/native-preview": "catalog:devTools", | ||
| "eslint": "catalog:devTools", | ||
| "eslint-config-prettier": "catalog:devTools", | ||
| "eslint-plugin-n": "catalog:devTools", | ||
| "express": "catalog:runtimeServerOnly", | ||
| "prettier": "catalog:devTools", | ||
| "supertest": "catalog:devTools", | ||
| "tsdown": "catalog:devTools", | ||
| "typescript": "catalog:devTools", | ||
| "typescript-eslint": "catalog:devTools", | ||
| "vitest": "catalog:devTools" | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { OAuthClientInformationFull } from '@modelcontextprotocol/core'; | ||
|
|
||
| /** | ||
| * Stores information about registered OAuth clients for this server. | ||
| */ | ||
| export interface OAuthRegisteredClientsStore { | ||
| /** | ||
| * Returns information about a registered client, based on its ID. | ||
| */ | ||
| getClient(clientId: string): OAuthClientInformationFull | undefined | Promise<OAuthClientInformationFull | undefined>; | ||
|
|
||
| /** | ||
| * Registers a new client with the server. The client ID and secret will be automatically generated by the library. A modified version of the client information can be returned to reflect specific values enforced by the server. | ||
| * | ||
| * NOTE: Implementations should NOT delete expired client secrets in-place. Auth middleware provided by this library will automatically check the `client_secret_expires_at` field and reject requests with expired secrets. Any custom logic for authenticating clients should check the `client_secret_expires_at` field as well. | ||
| * | ||
| * If unimplemented, dynamic client registration is unsupported. | ||
| */ | ||
| registerClient?( | ||
| client: Omit<OAuthClientInformationFull, 'client_id' | 'client_id_issued_at'> | ||
| ): OAuthClientInformationFull | Promise<OAuthClientInformationFull>; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.