Skip to content

Commit 9a8bd75

Browse files
committed
adding analytics
1 parent 0c5d15c commit 9a8bd75

File tree

6 files changed

+1414
-0
lines changed

6 files changed

+1414
-0
lines changed

GEMINI.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# GEMINI.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is an MCP (Model Context Protocol) OAuth 2.1 server implementation built with Next.js 15, providing secure authentication for MCP clients. The application serves as an OAuth authorization server that enables MCP clients to authenticate users and access protected MCP resources.
8+
9+
## Core Architecture
10+
11+
### Authentication Flow
12+
- **NextAuth.js**: Handles user authentication via Google OAuth provider
13+
- **OAuth 2.1 Server**: Custom implementation with PKCE support for MCP client authorization
14+
- **Database**: PostgreSQL with Prisma ORM storing OAuth clients, tokens, and user sessions
15+
- **MCP Integration**: Uses `@vercel/mcp-adapter` for MCP protocol handling
16+
17+
### Key Components
18+
- `app/auth.ts`: NextAuth configuration with Google provider and Prisma adapter
19+
- `app/api/oauth/`: OAuth 2.1 server endpoints (register, token, authorize)
20+
- `app/mcp/[transport]/route.ts`: MCP server with authentication middleware
21+
- `prisma/schema.prisma`: Database schema for OAuth entities and NextAuth models
22+
23+
### Database Schema
24+
The Prisma schema includes:
25+
- NextAuth models (User, Account, Session, VerificationToken)
26+
- OAuth 2.1 models (Client, AccessToken, AuthCode) with PKCE support
27+
- Proper foreign key relationships and cascading deletes
28+
29+
## Development Commands
30+
31+
```bash
32+
# Start development server
33+
pnpm dev
34+
35+
# Build for production
36+
pnpm build
37+
38+
# Start production server
39+
pnpm start
40+
41+
# Lint code
42+
pnpm lint
43+
44+
# Database operations
45+
pnpm prisma generate # Generate Prisma client
46+
pnpm prisma db push # Push schema changes to database
47+
pnpm prisma migrate dev # Create and apply migrations
48+
pnpm prisma studio # Open database admin interface
49+
```
50+
51+
## Environment Setup
52+
53+
Required environment variables:
54+
- `DATABASE_URL`: PostgreSQL connection string
55+
- `AUTH_SECRET`: NextAuth secret key
56+
- `GOOGLE_CLIENT_ID`: Google OAuth client ID
57+
- `GOOGLE_CLIENT_SECRET`: Google OAuth client secret
58+
- `REDIS_URL`: Optional Redis URL for SSE transport support
59+
60+
## Database Management
61+
62+
PostgreSQL must be running locally for development:
63+
```bash
64+
# Start PostgreSQL (macOS with Homebrew)
65+
brew services start postgresql@14
66+
67+
# Stop PostgreSQL
68+
brew services stop postgresql@14
69+
```
70+
71+
## MCP Integration
72+
73+
The MCP server (`app/mcp/[transport]/route.ts`) implements:
74+
- Bearer token authentication using OAuth access tokens
75+
- Token audience validation for security
76+
- CORS headers for cross-origin requests
77+
- Sample tool implementation (`add_numbers`)
78+
79+
## Security Considerations
80+
81+
- PKCE (Proof Key for Code Exchange) is implemented for public clients
82+
- Access tokens are validated against database and checked for expiration
83+
- Token audience validation prevents token misuse across different resources
84+
- Proper CORS configuration for MCP client access
85+
86+
## Testing MCP Integration
87+
88+
MCP clients can connect using:
89+
- SSE transport: `https://your-domain.com/mcp/sse`
90+
- HTTP transport: `https://your-domain.com/mcp/mcp`
91+
92+
Clients must include OAuth access token in Authorization header as Bearer token.
93+
94+
## Prisma Client Location
95+
96+
The Prisma client is generated to `generated/prisma/` directory (not the default location) as specified in the schema generator configuration.

0 commit comments

Comments
 (0)