|
| 1 | +--- |
| 2 | +title: "Anthropic MCP Integration" |
| 3 | +sidebarTitle: "Anthropic" |
| 4 | +description: "Guide for integrating Anthropic's Claude models with PraisonAI agents using MCP" |
| 5 | +icon: "a" |
| 6 | +--- |
| 7 | + |
| 8 | +## Add Anthropic Tool to AI Agent |
| 9 | + |
| 10 | +```mermaid |
| 11 | +flowchart LR |
| 12 | + In[In] --> Agent[AI Agent] |
| 13 | + Agent --> Tool[Airbnb MCP] |
| 14 | + Tool --> Agent |
| 15 | + Agent --> Out[Out] |
| 16 | + |
| 17 | + style In fill:#8B0000,color:#fff |
| 18 | + style Agent fill:#2E8B57,color:#fff |
| 19 | + style Tool fill:#FF5A5F,color:#fff |
| 20 | + style Out fill:#8B0000,color:#fff |
| 21 | +``` |
| 22 | + |
| 23 | +## Quick Start |
| 24 | + |
| 25 | +<Steps> |
| 26 | + <Step title="Set API Key"> |
| 27 | + Set your Anthropic API key as an environment variable in your terminal: |
| 28 | + ```zsh |
| 29 | + export ANTHROPIC_API_KEY=your_anthropic_api_key_here |
| 30 | + ``` |
| 31 | + </Step> |
| 32 | + |
| 33 | + <Step title="Create a file"> |
| 34 | + Create a new file `anthropic_airbnb.py` with the following code: |
| 35 | + ```python |
| 36 | + from praisonaiagents import Agent, MCP |
| 37 | + import os |
| 38 | + |
| 39 | + # Get API key from environment variable |
| 40 | + anthropic_api_key = os.environ.get("ANTHROPIC_API_KEY") |
| 41 | + |
| 42 | + search_agent = Agent( |
| 43 | + instructions="""You help book apartments on Airbnb.""", |
| 44 | + llm="anthropic/claude-3-7-sonnet-20250219", |
| 45 | + tools=MCP( |
| 46 | + command="npx", |
| 47 | + args=["-y", "@openbnb/mcp-server-airbnb", "--ignore-robots-txt"], |
| 48 | + env={"ANTHROPIC_API_KEY": anthropic_api_key} |
| 49 | + ) |
| 50 | + ) |
| 51 | + |
| 52 | + search_agent.start("MUST USE airbnb_search Tool to Search. Search for Apartments in Paris for 2 nights. 04/28 - 04/30 for 2 adults. All Your Preference") |
| 53 | + ``` |
| 54 | + </Step> |
| 55 | + |
| 56 | + <Step title="Install Dependencies"> |
| 57 | + Make sure you have Node.js installed, as the MCP server requires it: |
| 58 | + ```bash |
| 59 | + pip install "praisonaiagents[llm]" |
| 60 | + ``` |
| 61 | + </Step> |
| 62 | + |
| 63 | + <Step title="Run the Agent"> |
| 64 | + Execute your script: |
| 65 | + ```bash |
| 66 | + python anthropic_airbnb.py |
| 67 | + ``` |
| 68 | + </Step> |
| 69 | +</Steps> |
| 70 | + |
| 71 | +<Note> |
| 72 | + **Requirements** |
| 73 | + - Python 3.10 or higher |
| 74 | + - Node.js installed on your system |
| 75 | + - Anthropic API key |
| 76 | +</Note> |
| 77 | + |
| 78 | +## Features |
| 79 | + |
| 80 | +<CardGroup cols={2}> |
| 81 | + <Card title="Claude 3.7 Sonnet" icon="brain"> |
| 82 | + Leverage Anthropic's powerful Claude 3.7 Sonnet model. |
| 83 | + </Card> |
| 84 | + <Card title="MCP Integration" icon="plug"> |
| 85 | + Seamless integration with Model Context Protocol. |
| 86 | + </Card> |
| 87 | + <Card title="Airbnb Search" icon="hotel"> |
| 88 | + Search for accommodations on Airbnb with natural language queries. |
| 89 | + </Card> |
| 90 | + <Card title="Environment Variables" icon="key"> |
| 91 | + Securely pass API keys using environment variables. |
| 92 | + </Card> |
| 93 | +</CardGroup> |
0 commit comments