# MCP Setup Guide

This guide walks you through setting up the Templated MCP server with different AI assistants.

## Prerequisites

Before you begin, make sure you have:

1. A Templated account — <a href="https://app.templated.io/signup" target="_blank" rel="noopener noreferrer">Sign up for free</a>
2. Your API key — Find it in your <a href="https://app.templated.io/api-key" target="_blank" rel="noopener noreferrer">dashboard</a>

For local server mode, you'll also need:
- Node.js 18 or higher installed

## Claude Desktop

Claude Desktop supports both remote and local MCP servers.

### Option 1: Connectors Directory (Recommended)

Templated is listed in the Claude connectors directory, so there is nothing to install or paste.

1. **Open the Templated listing**

   Go to <a href="https://claude.ai/directory/templatedio" target="_blank" rel="noopener noreferrer">claude.ai/directory/templatedio</a>. You can also find it in Claude Desktop under **Settings** → **Connectors**, or on Claude.ai under **Customize** → **Connectors**, by searching for **Templated**.

2. **Connect**

   Click **Connect** (on Team and Enterprise plans, **Connect for your team**).

3. **Sign in to Templated**

   When prompted, sign in to your Templated account to authorize the connection.

4. **Verify the connection**

   Look for a tools icon (hammer) in the chat input area. Click it to see available Templated tools.

<Aside type="note">
On Team and Enterprise plans an admin may need to enable the connector for the organization first. If the connector is not available in your directory, add it as a custom connector instead: **Settings** → **Connectors** → **Add custom connector** with the URL `https://mcp.templated.io/mcp`.
</Aside>

### Option 2: Local Server

1. **Locate your config file**
   
   The Claude Desktop configuration file is located at:
   - **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
   - **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`

2. **Edit the configuration**
   
   Open the file and add the Templated MCP server:

   ```json title="claude_desktop_config.json" "YOUR_API_KEY"
   {
     "mcpServers": {
       "templated": {
         "command": "npx",
         "args": ["mcp-server-templated"],
         "env": {
           "TEMPLATED_API_KEY": "YOUR_API_KEY"
         }
       }
     }
   }
   ```

   Replace `YOUR_API_KEY` with your actual API key.

3. **Restart Claude Desktop**
   
   Completely quit and reopen Claude Desktop for the changes to take effect.

4. **Verify the connection**
   
   Look for a tools icon (hammer) in the chat input area. Click it to see available Templated tools.

<Aside type="tip">
If you have existing MCP servers configured, add `"templated"` to the existing `mcpServers` object rather than replacing the entire file.
</Aside>

## Cursor IDE

The fastest way is the install button, which opens Cursor with the server pre-configured:

<a href="https://cursor.com/en/install-mcp?name=templated&config=eyJ1cmwiOiJodHRwczovL21jcC50ZW1wbGF0ZWQuaW8vbWNwIn0=" target="_blank" rel="noopener noreferrer"><img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Add Templated to Cursor" /></a>

Then click **Login** next to the server and sign in to your Templated account.

### Manual setup

1. **Locate your config file**
   
   The Cursor MCP configuration file is located at:
   - **macOS/Linux:** `~/.cursor/mcp.json`
   - **Windows:** `%USERPROFILE%\.cursor\mcp.json`

2. **Create or edit the configuration**
   
   ```json title="mcp.json"
   {
     "mcpServers": {
       "templated": {
         "url": "https://mcp.templated.io/mcp"
       }
     }
   }
   ```

3. **Restart Cursor**
   
   Close and reopen Cursor for the changes to take effect.

4. **Sign in when prompted**

   Cursor shows a **Login** button on first use. Click it and sign in to your Templated account to authorize the connection.

5. **Start using Templated**
   
   In the Composer or Chat panel, you can now ask Cursor to use Templated tools.

#### Alternative: API key header

For automations, or if you prefer not to use OAuth, send your API key in the `Authorization` header instead:

```json title="mcp.json" "YOUR_API_KEY"
{
  "mcpServers": {
    "templated": {
      "url": "https://mcp.templated.io/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}
```

Replace `YOUR_API_KEY` with your actual API key.

### Local Server

1. **Locate your config file**
   
   Same location as above.

2. **Edit the configuration**
   
   ```json title="mcp.json" "YOUR_API_KEY"
   {
     "mcpServers": {
       "templated": {
         "command": "npx",
         "args": ["mcp-server-templated"],
         "env": {
           "TEMPLATED_API_KEY": "YOUR_API_KEY"
         }
       }
     }
   }
   ```

3. **Restart Cursor**

## ChatGPT

ChatGPT supports remote MCP servers only.

### Option 1: Plugin Directory (Recommended)

Templated is listed in the ChatGPT plugin directory, so there is nothing to install or paste.

1. **Open the Templated listing**

   Go to <a href="https://chatgpt.com/plugins/plugin_asdk_app_697a947e772c8191b888e4e23376bcf2" target="_blank" rel="noopener noreferrer">the Templated plugin in ChatGPT</a>. You can also select **Plugins** in the ChatGPT sidebar (or **Settings** → **Plugins**) and search for **Templated**.

2. **Connect**

   Click **Connect**.

3. **Sign in to Templated**

   When prompted, sign in to your Templated account to authorize the connection.

4. **Start using Templated**

   In any conversation, mention **Templated** in your prompt (for example, "Use Templated to render my certificate template for Jane Doe") or pick it from the **+** menu in the chat input.

<Aside type="note">
On Business and Enterprise workspaces an admin may need to enable the Templated plugin for the workspace first.
</Aside>

<Aside type="tip">
ChatGPT also has its own image generator. If it answers with a generated image instead of using your template, say so explicitly, for example "Using Templated (not image generation), render ...".
</Aside>

### Option 2: Custom App (Developer Mode)

If the plugin is not available in your workspace, you can add the server as a custom app.

1. **Turn on Developer mode**

   Go to **Settings** → **Apps** → **Advanced settings** and turn on **Developer mode**. On Business and Enterprise workspaces only admins can do this.

2. **Create the app**

   Click **Create app** and enter:
   - **Name:** Templated
   - **MCP Server URL:** `https://mcp.templated.io/mcp`
   - **Authentication:** OAuth

3. **Sign in to Templated**

   ChatGPT will prompt you to sign in to your Templated account to authorize the connection.

#### Alternative: API key in the URL

For automations, or if you prefer not to use OAuth, include your API key directly in the URL and set authentication to **"No Auth"**:

```
https://mcp.templated.io/mcp?apiKey=YOUR_API_KEY
```

Replace `YOUR_API_KEY` with your actual API key.

## Claude.ai (Web and Mobile)

Claude.ai uses the same connectors directory as Claude Desktop.

1. **Open the Templated listing**

   Go to <a href="https://claude.ai/directory/templatedio" target="_blank" rel="noopener noreferrer">claude.ai/directory/templatedio</a>, or open **Customize** → **Connectors** in the sidebar and search for **Templated**.

2. **Connect**

   Click **Connect** (on Team and Enterprise plans, **Connect for your team**).

3. **Sign in to Templated**

   When prompted, sign in to your Templated account to authorize the connection.

4. **Start chatting**

   The Templated tools will now be available in your conversations, including on the mobile apps and in Cowork.

<Aside type="note">
Prefer a custom connector? **Customize** → **Connectors** → **Add custom connector** with the URL `https://mcp.templated.io/mcp` works the same way.
</Aside>

## Claude Code

Claude Code supports the Templated MCP server through the CLI.

1. **Add the server**

   Run this command in your terminal:

   ```bash
   claude mcp add --transport http templated https://mcp.templated.io/mcp
   ```

2. **Authenticate**

   Inside Claude Code, run:

   ```
   /mcp
   ```

   and follow the prompts to sign in to your Templated account.

3. **Start using Templated**

   Once connected, you can ask Claude Code to use Templated tools.

## Scoping Access

When building multi-tenant applications (e.g. a chat interface where each customer edits their own templates), you can scope the MCP server so that each session only has access to a specific subset of resources. This is enforced at the server level, making it immune to prompt injection.

You can scope by **folder ID**, **external ID**, or both.

<Aside type="note">
Scoping parameters work with either authentication mode. You can combine `folderId` or `externalId` with an OAuth login (e.g. `https://mcp.templated.io/mcp?folderId=FOLDER_ID`), or with an API key sent as an `Authorization: Bearer YOUR_API_KEY` header. For server-to-server multi-tenant setups, keep using the API key since there's no interactive user available to complete an OAuth login.
</Aside>

### External ID Scoping

If you already use `externalId` to link templates to your own customers (e.g. via the [Embedded Editor](/docs/embed/)), you can use the same identifier to scope MCP access.

When set, the MCP server will:
<ul>
  <li class="list-disc">Only list templates and renders matching that external ID</li>
  <li class="list-disc">Automatically assign the external ID to new templates</li>
  <li class="list-disc">Reject any operation on a template that doesn't match</li>
</ul>

<Tabs>
  <TabItem label="Remote Server" icon="cloud">
    Add the `externalId` query parameter to the URL, and send your API key in the `Authorization: Bearer YOUR_API_KEY` header:

    ```
    https://mcp.templated.io/mcp?externalId=CUSTOMER_123
    ```
  </TabItem>

  <TabItem label="Local Server" icon="laptop">
    Set the `TEMPLATED_EXTERNAL_ID` environment variable:

    ```json
    {
      "mcpServers": {
        "templated": {
          "command": "npx",
          "args": ["mcp-server-templated"],
          "env": {
            "TEMPLATED_API_KEY": "YOUR_API_KEY",
            "TEMPLATED_EXTERNAL_ID": "CUSTOMER_123"
          }
        }
      }
    }
    ```
  </TabItem>
</Tabs>

### Folder ID Scoping

You can also restrict access to a specific folder. When set, the MCP server will:
<ul>
  <li class="list-disc">Only list templates and renders from that folder</li>
  <li class="list-disc">Automatically move new templates into the folder</li>
  <li class="list-disc">Reject any operation on a template outside the folder</li>
  <li class="list-disc">Hide folder management tools (since the folder is fixed)</li>
</ul>

<Tabs>
  <TabItem label="Remote Server" icon="cloud">
    Add the `folderId` query parameter to the URL, and send your API key in the `Authorization: Bearer YOUR_API_KEY` header:

    ```
    https://mcp.templated.io/mcp?folderId=FOLDER_ID
    ```
  </TabItem>

  <TabItem label="Local Server" icon="laptop">
    Set the `TEMPLATED_FOLDER_ID` environment variable:

    ```json
    {
      "mcpServers": {
        "templated": {
          "command": "npx",
          "args": ["mcp-server-templated"],
          "env": {
            "TEMPLATED_API_KEY": "YOUR_API_KEY",
            "TEMPLATED_FOLDER_ID": "FOLDER_ID"
          }
        }
      }
    }
    ```
  </TabItem>
</Tabs>

### Combining Both

You can use both scoping parameters together for stricter isolation. For example, to restrict access to a specific folder AND external ID:

```
https://mcp.templated.io/mcp?folderId=FOLDER_ID&externalId=CUSTOMER_123
```

<Aside type="tip">
For most multi-tenant use cases, **external ID scoping alone is sufficient**. It maps directly to your customer/user identifier and doesn't require managing a folder per customer.
</Aside>

## Troubleshooting

### Server not connecting

<Aside type="caution" title="Common Issues">
- **Invalid API key:** Double-check your API key is correct
- **JSON syntax error:** Validate your config file is valid JSON
- **Node.js not found:** For local server, ensure Node.js 18+ is installed and in your PATH
- **Server timeout:** Check your internet connection
</Aside>

### Tools not appearing

If the tools don't appear after configuration:

1. **Completely restart** the AI assistant (not just close the window)
2. **Check the config file location** — it must be in the exact path specified
3. **Verify JSON syntax** — use a JSON validator to check for errors
4. **Check for existing configs** — you may need to merge with existing `mcpServers`

### Local server errors

If using local server mode:

```bash
# Verify Node.js version
node --version  # Should be 18.0.0 or higher

# Test the MCP server directly
TEMPLATED_API_KEY=your_key npx mcp-server-templated
```

### Sign-in or authorization problems

- **The sign-in window doesn't open:** allow pop-ups for your AI assistant and try **Connect** again.
- **Connected to the wrong account:** on the authorization screen, click **Switch account** before authorizing, or disconnect and connect again.
- **"Unknown application" on the authorization screen:** start the connection again from your AI assistant so it registers a fresh client.
- **Tools fail with an authorization error:** your API key may have been regenerated. Disconnect and connect again.

### Disconnecting and revoking access

- **Claude:** open **Customize** → **Connectors**, select Templated and click **Disconnect**.
- **ChatGPT:** open **Settings** → **Plugins**, select Templated and disconnect it.
- **Cursor and other clients:** remove the `templated` entry from your MCP configuration.

Access granted through OAuth uses your team's API key. To revoke every connection at once, regenerate the key on the <a href="https://app.templated.io/api-key" target="_blank" rel="noopener noreferrer">API Key page</a>. Integrations using the old key stop working until you update them.

### Getting help

If you're still having issues:
- Check our <a href="https://github.com/templated-io/mcp-server-templated/issues" target="_blank" rel="noopener noreferrer">GitHub Issues</a>
- Contact us at <a href="mailto:support@templated.io">support@templated.io</a>