Module: OdataDuty::McpInputSchemas

Extended by:
McpInputSchemas
Included in:
McpInputSchemas
Defined in:
lib/odata_duty/mcp_input_schemas.rb

Instance Method Summary collapse

Instance Method Details

#count_input_schema(supports_search:) ⇒ Object

Property names are used as-is (symbols) for keys/required and the root type: object is omitted; the MCP SDK normalizes the keys and supplies the root type default.



8
9
10
11
12
# File 'lib/odata_duty/mcp_input_schemas.rb', line 8

def count_input_schema(supports_search:)
  properties = { '$filter' => { 'type' => 'string' } }
  properties['$search'] = { 'type' => 'string' } if supports_search
  { 'properties' => properties, 'required' => [] }
end

#create_input_schema(entity_type) ⇒ Object



29
30
31
32
33
34
# File 'lib/odata_duty/mcp_input_schemas.rb', line 29

def create_input_schema(entity_type)
  writable = entity_type.properties.select(&:settable_on_create?)
  properties = writable.to_h { |p| [p.name, p.to_oas2] }
  required = writable.reject(&:nullable).map(&:name)
  { 'properties' => properties, 'required' => required }
end

#delete_input_schema(entity_type) ⇒ Object



54
55
56
57
# File 'lib/odata_duty/mcp_input_schemas.rb', line 54

def delete_input_schema(entity_type)
  key = entity_type.property_refs.first
  { 'properties' => { key.name => key.to_oas2 }, 'required' => [key.name] }
end

#get_input_schema(entity_type) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/odata_duty/mcp_input_schemas.rb', line 44

def get_input_schema(entity_type)
  key = entity_type.property_refs.first
  properties = {
    key.name => key.to_oas2,
    '$select' => { 'type' => 'string',
                   'description' => 'Comma-separated properties to return' }
  }
  { 'properties' => properties, 'required' => [key.name] }
end

#list_input_schema(supports_search:) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/odata_duty/mcp_input_schemas.rb', line 14

def list_input_schema(supports_search:)
  properties = {
    '$filter' => { 'type' => 'string', 'description' => 'OData $filter expression' },
    '$select' => { 'type' => 'string',
                   'description' => 'Comma-separated properties to return' }
  }
  if supports_search
    properties['$search'] = { 'type' => 'string',
                              'description' => 'Search expression (AND, OR, NOT)' }
  end
  properties['$top'] = { 'type' => 'integer', 'description' => 'Max records to return' }
  properties['$skip'] = { 'type' => 'integer', 'description' => 'Records to skip' }
  { 'properties' => properties, 'required' => [] }
end

#update_input_schema(entity_type) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/odata_duty/mcp_input_schemas.rb', line 36

def update_input_schema(entity_type)
  key = entity_type.property_refs.first
  writable = entity_type.properties.select(&:settable_on_update?)
  properties = { key.name => key.to_oas2 }
  writable.each { |p| properties[p.name] = p.to_oas2 }
  { 'properties' => properties, 'required' => [key.name] }
end