Class: TalkToYourApp::Plugins::Db::Tools::Tables

Inherits:
Tool
  • Object
show all
Defined in:
lib/talk_to_your_app/plugins/db/tools/tables.rb

Overview

Lists the table names in the read-only database, so a client can discover the schema before querying.

Constant Summary collapse

CONNECTION =
:replica_readonly

Instance Method Summary collapse

Methods inherited from Tool

argument, arguments, connection, default_arguments, description, dispatch, input_schema_hash, invoke, name, normalize_response, to_mcp_definition, to_mcp_tool

Instance Method Details

#call(_args, ctx) ⇒ Object



18
19
20
21
22
23
# File 'lib/talk_to_your_app/plugins/db/tools/tables.rb', line 18

def call(_args, ctx)
  tables = ctx.connection { |conn| conn.tables.sort }
  json(tables: tables)
rescue ActiveRecord::ActiveRecordError => e
  error("Could not list tables: #{e.message}")
end