Module: OvertureMaps::MCPServer::Helpers

Defined in:
lib/overture_maps/mcp_server.rb

Class Method Summary collapse

Class Method Details

.bbox_propertiesObject



52
53
54
55
56
57
58
# File 'lib/overture_maps/mcp_server.rb', line 52

def bbox_properties
  {
    location: { type: "string", description: "Place name to geocode (e.g. 'Seattle'); alternative to the bbox corners" },
    west: { type: "number" }, south: { type: "number" },
    east: { type: "number" }, north: { type: "number" }
  }
end

.error_response(message) ⇒ Object



33
34
35
# File 'lib/overture_maps/mcp_server.rb', line 33

def error_response(message)
  MCP::Tool::Response.new([{ type: "text", text: JSON.generate(error: message) }], error: true)
end

.resolve_bbox(args) ⇒ Object

Accepts either a named-corner bbox or a location name.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/overture_maps/mcp_server.rb', line 38

def resolve_bbox(args)
  if args[:west] && args[:south] && args[:east] && args[:north]
    BoundingBox.new(lat1: args[:south], lng1: args[:west],
                    lat2: args[:north], lng2: args[:east])
  elsif args[:location]
    results = DivisionSearch.search(query: args[:location])
    raise Error, "no divisions found matching #{args[:location].inspect}" if results.empty?

    results.first[:bbox]
  else
    raise ArgumentError, "provide west/south/east/north or a location name"
  end
end

.text_response(payload) ⇒ Object



29
30
31
# File 'lib/overture_maps/mcp_server.rb', line 29

def text_response(payload)
  MCP::Tool::Response.new([{ type: "text", text: JSON.pretty_generate(payload) }])
end