Skip to content

Conversation

@koistya
Copy link
Member

@koistya koistya commented Aug 16, 2025

This PR reorganizes the package exports to make it clearer that browserAuth() and related functionality are specifically designed for Model Context Protocol (MCP) SDK integration.

Closes #16, Closes #20

What changed

New module structure

  • Created src/mcp.ts as a dedicated entry point for MCP SDK-specific exports
  • Added oauth-callback/mcp export path in package.json
  • Moved MCP-specific exports (browserAuth) to the new module
  • Added namespace export (mcp) to main module for backward compatibility

Exported types

The MCP module now exports all necessary types for advanced usage:

  • BrowserAuthOptions - Configuration options for browser OAuth flows
  • Tokens - OAuth token storage interface
  • TokenStore - Minimal storage interface for OAuth tokens
  • ClientInfo - Dynamic client registration data (RFC 7591)
  • OAuthSession - Active OAuth flow state for crash recovery
  • OAuthStore - Full OAuth state storage interface

Why this change

  1. Clarity: Makes it explicit that browserAuth() is designed for MCP SDK integration, not general OAuth usage
  2. Organization: Separates core OAuth functionality from MCP-specific features
  3. Type exports: Addresses missing type exports needed for custom implementations (Export missing TypeScript types for better integration support #16)
  4. Module boundaries: Better separation of concerns between core and MCP functionality (Rename browserAuth() to mcpAuth() to reflect MCP SDK specificity #20)

How to use

For MCP SDK users (recommended)

// Direct import - cleaner and more explicit
import { browserAuth, fileStore } from "oauth-callback/mcp";

const authProvider = browserAuth({
  store: fileStore(),
});

Alternative: Namespace import

// Via namespace - all MCP functionality grouped
import { mcp } from "oauth-callback";

const authProvider = mcp.browserAuth({
  store: mcp.fileStore(),
});

For core OAuth functionality

// Core OAuth remains in main export
import { getAuthCode, OAuthError } from "oauth-callback";

const result = await getAuthCode("https://example.com/oauth/authorize?...");

Migration guide

If you're currently importing browserAuth from the main export:

Before:

import { browserAuth, fileStore } from "oauth-callback";

After:

import { browserAuth, fileStore } from "oauth-callback/mcp";

Or use the namespace approach to maintain similar import structure:

import { mcp } from "oauth-callback";
const { browserAuth, fileStore } = mcp;

Build changes

  • Updated build script to compile both index.ts and mcp.ts separately
  • Fixed Bun bundler crash when building multiple entry points simultaneously
  • Both modules are now properly bundled (~56KB each)

Testing

  • ✅ All 22 existing tests pass
  • ✅ Build process works correctly with both modules
  • ✅ Package validation (publint) passes
  • ✅ Example code updated and tested
  • ✅ TypeScript declarations properly generated

Breaking changes

⚠️ Potentially breaking: If you import browserAuth directly from "oauth-callback", you'll need to update your imports to use "oauth-callback/mcp" or the namespace export.

This change makes the package more maintainable and clearer about the intended use of each export.

@koistya koistya merged commit 0a03dc7 into main Aug 16, 2025
6 checks passed
@koistya koistya deleted the dev branch August 16, 2025 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename browserAuth() to mcpAuth() to reflect MCP SDK specificity Export missing TypeScript types for better integration support

2 participants