<%= render 'shared/settings_nav' %>

<%= t('mcp_server') %>

<%= link_to new_settings_mcp_path, class: 'btn btn-primary btn-md gap-2 w-full md:w-fit', data: { turbo_frame: 'modal' } do %> <%= svg_icon('plus', class: 'w-6 h-6') %> <%= t('new_token') %> <% end %>
<% if @mcp_token.present? %>
<%= render 'shared/clipboard_copy', icon: 'copy', text: @mcp_token.token, class: 'base-button', icon_class: 'w-6 h-6 text-white', copy_title: t('copy'), copied_title: t('copied') %>

<%= t('instructions') %>

<%= t('connect_to_docuseal_mcp') %>

<%= t('add_the_following_to_your_mcp_client_configuration') %>:

<% text = JSON.pretty_generate({ mcpServers: { docuseal: { type: 'http', url: "#{root_url(Docuseal.default_url_options)}mcp", headers: { Authorization: "Bearer #{@mcp_token.token}" } } } }).strip %> <%= render 'shared/clipboard_copy', icon: 'copy', text:, class: 'btn btn-ghost text-white', icon_class: 'w-6 h-6 text-white', copy_title: t('copy'), copied_title: t('copied') %>
<%== HighlightCode.call(text, 'JSON', theme: 'base16.dark') %>

<%= t('works_with_claude_desktop_cursor_windsurf_vs_code_and_any_mcp_compatible_client') %>

<% end %>
<% @mcp_tokens.each do |mcp_token| %> <% end %>
<%= t('name') %> <%= t('token') %> <%= t('created_at') %>
<%= mcp_token.name %> <% if @mcp_token.present? && mcp_token.id == @mcp_token.id %> <%= @mcp_token.token %> <% else %> <%= "#{mcp_token.token_prefix}#{'*' * 38}" %> <% end %> <%= l(mcp_token.created_at.in_time_zone(current_account.timezone), format: :short, locale: current_account.locale) %> <%= button_to settings_mcp_path(mcp_token), method: :delete, class: 'btn btn-outline btn-error btn-xs', title: t('remove'), data: { turbo_confirm: t('are_you_sure_') } do %> <%= t('remove') %> <% end %>
<% account_config = AccountConfig.find_or_initialize_by(account: current_account, key: AccountConfig::ENABLE_MCP_KEY) %> <% if can?(:manage, account_config) %> <%= form_for account_config, url: account_configs_path, method: :post do |f| %> <%= f.hidden_field :key %>
<%= t('enable_mcp_server') %> <%= svg_icon('info_circle', class: 'hidden md:inline-block w-4 h-4 shrink-0') %>
<%= f.check_box :value, class: 'toggle', checked: account_config.value == true %>
<% end %> <% end %>