-
Notifications
You must be signed in to change notification settings - Fork 2
Filip/mcp #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: petr/has-folio-tiptap-and-cache
Are you sure you want to change the base?
Filip/mcp #520
Conversation
mreq
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nedokazu posoudit pouzitelnost, ale prosim, udelej to z petr/has-folio-tiptap-and-cache jako mcp pack https://github.com/sinfin/folio/blob/petr/has-folio-tiptap-and-cache/docs/packs.md
|
@mreq To je větev ve které už jsou překlady TipTapu? Používáme to teď na Sinfin webu už s překlady. cc @VladaTrefil |
…ersions Bumped sidekiq-cron to version 2.0 and sidekiq to version 7.0 in the gemspec for improved functionality and compatibility.
Included connection_pool version 2.x in the gemspec to ensure compatibility, as version 3.0.x introduces breaking changes.
Added MCP (Model Context Protocol) server support, enabling AI agents to interact with CMS content. This includes new dependencies, a dedicated controller, tools for handling translations, and configuration for resource management. Updated user model to support MCP tokens and added necessary migrations and documentation.
Updated record retrieval and update methods to handle nil types for base classes without STI, improving type validation. Added validation for Tiptap content during record updates and implemented cover image assignment based on provided attributes. Enhanced file upload functionality with improved MIME type detection and validation for image processability, ensuring robust error handling and user feedback. Expanded documentation to include Tiptap content structure and validation guidelines.
Implemented eager loading for Tiptap node classes to ensure all descendants are populated. Updated content creation and update methods to support both simple and full wrapper formats for Tiptap JSON content. Added normalization and validation for Tiptap content, including deep stringification of keys for consistent handling. Enhanced documentation to clarify Tiptap content structure and usage of custom nodes.
Added support for versioning in the MCP, including tools to list, retrieve, and restore record versions. Implemented validation and authorization checks for versioning actions. Enhanced configuration to enable versioning for resources and updated documentation to reflect new features and usage examples. Introduced tests to ensure functionality and error handling for version-related operations.
Reformatted the extract_type method for improved readability by aligning the case statement and removing unnecessary line breaks. This enhances code clarity while maintaining existing functionality.
Included a relative require for the version file in the server factory to ensure versioning tools are accessible within the MCP module. This change supports the ongoing enhancements related to version management.
8e15a8a to
bcc5192
Compare
|
@mreq pridal jsem to do te pack struktury, koukni na to prosim. |
| module Folio | ||
| mattr_accessor :enabled_packs | ||
| self.enabled_packs = [:cache] | ||
| self.enabled_packs ||= [:cache] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mreq vypada to, ze lib/folio se nacte po application.rb, takze je potreba pridat ||=, aby se to tu neprepsalo.
d6b9d76 to
9c04f06
Compare
Folio MCP Server - Implementation Plan
Status: Production Ready (v1.2) ✅
Last tested: 2026-01-24 21:01 UTC
Completed Features
HasMcpTokenconcernFolio::Api::McpControllercover_idfieldArchitecture Overview
Components
Configuration Example
Critical Findings
Tiptap Content Structure
The tiptap content MUST be wrapped in a specific structure when saving:
{ "tiptap_content": { "type": "doc", "content": [...] } }NOT directly:
{ "type": "doc", "content": [...] }This is due to
Folio::Tiptap::TIPTAP_CONTENT_JSON_STRUCTURE[:content]requiring the"tiptap_content"key.Attribute Filtering Fixed
filter_allowed_attrsnow properly handles nil config values and converts symbols:Phase 2: Improvements
Priority 1: Fix Translation Extraction for Wrapped Structure
Issue:
extract_translatable_textsmay return empty when tiptap is wrappedLocation:
app/lib/folio/mcp/tiptap_text_extractor.rbTask: Handle wrapped structure
{"tiptap_content": {...}}automaticallyPriority 2: Tiptap Structure Documentation in Tool Descriptions
Task: Update MCP tools description to document required tiptap structure
Location:
lib/folio/mcp/server_factory.rb- tool descriptionsAdd to update tool description:
Priority 3: Search Files Tool
Issue: Cannot assign cover images without knowing file_id
Solution: Add
search_filestoolPriority 4: Better Error Messages
Task: Improve error messages to be more actionable
Priority 5: Cover Image Assignment ✅ DONE
Cover images are now assignable via
cover_idfield:Implementation:
server_factory.rbaddscover_idto input schema whencover_fieldconfiguredupdate_record.rbhandleshas_one :throughplacement associationsPriority 6: Robust File Upload ✅ DONE
Upload validation ensures only valid, processable images are accepted:
upload_XXXX.jpgbased on detected typePhase 3: Advanced Features
Bulk Operations
bulk_update_records- Update multiple records at oncebulk_translate- Translate multiple fields/recordsPreview URLs
preview_urlto serialized outputAtom Management
list_atom_types- Available atom typesadd_atom_to_page- Add atoms to existing pagesreorder_atoms- Change atom orderWebhook Support
Rate Limiting
Site Context
Testing Checklist
Manual Tests Performed (2026-01-24)
Automated Tests
Location:
test/lib/folio/mcp/compatibility_test.rb- Config validationconfiguration_test.rb- DSL teststiptap_text_extractor_test.rb- Extraction teststools/apply_translations_test.rb- Translation testsRun tests:
MCP Client Configuration
Cursor IDE
Location:
.cursor/mcp.json{ "mcpServers": { "folio-local": { "type": "http", "url": "http://localhost:3000/folio/api/mcp", "headers": { "Authorization": "Bearer YOUR_TOKEN_HERE" } } } }Generate Token
rails 'folio:mcp:generate_token[user@example.com]'Or in Rails console:
Using Images in Tiptap Content
To include uploaded images in tiptap content, use the
cover_placement_attributeswithfile_id:Single Image
{ "type": "folioTiptapNode", "attrs": { "data": { "cover_placement_attributes": { "file_id": 123 } }, "type": "SinfinDigital::Tiptap::Node::Images::SingleImage", "version": 1 } }Image in Card
{ "type": "folioTiptapNode", "attrs": { "data": { "title": "Card Title", "content": "{\"type\":\"doc\",\"content\":[...]}", "cover_placement_attributes": { "file_id": 123 } }, "type": "SinfinDigital::Tiptap::Node::Cards::Large", "version": 1 } }Multiple Images (Gallery)
{ "type": "folioTiptapNode", "attrs": { "data": { "title": "Gallery Title", "image_placements_attributes": [ { "file_id": 123 }, { "file_id": 124 }, { "file_id": 125 } ] }, "type": "SinfinDigital::Tiptap::Node::Images::MasonryGallery", "version": 1 } }Workflow for Adding Images
upload_file(url: "https://example.com/image.jpg", alt: "Description")id(e.g., 123)idin tiptap content asfile_idAPI Reference
Tools
list_{resources}get_{resource}create_{resource}update_{resource}list_{resource}_versionsversioned: true)get_{resource}_versionrestore_{resource}_versionupload_fileextract_translatable_textsapply_translationsResources
folio://pagesfolio://articlesfolio://projectsfolio://filesfolio://tiptap/schemaPrompts
translate_pagecreate_contentedit_metadataVersion History
Configuration
Enable versioning for a resource:
Workflow: Review and Restore Previous Version
Version Response Format
{ "version_info": { "version": 5, "action": "update", "created_at": "2026-01-24T10:30:00Z", "user": { "id": 1, "email": "editor@example.com" }, "changes": ["title", "tiptap_content"], "preview_url": "https://example.com/folio/console/pages/123/revision/5", "restorable": true }, "record": { "id": 123, "title": "Page title at version 5", ... } }Known Limitations
Security Considerations
allowed_actionsfieldsandtiptap_fieldsChangelog
2026-01-25 (v1.2)
list_{resource}_versions- List all versions with paginationget_{resource}_version- Get specific version content with preview URLrestore_{resource}_version- Restore to a previous versionversioned: trueoption for resources2026-01-24 (v1.1)
cover_idfield forhas_one :throughplacementsallowed_typescheck handles records withtype: nil::File.extnameinstead ofFile.extnamein upload2026-01-24 (v1.0)
namespace :folioinstead ofscope)required: [])|server_context:, **kwargs|)Future Considerations
Performance