Tools
=====

**ツール** とは、エージェントが名前で呼び出すことができるものです。
AIDBが知っているすべてのツールビルトイン、カスタム、またはMCPサーバーからインポートは、1か所の\ ``aidb.tools``
にリストされています。

.. code:: sql

   SELECT name, tool_type, read_only FROM aidb.tools;

   __OUTPUT__
           name         | tool_type   | read_only
   - --------------------+-------------+-----------
    chunk_text          | native_tool | t
    create_agent        | native_tool | f
    ...

ツールは3つの異なる方法で呼び出すことができます。

1. AIDBの内部エージェントによってネイティブに。

2. MCPを介した外部エージェントによる。

3. テストと開発またはその他のカスタムユースケースのためのSQLを介して。

.. code:: sql

   SELECT aidb.run_tool(catalog_list_objects, {"schema": "public", "object_type": "table"});

   __OUTPUT__
           run_tool
   - --------------------------------------------
    {"comment": null, "truncated": false, "object_name": "my_table", "object_type": "table", "schema_name": "public"},  ...

AIDBには3種類のツールがあります。

- **``native_tool``**
  AIDB独自のビルトインカタログ。いつでも利用できます。追加、削除、または再構成はできません。
  :ref:`Native tools <Native tools>`  を参照してください。

- **``sql_tool``** - 自分で登録するパラメーター化されたSQLクエリー。
  :ref:`Custom SQL tools <Custom SQL tools>` を参照してください。

- **``mcp_tool``** — 外部MCPサーバーからインポートされたツール。
  :ref:`MCP tools <MCP tools>` を参照してください。

:ref:`promoteb.create_agent <promoteb.create_agent>` の\ ``tools``
配列に名前をリストすることにより、エージェントにツールへのアクセスを付与します。

ドキュメントマップ
------------------

.. csv-table::
  :header: Page,What it covers
  :widths: 10,30
  :align: left
  :class: longtable

  :ref:`Native tools<Native tools>` ,"AIDB's built-in tool catalog: ad hoc SQL, catalog discovery, semantic knowledge bases, models, volumes, embedding and document processing, agent management, pipelines"
  :ref:`Custom SQL tools<Custom SQL tools>` ,"`aidb.create_sql_tool()`, naming, parameter placeholders, read-only enforcement, removing tools"
  :ref:`MCP tools<MCP tools>` ,"`aidb.import_mcp_tools()`, authentication, filtering, refreshing, removing servers, exposing AIDB's tools over MCP"

完全なパラメーターテーブルと戻り型については、
:ref:`Tools reference <Tools reference>` を参照してください。

.. toctree::
  :maxdepth: 3

  tools--native-tools
  tools--custom-sql-tools
  tools--mcp-tools
