# @snokam/salesforce-mcp

MCP (Model Context Protocol) server for Salesforce CRM integration. Enables AI agents like Olaf to interact with Salesforce data directly.

## Features

- 🔍 **Search contacts, leads, and accounts**
- 📊 **View opportunities pipeline**
- 📝 **Create tasks**
- 🔧 **Execute custom SOQL queries** (read-only)
- 📋 **Get recent activities**

## Installation

```bash
cd backend/apps/salesforce-mcp
pnpm install
pnpm build
```

## Configuration

Uses the same environment variables as the existing `chatgpt-function`:

```env
SALESFORCE_CONSUMER_KEY=your_connected_app_consumer_key
SALESFORCE_CONSUMER_SECRET=your_connected_app_consumer_secret
```

Uses `client_credentials` OAuth flow against `https://snokam.my.salesforce.com`.

## Usage with mcporter

Add to your `~/.mcporter/config.yaml`:

```yaml
servers:
  salesforce:
    command: node
    args:
      - /path/to/monorepo/backend/apps/salesforce-mcp/dist/index.js
    env:
      SALESFORCE_CONSUMER_KEY: ${SALESFORCE_CONSUMER_KEY}
      SALESFORCE_CONSUMER_SECRET: ${SALESFORCE_CONSUMER_SECRET}
```

## Available Tools

| Tool                        | Description                                                     |
| --------------------------- | --------------------------------------------------------------- |
| `search_contacts`           | Search contacts by name, email, or company                      |
| `search_leads`              | Search leads with optional status filter                        |
| `search_accounts`           | Search accounts/companies with type filter                      |
| `get_account`               | Get detailed account info with contacts and opportunities       |
| `get_opportunities`         | View pipeline with stage/account filters                        |
| `get_strategic_contacts`    | Get contacts from strategic priority accounts needing follow-up |
| `get_contact_activities`    | Get recent events and tasks for a contact                       |
| `get_comprehensive_contact` | Full contact info with account details and activities           |
| `soql_query`                | Execute custom SOQL queries (SELECT only)                       |

## Development

```bash
pnpm dev  # Run with tsx
```

## Jira

- SNO-3449: Sette opp MCP-server for Salesforce-integrasjon
