Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 113 additions & 1 deletion examples/agents/claude-agent-descope-gmail/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,113 @@
# claude-agent-descope-gmail
# Claude MCP Gmail Agent with Human-in-the-Loop Approval

A secure AI agent that integrates Gmail using Claude's Agents SDK, Model Context Protocol (MCP), and Descope for authentication, authorization, and progressive OAuth scoping with human approval for sensitive actions.
Comment on lines +1 to +3
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intro says this agent integrates Gmail using “Claude's Agents SDK”, but the implementation under src/ appears to use @anthropic-ai/sdk directly and does not import or reference @anthropic-ai/claude-agent-sdk. Please update the README to match the actual SDK used, or update the code to use the Agents SDK if that’s the intent.

Copilot uses AI. Check for mistakes.

## Features

- 📧 Read emails from Gmail inbox
- ✉️ Send emails with approval workflow
- 🔐 Progressive OAuth scoping (permissions requested on-demand)
- 🎫 Human-in-the-loop approval via Descope Enchanted Links
- 🔒 Agent never directly handles Gmail tokens (Agent → MCP → Descope → Gmail)

Comment on lines +10 to +12
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README claims the agent “never directly handles Gmail tokens”, but src/cli-agent.ts fetches a Gmail access token from Descope (/v1/mgmt/outbound/app/user/token/latest) and uses it to call the Gmail API directly when sending an approved email. This is a security/architecture mismatch; please adjust the README description (and the Architecture/Security sections) to reflect the real token flow.

Copilot uses AI. Check for mistakes.
## Prerequisites

- Node.js 18+
- Descope account and project
- Anthropic API key
- Google Cloud project with Gmail API enabled

## Quick Start

### 1. Install Dependencies

```bash
npm install
```

### 2. Configure Descope

**Create Inbound App:**
1. Go to Descope Console → Applications → Inbound Apps
2. Create new application
3. Add scopes: `google-read`, `google-send`
4. Note your Project ID, MCP Server ID, Client ID, and Client Secret

**Create Connection:**
1. Go to Applications → Connections → Add Connection
2. Select Gmail
3. App ID: `gmail`
4. OAuth Scopes: `gmail.readonly`, `gmail.send`
5. Redirect URL: `http://localhost:3000/connection-complete`

**Enable Enchanted Link:**
1. Go to Authentication Methods → Enchanted Link
2. Enable and configure

### 3. Set Environment Variables

Create a `.env` file:

```env
ANTHROPIC_API_KEY=your_anthropic_api_key_here
DESCOPE_PROJECT_ID=your_descope_project_id_here
DESCOPE_CLIENT_ID=your_descope_client_id_here
DESCOPE_CLIENT_SECRET=your_descope_client_secret_here
MCP_SERVER_ID=your_mcp_server_id_here
```
Comment on lines +49 to +57
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .env variables listed here don’t match the checked-in .env.example (which currently omits DESCOPE_CLIENT_ID). Since src/auth.ts requires DESCOPE_CLIENT_ID, consider either updating the README to reference .env.example or ensuring the documented env vars stay in sync with it to prevent setup confusion.

Copilot uses AI. Check for mistakes.

### 4. Run the Agent

```bash
npm start
```

## Usage

**Read emails:**
```
You: Read my latest emails
```

**Send email:**
```
You: Send an email to test@example.com with subject "Hello" and body "Test message"
```

The agent will request Gmail permissions only when needed and require approval before sending any email.

## Architecture

```
User → Agent (Claude) → MCP Server → Descope → Gmail API
```

The agent never directly handles Gmail OAuth tokens. The MCP server requests them from Descope, creating an extra security boundary.
Comment on lines +81 to +85
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The architecture diagram shows “User → Agent → MCP Server → Descope → Gmail API”, but the current implementation also calls Descope/Gmail directly from the agent process (e.g., approval route in src/cli-agent.ts). Please update the diagram/description to match the actual call paths so readers don’t assume all Gmail calls are isolated behind the MCP server.

Copilot uses AI. Check for mistakes.

## Security

- **Authentication**: OAuth 2.0 via Descope Inbound Apps
- **Authorization**: Tool-level scopes
- **Progressive Scoping**: Gmail permissions requested on-demand
- **Human Approval**: Enchanted Links for sensitive actions
- **Token Isolation**: Agent never touches Gmail tokens

## Project Structure

```
src/
├── cli-agent.ts # Main agent
├── mcp-stdio.ts # MCP server with Gmail tools
├── auth.ts # Descope authentication
└── approval.ts # Enchanted Link approval
```

## Learn More

- [Claude Agents SDK](https://github.com/anthropics/anthropic-sdk-typescript)
- [Model Context Protocol](https://modelcontextprotocol.io/)
- [Descope Documentation](https://docs.descope.com/)

## License

MIT
Comment on lines +111 to +113
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README lists the project license as MIT, but package.json in this example declares ISC. Please align the README License section with the actual licensing for this package (or update package.json if MIT is intended).

Copilot uses AI. Check for mistakes.