Class: TalkToYourApp::Plugins::Db::Tools::Schema
- Defined in:
- lib/talk_to_your_app/plugins/db/tools/schema.rb
Overview
Describes a single table from the live read-only database: its columns, primary key, indexes, and foreign keys. Lets a client learn a table’s shape without a schema dump.
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
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/talk_to_your_app/plugins/db/tools/schema.rb', line 20 def call(args, ctx) table = args[:table].to_s ctx.connection do |conn| unless conn.tables.include?(table) next error("Unknown table #{table.inspect}. Use db.tables to list available tables.") end json(describe(conn, table)) end rescue ActiveRecord::ActiveRecordError => e error("Could not describe #{args[:table].inspect}: #{e.}") end |