mirror of https://github.com/docusealco/docuseal
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
# frozen_string_literal: true
|
|
|
|
module Mcp
|
|
class LoadTemplateController < McpBaseController
|
|
SCHEMA = {
|
|
name: 'load_template',
|
|
title: 'Load Template',
|
|
description: 'Load a template with its fields. Each field includes name, type, and the signing role name.',
|
|
inputSchema: {
|
|
type: 'object',
|
|
properties: {
|
|
template_id: {
|
|
type: 'integer',
|
|
description: 'Template identifier'
|
|
}
|
|
},
|
|
required: %w[template_id]
|
|
},
|
|
annotations: {
|
|
readOnlyHint: true,
|
|
destructiveHint: false,
|
|
idempotentHint: true,
|
|
openWorldHint: false
|
|
}
|
|
}.freeze
|
|
|
|
def call
|
|
@template = Template.accessible_by(current_ability).find(mcp_params['template_id'])
|
|
|
|
authorize!(:read, @template)
|
|
|
|
submitters_index = @template.submitters.index_by { |s| s['uuid'] }
|
|
|
|
roles = @template.submitters.pluck('name')
|
|
|
|
fields = @template.fields.filter_map do |field|
|
|
next if field['name'].blank?
|
|
|
|
{
|
|
name: field['name'],
|
|
type: field['type'],
|
|
role: submitters_index[field['submitter_uuid']]&.dig('name')
|
|
}
|
|
end
|
|
|
|
render_tool_result(
|
|
id: @template.id,
|
|
name: @template.name,
|
|
roles: roles,
|
|
fields: fields
|
|
)
|
|
end
|
|
end
|
|
end
|