-
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/tiptap-multi-lang
Are you sure you want to change the base?
Filip/mcp #520
Conversation
…ance method Update test stubs to use instance method stubs instead of class method stubs. Add migration notes to UPGRADING.md and CHANGELOG.md.
…r autosave checks Updated instances in ConsoleUrlBarComponent, SimpleFormWrapComponent, and AutosaveInfoComponent to use `try` for `tiptap_autosave_enabled?` method calls, enhancing robustness against nil objects.
- Refactor TipTap SCSS variables to CSS custom properties. - Move theme class to .f-tiptap-styles directly. - Add support for per-record themes in ViewComponents. - Remove redundant SCSS variables.
- Move float aside CSS variables from .f-tiptap-float to .f-tiptap-styles scope - Add responsive variables for tablet/desktop breakpoints - Update container queries to use responsive variables instead of hardcoded values - Allows apps to override float values at theme level without selector duplication
Add video/x-m4v to allowed video formats and map it to video/mp4 for browser compatibility, similar to video/quicktime support.
Position buttons in paginated catalogues can now move items to adjacent pages. When moving to previous page, automatically scrolls to bottom to show moved item. Adds has_folio_positionable? class method to positionable concerns.
# Conflicts: # CHANGELOG.md
Allow string attributes to define a default proc that receives the node instance as an optional argument. The default value is displayed as a placeholder in the form input. Updated documentation to reflect proc-based defaults with flexible arity.
# Conflicts: # CHANGELOG.md
- Add factory for Folio::Cache::Version model - Add tests for key presence and uniqueness validations - Test error types instead of messages for locale independence - Document Rails error testing best practices in AGENTS.md
- Add packs architecture with configurable enabled_packs - Move cache feature to packs/cache pack - Add packwerk configuration and rake tasks - Extend packwerk to support engine paths outside Rails.root - Add package.yml for core engine and cache pack - Update documentation for packs architecture
- Move pack test loading from test_helper_base to test_helper (engine only) - Unify test entry point: remove dummy test_helper, load dummy tests from engine test_helper - Update all dummy test files to require engine test_helper - Now 'rails test' runs all tests (engine + packs + dummy) in one command
Load all cache versions for current site once per request on first folio_cache usage, then filter from memory for subsequent calls. Moves cache_versions_hash to cache pack concern to avoid packwerk violations.
- Add expires_at column to cache versions for scheduled invalidation - Implement ExpireJob for automatic cache invalidation when expires_at passes - Add publishable extensions with folio_cache_expires_at methods - Support block form in configure for temporary test configuration - Add comprehensive tests for folio_cache_expires_at variants - Refactor invalidator to extract data_to_upsert variable - Update documentation with scheduled expiration details
…ries Add --pack=<pack_name> option to all generators that include Folio::GeneratorBase. When specified, files are generated into packs/<pack_name>/app/... instead of app/... Updated generators: - folio:component - folio:atom - folio:console:scaffold - folio:console:catalogue - folio:scaffold - folio:mailer - folio:search - folio:page_singleton - folio:prepared_atom - folio:blog - folio:tiptap:node - folio:ui - folio:devise - folio:install - folio:assets - folio:cache_headers Example usage: rails g folio:component cache/version --pack=cache # -> packs/cache/app/components/...
- Change cache pack routes from namespace :folio/:cache to namespace :cache with module option - Routes now match polymorphic routing expectations (console_cache_versions_url) - Add automatic locale loading for all enabled packs in engine - Locale files in packs/*/config/locales are now loaded automatically
- Add invalidate controller action that bumps updated_at via Invalidator - Add invalidate action button to versions index catalogue with reload icon - Add flash message translations in cache locale files - Add to_label method to Cache::Version model - Add test for invalidate action
- Add invalidate_all collection action to invalidate all cache versions for current site - Add clear_rails_cache action to clear Rails.cache - Add buttons to index header for both actions with confirmation dialogs - Update index_header helper to support block syntax for component customization - Add pg_search_scope to Cache::Version model for search functionality - Add tests for both new actions - Update translations with proper Czech phrasing
- Add console_sidebar_before_site_packs_links hook for packs to add sidebar links - Add cache versions link to sidebar above site settings when cache pack enabled - Hide site cache clear button when cache pack is enabled - Update sidebar cell to collect and merge pack links
- Add invalidation_metadata JSONB column to cache versions table - Store metadata when invalidating cache (model info, manual actions with user) - Display metadata in console index with component - Show time ago for updated_at attribute - Add i18n translations for metadata display - Update tests to handle string keys from JSONB
…ax from Redis configuration
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 |
- Add a new fetch method to Folio::Cache that supports cache versioning. - The method constructs a cache key using the provided name and version keys. - Default expiration time is set if not specified in options. - The method delegates to Rails.cache.fetch for actual caching functionality.
…ords Fix folio_cache_affects_published? to only return true when record is currently published or was previously published (unpublishing case). Previously it would return true for newly created unpublished records because previous_changes included 'published' attribute.
…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
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