Skip to content

Commit 46a6de6

Browse files
docs(custom_tool): document --tools file loading and /tools load command (gptme#1547)
* docs(custom_tool): document --tools file loading and /tools load command PR gptme#1540 added support for loading custom tools from .py files via --tools flag, but the docs still only covered TOOL_MODULES registration. Added documentation for both the --tools CLI flag and /tools load runtime command, reorganized the "Registering the Tool" section into clearer subsections for file-based vs module-based loading. * docs(custom_tool): fix --tools examples and remove incorrect /tools load usage - Add '+' prefix examples (additive mode) as the recommended approach - Explain that without '+', --tools replaces the entire default toolset - Remove incorrect '/tools load ./my_tool.py' example — /tools load only accepts tool names (e.g. 'browser'), not file paths Fixes feedback from Greptile and Erik in PR review. * docs(custom_tool): fix multi-file example — one '+' is enough for additive mode --------- Co-authored-by: TimeToBuildBob <TimeToBuildBob@users.noreply.github.com>
1 parent 16e5cd8 commit 46a6de6

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

docs/custom_tool.rst

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,38 @@ Use **custom tools** when you need:
213213
- Complex argument validation
214214
- Operation without shell access
215215

216-
Registering the Tool
216+
Use ``--tools +./file.py`` for **quick development** — no packaging or ``PYTHONPATH`` needed. Use ``TOOL_MODULES`` for **production** tools that are installed as packages.
217+
218+
Loading Custom Tools
217219
--------------------
218-
To ensure your tool is available for use, you can specify the module in the ``TOOL_MODULES`` env variable or
219-
setting in your :doc:`project configuration file <config>`, which will automatically load your custom tools.
220+
221+
There are two ways to load custom tools: directly from a ``.py`` file (quickest for development), or via a Python module (best for packaged/shared tools).
222+
223+
Loading from a File (``--tools``)
224+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
225+
226+
The simplest way to use a custom tool is to pass the file path directly via ``--tools``:
227+
228+
.. code-block:: bash
229+
230+
# Add your tool on top of the default toolset (most common)
231+
gptme --tools +./my_tool.py "use the my_tool tool"
232+
233+
# Replace the default toolset entirely with specific tools
234+
gptme --tools save,patch,./my_tool.py "prompt"
235+
236+
# Load multiple custom tool files (additive — one '+' is enough)
237+
gptme --tools +./tools/search.py,./tools/deploy.py "prompt"
238+
239+
The ``+`` prefix adds tools on top of the default toolset. Without ``+``, the argument replaces the entire toolset — so you'd need to explicitly list any built-in tools you still want.
240+
241+
**How it works**: gptme scans the file for top-level ``ToolSpec`` instances and registers them. The file must be a regular ``.py`` file containing at least one ``ToolSpec`` variable (see the example in `Creating a Custom Tool`_ above).
242+
243+
Loading from a Module (``TOOL_MODULES``)
244+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
245+
246+
For packaged tools, specify the module in the ``TOOL_MODULES`` env variable or
247+
in your :doc:`project configuration file <config>`:
220248

221249
.. code-block:: toml
222250

0 commit comments

Comments
 (0)