> ## Documentation Index
> Fetch the complete documentation index at: https://docs.privetag.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Integration

> Native Model Context Protocol integration for Claude and other AI assistants

# MCP Integration

PriveTag provides a native MCP (Model Context Protocol) server for seamless integration with Claude Desktop and other MCP-compatible AI assistants.

<Info>
  **MCP** (Model Context Protocol) is Anthropic's open standard for connecting AI assistants to external data sources and tools.
</Info>

## Quick Start

### Installation

```bash theme={null}
# Install the MCP server globally
npm install -g @privetag/mcp-server

# Or use npx directly
npx @privetag/mcp-server start
```

### Claude Desktop Configuration

Add PriveTag to your Claude Desktop config (`claude_desktop_config.json`):

```json theme={null}
{
  "mcpServers": {
    "privetag": {
      "command": "npx",
      "args": ["@privetag/mcp-server", "start"],
      "env": {
        "PRIVETAG_API_KEY": "pk_your_api_key_here"
      }
    }
  }
}
```

<Tip>
  Find your Claude Desktop config at:

  * **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
  * **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
</Tip>

### Restart Claude Desktop

After adding the configuration, restart Claude Desktop. You should see "PriveTag" in the connected tools.

## Available Tools

The MCP server exposes three tools to Claude:

### privetag\_recommend

Get context-aware activity recommendations.

**Parameters:**

| Name          | Type      | Required | Description                                       |
| ------------- | --------- | -------- | ------------------------------------------------- |
| `travel_type` | string    | Yes      | `family`, `couple`, `solo`, `business`, `friends` |
| `city`        | string    | Yes      | City name (e.g., `Bangkok`, `Phuket`)             |
| `interests`   | string\[] | No       | Activity categories                               |
| `budget`      | string    | No       | `budget`, `mid`, `luxury`                         |
| `lat`         | number    | No       | Latitude for weather-aware recommendations        |
| `lon`         | number    | No       | Longitude for weather-aware recommendations       |

**Example Claude Prompt:**

```
"What activities would you recommend for a family visiting Bangkok today?"
```

**Claude will call:**

```json theme={null}
{
  "tool": "privetag_recommend",
  "arguments": {
    "travel_type": "family",
    "city": "Bangkok"
  }
}
```

### privetag\_book

Execute a booking and send voucher to user.

**Parameters:**

| Name             | Type   | Required | Description             |
| ---------------- | ------ | -------- | ----------------------- |
| `activity_id`    | string | Yes      | From recommendations    |
| `user_email`     | string | Yes      | For voucher delivery    |
| `user_name`      | string | Yes      | Guest name              |
| `booking_date`   | string | Yes      | ISO date format         |
| `num_adults`     | number | Yes      | Number of adults        |
| `num_children`   | number | No       | Number of children      |
| `context_log_id` | string | No       | For conversion tracking |

**Example Claude Prompt:**

```
"Book Safari World for John Doe (john@example.com) for tomorrow, 2 adults"
```

### privetag\_inventory

Check real-time availability and deals.

**Parameters:**

| Name               | Type    | Required | Description              |
| ------------------ | ------- | -------- | ------------------------ |
| `city`             | string  | Yes      | City to search           |
| `date`             | string  | No       | Specific date            |
| `category`         | string  | No       | Activity category filter |
| `flash_deals_only` | boolean | No       | Only show deals          |

**Example Claude Prompt:**

```
"Are there any spa deals available in Phuket today?"
```

## Tool Descriptions (GEO Optimized)

The MCP server provides AI-optimized tool descriptions:

```javascript theme={null}
{
  name: "privetag_recommend",
  description: `Get travel activity recommendations.

USE THIS TOOL WHEN the user:
- Asks "what should we do" in a city
- Wants activity suggestions based on travel type
- Needs weather-appropriate recommendations
- Is looking for things to do with family/couple/solo

DO NOT USE THIS TOOL for:
- General travel planning questions
- Flight or hotel bookings
- Restaurant-only recommendations`,
  inputSchema: { /* ... */ }
}
```

## Advanced Configuration

### Custom Base URL

For enterprise or self-hosted deployments:

```json theme={null}
{
  "mcpServers": {
    "privetag": {
      "command": "npx",
      "args": ["@privetag/mcp-server", "start"],
      "env": {
        "PRIVETAG_API_KEY": "pk_your_api_key",
        "PRIVETAG_BASE_URL": "https://your-custom-endpoint.com"
      }
    }
  }
}
```

### Debug Mode

Enable verbose logging:

```json theme={null}
{
  "mcpServers": {
    "privetag": {
      "command": "npx",
      "args": ["@privetag/mcp-server", "start", "--debug"],
      "env": {
        "PRIVETAG_API_KEY": "pk_your_api_key"
      }
    }
  }
}
```

## Example Conversations

### Family Trip Planning

**User:** "We're a family of 4 (2 adults, 2 kids) visiting Bangkok next week. What activities would you recommend?"

**Claude:** *\[Calls privetag\_recommend with travel\_type: "family", city: "Bangkok"]*

"Based on your family profile, here are the top recommendations:

1. **Safari World Bangkok** - Perfect for kids, includes a safari drive and marine park. ฿1,500/person
2. **Dream World Theme Park** - Exciting rides suitable for all ages. ฿1,200/person
3. **SEA LIFE Bangkok** - Indoor aquarium, great for hot days. ฿990/person

Would you like me to book any of these?"

**User:** "Yes, let's book Safari World for December 15th. My email is [family@example.com](mailto:family@example.com)"

**Claude:** *\[Calls privetag\_book with activity\_id, user\_email, booking\_date, num\_adults: 2]*

"I've booked Safari World for December 15th. A voucher with QR code has been sent to [family@example.com](mailto:family@example.com). Just show the QR at the entrance!"

### Rainy Day Recommendations

**User:** "It's raining in Phuket. What can we do indoors?"

**Claude:** *\[Calls privetag\_recommend with city: "Phuket", lat/lon for weather context]*

"Given the rainy weather in Phuket, here are indoor options:

1. **Oasis Spa Signature Package** - 40% OFF flash deal! ฿1,800 (was ฿3,000)
2. **Phuket Trickeye Museum** - 3D art museum, fun for photos
3. **Central Festival Shopping** - AC shopping complex

The spa has a flash deal that expires at 6 PM - would you like to grab it?"

## Error Handling

The MCP server handles errors gracefully:

```json theme={null}
{
  "error": {
    "code": "ACTIVITY_UNAVAILABLE",
    "message": "Safari World is closed on Mondays",
    "suggestion": "Try booking for Tuesday through Sunday"
  }
}
```

Claude will interpret these errors and suggest alternatives to the user.

## Best Practices

<AccordionGroup>
  <Accordion title="Always provide context_log_id">
    When Claude books an activity, it should pass the context\_log\_id from recommendations. This enables the Ground Truth feedback loop.
  </Accordion>

  <Accordion title="Use lat/lon for weather-aware recommendations">
    When the user's location is known, pass coordinates for weather-appropriate suggestions.
  </Accordion>

  <Accordion title="Check inventory before booking">
    For dates more than a week out, use `privetag_inventory` to verify availability before committing to book.
  </Accordion>

  <Accordion title="Handle booking failures gracefully">
    If a booking fails, Claude should suggest alternatives from the original recommendations.
  </Accordion>
</AccordionGroup>

## Supported MCP Clients

| Client          | Status      | Notes                 |
| --------------- | ----------- | --------------------- |
| Claude Desktop  | ✅ Supported | Full integration      |
| Claude.ai       | 🔜 Coming   | Web-based MCP support |
| Cline (VS Code) | ✅ Supported | Development use       |
| Continue        | ✅ Supported | Development use       |

## Troubleshooting

### Server Not Starting

```bash theme={null}
# Check if the server runs manually
npx @privetag/mcp-server start --debug

# Verify API key is valid
curl -H "x-api-key: pk_your_key" https://api.privetag.com/api/health
```

### Tools Not Appearing in Claude

1. Check `claude_desktop_config.json` syntax
2. Ensure API key is set correctly
3. Restart Claude Desktop completely
4. Check Claude's MCP logs (Help → Debug → MCP Logs)

### Rate Limiting

If you hit rate limits, the MCP server will return:

```json theme={null}
{
  "error": {
    "code": "RATE_LIMITED",
    "retry_after": 15
  }
}
```

Claude will wait and retry automatically.

## Next Steps

<CardGroup cols={2}>
  <Card title="Context Pipeline" icon="diagram-project" href="/b2a-platform/context-pipeline">
    How recommendations are personalized
  </Card>

  <Card title="LangChain Integration" icon="link" href="/b2a-platform/langchain">
    Alternative integration option
  </Card>
</CardGroup>
