authenticateClient (middleware/clientAuth.ts)

typescript-sdk · packages/server-legacy/src/auth/middleware/clientAuth.ts · typescript · Apache-2.0
auth, tag:embed-classified

Express middleware that authenticates OAuth clients using a store.

// Source: https://github.com/modelcontextprotocol/typescript-sdk | License: Apache-2.0
// Provided via justclaw.it.com; keep this notice with the code.
import type { OAuthClientInformationFull } from '@modelcontextprotocol/core-internal';
import type { RequestHandler } from 'express';
import * as z from 'zod/v4';

import type { OAuthRegisteredClientsStore } from '../clients';
import { InvalidClientError, InvalidRequestError, OAuthError, ServerError } from '../errors';

export type ClientAuthenticationMiddlewareOptions = {
    /**
     * A store used to read information about registered OAuth clients.
     */
    clientsStore: OAuthRegisteredClientsStore;
};

const ClientAuthenticatedRequestSchema = z.object({
    client_id: z.string(),
    client_secret: z.string().optional()
});

declare

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key