# AGENT.md - mcp-remote-static Development Guide
## Commands
- **Build**: `pnpm build` (or `pnpm build:watch` for development)
- **Type check**: `pnpm check` (runs prettier and tsc)
- **Lint/Format**: `pnpm lint-fix` (prettier with write)
- **Test**: `pnpm test:unit` (or `pnpm test:unit:watch` for watch mode)
- **Run dev**:
- Standard: `npx tsx src/client.ts` or `npx tsx src/proxy.ts`
- Static OAuth: `npx tsx src/client-static.ts` or `npx tsx src/proxy-static.ts`
## Architecture
- **Project Type**: TypeScript ESM library for MCP (Model Context Protocol) remote proxy
- **Main Binaries**:
- `mcp-remote-static` (proxy-static.ts) - Proxy with static OAuth client
- `mcp-remote-client-static` (client-static.ts) - Client with static OAuth client
- **Core Libraries**: `/src/lib/` contains auth coordination, OAuth client, utils, types
- **OAuth Implementations**:
- **Static OAuth**: Uses `NonPkceOAuthProvider` with standard OAuth 2.0 authorization code flow for pre-registered clients
- **Transport**: Supports both HTTP and SSE transports with OAuth authentication
- **Config**: Uses `~/.mcp-auth/` directory for credential storage
## Code Style
- **Formatting**: Prettier with 140 char width, single quotes, no semicolons
- **Types**: Strict TypeScript, ES2022 target with bundler module resolution
- **Imports**: ES modules, use `.js` extensions for SDK imports
- **Error Handling**: EventEmitter pattern for auth flow coordination
- **Naming**: kebab-case for files, camelCase for variables/functions
- **Comments**: JSDoc for main functions, inline for complex auth flows
## Static OAuth Implementation
The static OAuth implementation provides support for pre-registered OAuth clients:
- **Files**: `*-static.ts` files in `/src/` and `/src/lib/`
- **Key Components**:
- `oauth-provider-static.ts`: Implements standard OAuth 2.0 authorization code flow
- `oauth-connect-static.ts`: Handles connection with static OAuth clients
- `proxy-static.ts`: Proxy binary for static OAuth mode
- `client-static.ts`: Client binary for static OAuth mode
- **Requirements**: Requires `--static-oauth-client-info` with `client_id` and optionally `client_secret`
- **Use Case**: Marketplace scenarios and OAuth servers that require pre-registered clients