Skip to main content
Glama
node-oauth-client-provider.ts2.19 kB
import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js' import type { OAuthClientInformation, OAuthClientMetadata, OAuthTokens } from '@modelcontextprotocol/sdk/shared/auth.js' import open from 'open' import type { AuthCoordinator } from './auth-coordinator' export type InvalidateCredentialsScope = 'all' | 'client' | 'tokens' | 'verifier' export class NodeOauthClientProvider implements OAuthClientProvider { constructor(private readonly coordinator: AuthCoordinator) {} public get clientMetadata(): OAuthClientMetadata { return { client_name: 'Sequa MCP Proxy', redirect_uris: [this.redirectUrl] } } public get redirectUrl(): string { return this.coordinator.getRedirectUrl() } public async clientInformation(): Promise<OAuthClientInformation | undefined> { return await this.coordinator.getClientInformation() } public async saveClientInformation(clientInformation: OAuthClientInformation): Promise<void> { await this.coordinator.saveClientInformation(clientInformation) } public async state(): Promise<string> { return encodeURIComponent(this.coordinator.getServerUrl().toString()) } public async redirectToAuthorization(authorizationUrl: URL): Promise<void> { const url = authorizationUrl.toString() if (!url.startsWith('http://') && !url.startsWith('https://')) { throw new Error('Invalid authorization url URL') } await open(url) } public async codeVerifier(): Promise<string> { const codeVerifier = await this.coordinator.getCodeVerifier() if (!codeVerifier) { throw new Error('Code verifier is not set') } return codeVerifier } public async saveCodeVerifier(codeVerifier: string): Promise<void> { await this.coordinator.saveCodeVerifier(codeVerifier) } public async tokens(): Promise<OAuthTokens | undefined> { return await this.coordinator.getTokens() } public async saveTokens(tokens: OAuthTokens): Promise<void> { await this.coordinator.saveTokens(tokens) } public async invalidateCredentials(scope: InvalidateCredentialsScope): Promise<void> { await this.coordinator.invalidateCredentials(scope) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sequa-ai/sequa-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server