add MCP support

This commit is contained in:
Alex Turchyn
2026-03-05 12:17:14 +02:00
committed by GitHub
parent 961f09e092
commit 62a969d8fe
20 changed files with 820 additions and 2 deletions
+1
View File
@@ -57,6 +57,7 @@ class AccountConfig < ApplicationRecord
DOCUMENT_FILENAME_FORMAT_KEY = 'document_filename_format'
TEMPLATE_CUSTOM_FIELDS_KEY = 'template_custom_fields'
POLICY_LINKS_KEY = 'policy_links'
ENABLE_MCP_KEY = 'enable_mcp'
EMAIL_VARIABLES = {
SUBMITTER_INVITATION_EMAIL_KEY => %w[template.name submitter.link account.name].freeze,
+42
View File
@@ -0,0 +1,42 @@
# frozen_string_literal: true
# == Schema Information
#
# Table name: mcp_tokens
#
# id :bigint not null, primary key
# archived_at :datetime
# name :string not null
# sha256 :string not null
# token_prefix :string not null
# created_at :datetime not null
# updated_at :datetime not null
# user_id :bigint not null
#
# Indexes
#
# index_mcp_tokens_on_sha256 (sha256) UNIQUE
# index_mcp_tokens_on_user_id (user_id)
#
# Foreign Keys
#
# fk_rails_... (user_id => users.id)
#
class McpToken < ApplicationRecord
TOKEN_LENGTH = 43
belongs_to :user
before_validation :set_sha256_and_token_prefix, on: :create
attribute :token, :string, default: -> { SecureRandom.base58(TOKEN_LENGTH) }
scope :active, -> { where(archived_at: nil) }
private
def set_sha256_and_token_prefix
self.sha256 = Digest::SHA256.hexdigest(token)
self.token_prefix = token[0, 5]
end
end
+1
View File
@@ -62,6 +62,7 @@ class User < ApplicationRecord
belongs_to :account
has_one :access_token, dependent: :destroy
has_many :access_tokens, dependent: :destroy
has_many :mcp_tokens, dependent: :destroy
has_many :templates, dependent: :destroy, foreign_key: :author_id, inverse_of: :author
has_many :template_folders, dependent: :destroy, foreign_key: :author_id, inverse_of: :author
has_many :user_configs, dependent: :destroy