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

#  MCP

> How to Use MCP in AI21 Studio 

MCP (Model Context Protocol) is an open-source standard for connecting AI applications to external systems. Follow these steps to connect your agent in **AI21 Studio** to an MCP server.

### Step 1: **Go to the Playground Section**

<Expandable title="Content">
  Navigate to Maestro [**Playground**](https://studio.ai21.com/v2?tab=maestro) from the left-hand menu in AI21 Studio.

  <img src="https://mintcdn.com/ai21-demo/LNlHHKfViioyL7qE/Step1GotothePlaygroundSection.png?fit=max&auto=format&n=LNlHHKfViioyL7qE&q=85&s=cd37a1abd98d3b0593ce7cb5aff9a18f" alt="Dataconnectorsallscreen Pn" width="1498" height="709" data-path="Step1GotothePlaygroundSection.png" />
</Expandable>

### Step 2: Add a Tool

<Expandable title="Content">
   In the **Configuration** panel, go to the **Tools** section and click **Add**.

  <img src="https://mintcdn.com/ai21-demo/LNlHHKfViioyL7qE/images/Step2AddaTool.png?fit=max&auto=format&n=LNlHHKfViioyL7qE&q=85&s=9411bc6315736e17e3397d6a9f6e8e8d" alt="Step2adda Tool Pn" width="1489" height="722" data-path="images/Step2AddaTool.png" />
</Expandable>

### **Step 3: Select MCP**

<Expandable title="Content">
  In the tools dropdown, select **MCP**.

  <img src="https://mintcdn.com/ai21-demo/drMbiQRvxIxU7C7B/images/stage3mcptool.png?fit=max&auto=format&n=drMbiQRvxIxU7C7B&q=85&s=5037b5f1eb78f1fb05add8fe390dcf52" alt="Stage3mcptool Pn" width="1721" height="925" data-path="images/stage3mcptool.png" />
</Expandable>

### **Step 4: Fill in the Fields**

<Expandable title="Content">
  **4.1 Add a URL**\
  Enter the MCP server address in the **URL** field.

  <img src="https://mintcdn.com/ai21-demo/PSuwdIHwl54ddQPs/images/4.1mcpurl.png?fit=max&auto=format&n=PSuwdIHwl54ddQPs&q=85&s=438fce8c33ae9caa60f10d6ef4361426" alt="4 1mcpurl Pn" width="1488" height="729" data-path="images/4.1mcpurl.png" />

  <Note>
    **Handling “Invalid URL” Errors**\
    \
    If you see the **“Invalid URL”** error when adding your MCP server in AI21 Studio, it usually means:

    * The server is using `http://` instead of `https://`
    * The server is running on a raw IP address and isn’t exposed as a public HTTPS endpoint

    **How to fix it:** Set up an **ngrok tunnel** (or a similar tool) to expose your local server over HTTPS, which passes validation.

    \
    For full setup instructions, see the [MCP Server Setup guide](https://docs.ai21.com/docs/mcp-server-setup-guide).
  </Note>

  \
  **4.2 Add a Label**\
  Enter a descriptive **Label** to identify the MCP server.

  <img src="https://mintcdn.com/ai21-demo/PSuwdIHwl54ddQPs/images/4.2mcplabel.png?fit=max&auto=format&n=PSuwdIHwl54ddQPs&q=85&s=1e7b8a19fba8a805d166623c97a69b10" alt="4 2mcplabel Pn" width="1484" height="729" data-path="images/4.2mcplabel.png" />

  **4.3 Add Authentication** \
  From the **Authentication** dropdown, select the authentication method (for example, API key or access token) and provide the credentials.

  <Note>
    Authorization headers are not saved with the agent. If you save the agent, the headers will not be stored. When you reload the agent, you’ll need to enter the authorization headers again.
  </Note>

  <img src="https://mintcdn.com/ai21-demo/EsOA37anh3HWatHi/images/4.3AddAuthentication.png?fit=max&auto=format&n=EsOA37anh3HWatHi&q=85&s=bc34b883fc93c21811f8d6d7a5286aa5" alt="4 3add Authentication Pn" width="1481" height="730" data-path="images/4.3AddAuthentication.png" />
</Expandable>

### **Step 5: Review Allowed Tools**

<Expandable title="Content">
  Click **Review allowed tools**.

  <img src="https://mintcdn.com/ai21-demo/PSuwdIHwl54ddQPs/images/Step5ReviewAllowedTools.png?fit=max&auto=format&n=PSuwdIHwl54ddQPs&q=85&s=66f9332406e3a01b8e2ff10901559802" alt="Step5review Allowed Tools Pn" width="1483" height="732" data-path="images/Step5ReviewAllowedTools.png" />

  You will see a list of tools available from the MCP server.
</Expandable>

### **Step 6: Save the Tools**

<Expandable title="Content">
  After verifying the tools are correct, click **Save**.
</Expandable>

### **Step 7 (Optional): Edit MCP Tools**

<Expandable title="Content">
  Edit an existing MCP tool by following these steps:

  1. Click the **⋮** (colon icon).
  2. Select **Edit**, make your changes, and click **Save.**

  <img src="https://mintcdn.com/ai21-demo/1c9AiCFNhfpxWOZR/images/EditMCPTools1.png?fit=max&auto=format&n=1c9AiCFNhfpxWOZR&q=85&s=0c7cf19e079c139aac6c5ee3f22bfb0b" alt="Edit MCP Tools1 Pn" width="871" height="576" data-path="images/EditMCPTools1.png" />

  <img src="https://mintcdn.com/ai21-demo/1c9AiCFNhfpxWOZR/images/EditMCPTools2.png?fit=max&auto=format&n=1c9AiCFNhfpxWOZR&q=85&s=490b398722a1a72a61457c1b7a1376c4" alt="Edit MCP Tools2 Pn" width="627" height="474" data-path="images/EditMCPTools2.png" />
</Expandable>

### Next Steps

Use MCP in [AI21 Stuido](https://studio.ai21.com/v2?tab=maestro).
