Model Context Protocol (MCP) is an open standard from Anthropic that allows AI agents to work directly with external systems. We integrated an MCP server into Folio CMS, so you can now create pages, edit articles, or upload files from Cursor IDE with a single prompt.
A Rails application with Folio CMS (version with MCP support)
Cursor IDE (or another MCP-compatible client)
Admin account in Folio Console
The whole setup takes about 10 minutes.
Run the generator that adds the required migrations and configuration files:
rails generate folio:mcp:install
rails db:migrateEdit config/initializers/folio_mcp.rb and define which models MCP should manage:
Folio::Mcp.configure do |config|
config.enabled = true
config.resources = {
pages: {
model: "Folio::Page",
fields: %i[title slug perex meta_title meta_description published locale],
tiptap_fields: %i[tiptap_content],
cover_field: :cover,
versioned: true
},
articles: {
model: "SinfinDigital::FlashArticle",
fields: %i[title subtitle slug published featured],
tiptap_fields: %i[tiptap_content]
},
files: {
model: "Folio::File::Image",
searchable: true,
uploadable: true
}
}
config.locales = %i[cs en]
endEach resource can have fields (simple attributes), tiptap_fields (rich text), cover_field (main image), and versioned (change history).
The token is tied to a specific user and inherits their permissions. It is shown only once, so save it.
# Generování nového tokenu
rails folio:mcp:generate_token[[email protected]]
# Seznam uživatelů s povoleným MCP
rails folio:mcp:list_enabled
# Deaktivace MCP pro uživatele
rails folio:mcp:disable[[email protected]]Create a .cursor/mcp.json file in the project root. For production, change the URL to your domain.
{
"mcpServers": {
"folio-local": {
"type": "http",
"url": "http://localhost:3000/folio/api/mcp",
"headers": {
"Authorization": "Bearer mcp_live_vas_token_zde"
}
}
}
}After saving, restart Cursor. The MCP server should appear in the list of available tools.
Test the connection directly from the terminal. If everything works, you will get a response with pong.
curl -X POST http://localhost:3000/folio/api/mcp \
-H "Authorization: Bearer VAS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":1,"method":"ping"}'For each configured resource, MCP automatically creates a set of CRUD tools plus specialized tools for files, versions, and translations.
# CRUD operace (pro každý resource)
get_page(id) # Získání záznamu
list_pages(limit, offset, locale) # Výpis záznamů
create_page(title, slug, tiptap_content) # Vytvoření
update_page(id, title, ...) # Úprava
# Práce se soubory
upload_file(url, alt, tags) # Nahrání z URL
list_files(query) # Vyhledání
# Historie verzí (pokud versioned: true)
list_page_versions(id) # Seznam verzí
get_page_version(id, version) # Konkrétní verze
restore_page_version(id, version) # Obnovení
# Překlady
extract_translatable_texts(tiptap) # Extrakce textů
apply_translations(original, translations) # Aplikace překladůTiptap is the rich text editor used in Folio. Content is stored as JSON. You can get the list of available node types through the MCP resource folio://tiptap/schema.
// Základní struktura Tiptap dokumentu
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "Obyčejný odstavec" }
]
},
{
"type": "folioTiptapNode",
"attrs": {
"type": "SinfinDigital::Tiptap::Node::Contents::Title",
"version": 1,
"data": { "title": "Nadpis", "tag": "H2" }
}
}
]
}Watch the naming convention: the attribute name depends on whether it is a single image or a collection:
// Jeden obrázek (cover: :image)
"cover_placement_attributes": { "file_id": 123 }
// Více obrázků (images: :images)
"image_placements_attributes": [
{ "file_id": 123 },
{ "file_id": 124 }
]The MCP server uses the same rules as Folio Console: Bearer token authentication, authorization through Folio::Ability, and respects site boundaries. You can configure rate limiting and audit logging.
# config/initializers/folio_mcp.rb
config.rate_limit = 100 # požadavků/minutu
config.audit_logger = ->(event) {
Rails.logger.tagged("MCP") { Rails.logger.info(event.to_json) }
}404 Not Found- Check that Folio::Mcp.enabled? returns true. Restart the Rails server after changing the configuration.
401 Unauthorized- Verify the token. The user must have mcp_enabled: true.
Validation Errors- MCP uses the same validations as Console. Check the required model fields.
The MCP server is part of Folio CMS. You can find the full documentation in the repository. Have questions? Get in touch.