MCP Server

MCP Server

The ElmapiCMS MCP Server connects AI-powered editors and agents to your CMS instance through the Model Context Protocol. Install it in Cursor, Claude Code, or any MCP-compatible tool and manage your collections, fields, content, and assets through natural language.

What It Does

The MCP server gives AI agents direct access to the ElmapiCMS API. Instead of manually creating collections and entering content, you can ask your AI editor to do it for you:

  • Create and manage collections — Define collections with fields, validations, and field groups
  • Manage fields — Add, update, and reorder fields within any collection
  • Create and edit content — Create, update, list, and soft-delete content entries
  • Manage assets — Upload, list, and delete media files
  • Schema-aware — AI agents can read field type documentation and collection guidelines as built-in MCP resources, so they understand your content structure

Installation

Install the MCP server globally from npm:

npm install -g @elmapicms/mcp-server

Or install it locally in a project:

npm install @elmapicms/mcp-server

You need Node.js 18 or later installed on your machine.

Configuration

The server requires three environment variables:

VariableDescription
ELMAPI_API_URLBase API URL (e.g., https://your-domain.com/api)
ELMAPI_API_KEYAPI token with the required abilities
ELMAPI_PROJECT_IDProject UUID

You can generate an API token from your project's Settings > API Access page. Make sure the token has the abilities needed for the tools you want to use (see Token Abilities below).

Setting Up in Cursor

Add the following to your Cursor MCP settings file (~/.cursor/mcp.json):

{
  "mcpServers": {
    "elmapicms": {
      "command": "npx",
      "args": ["@elmapicms/mcp-server"],
      "env": {
        "ELMAPI_API_URL": "https://your-domain.com/api",
        "ELMAPI_API_KEY": "your-api-key",
        "ELMAPI_PROJECT_ID": "your-project-uuid"
      }
    }
  }
}

After saving, go to Settings > MCP in Cursor and click the refresh button to start the server.

Setting Up in Claude Code

Add the MCP server using the Claude Code CLI:

claude mcp add elmapicms \
  -e ELMAPI_API_URL=https://your-domain.com/api \
  -e ELMAPI_API_KEY=your-api-key \
  -e ELMAPI_PROJECT_ID=your-project-uuid \
  -- npx @elmapicms/mcp-server

Available Tools

The MCP server exposes 17 tools across five categories:

Project

ToolDescription
get_projectGet project information

Collections

ToolDescription
list_collectionsList all collections
get_collectionGet a collection with its full field schema
create_collectionCreate a collection (with optional batch field creation)
update_collectionUpdate a collection's name and slug
reorder_collectionsReorder collections

Fields

ToolDescription
create_fieldAdd a field to a collection
update_fieldUpdate a field
reorder_fieldsReorder fields within a collection

Content Entries

ToolDescription
list_entriesList entries with advanced where filtering (13 operators, OR groups, relation filtering), sorting, pagination, count, and first
get_entryGet a single content entry
create_entryCreate a content entry
update_entryUpdate a content entry
delete_entrySoft-delete a content entry (moves to trash)

Assets

ToolDescription
list_assetsList assets with pagination
get_assetGet an asset by UUID or filename
upload_assetUpload a file as an asset
delete_assetDelete an asset

Advanced Queries

The list_entries tool supports powerful filtering through the where parameter. You can ask your AI editor to construct complex queries in natural language.

Supported operators: eq, lt, lte, gt, gte, not, like, in, not_in, null, not_null, between, not_between

Examples

Filter products under $50 that are in stock:

{
  "where": {
    "price": { "lt": 50 },
    "in-stock": true
  }
}

OR group — find entries tagged "clearance" or related to a campaign:

{
  "where": {
    "or": [
      { "tags": "clearance" },
      { "campaign": { "name": "Summer Sale" } }
    ]
  }
}

Sort by price, paginate 12 per page:

{
  "sort": "price:asc",
  "paginate": 12
}

Get just the count of matching entries:

{
  "where": { "status": "published" },
  "count": true
}

The server includes a built-in Query Reference resource with complete documentation on all operators, relation filtering, sorting, and pagination options.

Built-in Resources

The server exposes three reference resources that AI agents can read for context. These help agents understand your CMS without needing prior knowledge of ElmapiCMS:

  • Field Types Reference (elmapicms://field-types) — Complete reference of all 16 field types, their options, validations, and common patterns.
  • Collections Guide (elmapicms://collections-guide) — Guide for working with collections, singletons, reserved slugs, and best practices.
  • Query Reference (elmapicms://query-reference) — Full documentation for content queries: where filters with 13 operators, OR groups, relation filtering, sorting, pagination, and examples.

Token Abilities

Your API token needs the appropriate abilities for the tools you want to use:

AbilityTools
readlist/get collections, entries, assets
createcreate entries, upload assets
updateupdate entries
deletedelete entries, delete assets
admincreate/update/reorder collections and fields

For the best experience, create a token with all five abilities: read, create, update, delete, and admin.

Using Multiple Projects

Each MCP server instance connects to one project. To work with multiple projects at the same time, add separate entries in your MCP config:

{
  "mcpServers": {
    "elmapicms-blog": {
      "command": "npx",
      "args": ["@elmapicms/mcp-server"],
      "env": {
        "ELMAPI_API_URL": "https://your-domain.com/api",
        "ELMAPI_API_KEY": "blog-project-api-key",
        "ELMAPI_PROJECT_ID": "blog-project-uuid"
      }
    },
    "elmapicms-store": {
      "command": "npx",
      "args": ["@elmapicms/mcp-server"],
      "env": {
        "ELMAPI_API_URL": "https://your-domain.com/api",
        "ELMAPI_API_KEY": "store-project-api-key",
        "ELMAPI_PROJECT_ID": "store-project-uuid"
      }
    }
  }
}

Example Workflow

Here is an example of what you can do with the MCP server in Cursor:

  1. Ask Cursor: "Create a Blog Posts collection with title, slug, content, featured image, and published fields"
  2. Cursor creates the collection and all fields with proper types, validations, and slug configuration
  3. Ask Cursor: "Create a sample blog post about getting started with headless CMS"
  4. Cursor creates the entry with generated content across all fields
  5. Ask Cursor: "Build a Next.js page that fetches and displays blog posts from ElmapiCMS"
  6. Cursor reads the collection schema and builds a fully typed frontend page

The AI agent handles the entire CMS setup while you focus on your frontend code.

Local Development

If your ElmapiCMS instance runs on a .test domain with a self-signed SSL certificate (e.g., via Laravel Herd), add NODE_TLS_REJECT_UNAUTHORIZED to your env config:

"env": {
  "ELMAPI_API_URL": "https://myproject.test/api",
  "ELMAPI_API_KEY": "your-api-key",
  "ELMAPI_PROJECT_ID": "your-project-uuid",
  "NODE_TLS_REJECT_UNAUTHORIZED": "0"
}

Only use NODE_TLS_REJECT_UNAUTHORIZED=0 for local development. Do not use this in production.

Search documentation

Find guides and reference pages