Files
mims-harvard__tooluniverse/docs/guide/loading_tools.rst
Shanghua Gao 08246bcd4d docs: expand redirect map (15 more paper-cited legacy paths) (#211)
* docs: expand redirect map with 15 additional legacy paths

Adds redirects for paths uncovered in a second-pass audit against
the live published site. Each destination verified to return HTTP 200
on https://zitniklab.hms.harvard.edu/ToolUniverse/.

New /tutorials/ → /guide/, /tools/, /expand_tooluniverse/ redirects:
- make_your_data_searchable, make_your_data_agent_searchable,
  build_search_and_share_datastores → guide/make_your_data_agent_searchable
- skills → guide/skills_showcase
- tool_finder → guide/finding_tools
- overview → guide/index
- remote_tools → tools/remote_tools
- mcp_integration → expand_tooluniverse/remote_tools/mcp_integration

Top-level legacy pages (404 at root, now redirected):
- getting_started → guide/python_guide
- deployment, contributing, changelog → about/<page>
- faq → help/faq

Local build confirms all 22 redirect stubs generate and that every
destination file exists in the build output.

* docs: fix broken sphinx-tabs, dead toctrees, orphan pages, missing image

Build now produces 0 warnings/errors of these structural categories
(down from ~280 such issues):

- Re-enable sphinx_tabs.tabs extension (3.5.0 supports Sphinx 9.x);
  fixes 7 broken "Unknown directive type tabs" errors that made
  help/faq.html and help/troubleshooting.html render incomplete.
- Drop 25+ dead toctree entries in api/modules.rst and
  api/tooluniverse.rst that referenced per-module pages never
  generated by sphinx-apidoc; modules.rst now points at the existing
  comprehensive tooluniverse autodoc page.
- Wire 16 orphan pages into the master toctree so they're reachable
  from the navigation, including tooluniverse_case_study,
  visualization_tutorial, expert_feedback, literature_search_web_ui,
  euhealth, logging, openrouter, streaming, vllm, wechat_community,
  simbad_tools, the guide/index landing page, and the full
  expand_tooluniverse sub-tree.
- Remove three stale ":doc:" links to old/{quickstart,installation,
  getting_started} from sitemap.rst (those directories are excluded
  from the build) and mark sitemap.rst as :orphan: since it's a
  parallel nav surface by design.
- Mark MCP_TASKS_GUIDE.md as orphan and exclude the internal
  DOCUMENTATION_STRUCTURE.md meta-doc from the build.
- Add the missing tools/remote/ui.jpg referenced by the remote
  expert_feedback page (previously: broken image).

* docs: eliminate all 49 structural Sphinx ERRORs (broken tables, directives, headings)

Round-3 build cleanup. Builds now finish with 0 structural ERRORs of any
category (previous: 49 ERRORs spread across 20 files). Total
warnings/errors dropped from 280 → 114; the remaining 114 are all in
Python source-file docstrings (out of scope for a docs PR).

Categories fixed:

**Malformed tables** (8 files)

  Replace ASCII grid tables with mis-aligned pipes and inline-markdown
  pipe tables (which RST mis-parses as substitution references) with
  ``list-table`` directives that render correctly across all themes:

  - guide/literature_search_tools_tutorial.rst (two tables)
  - guide/cache_system.rst (env-var table whose first column overflowed)
  - guide/clinical_guidelines_tools.rst
  - guide/make_your_data_agent_searchable.rst
  - expand_tooluniverse/contributing/index.rst
  - expand_tooluniverse/contributing/remote_tools.rst
  - expand_tooluniverse/reference/index.rst

**list-table indentation** (3 files)

  Option lines and list items were indented with 1 space (only valid for
  3-space) so Sphinx silently dropped them and reported "exactly one
  bullet list expected":

  - guide/finding_tools.rst
  - guide/http_api.rst
  - guide/tools.rst

**Code-block separators** (5 files, ~30 directives)

  Add the required blank line between an introductory paragraph and a
  following ``.. code-block::``. Without it, Sphinx treated the directive
  as a continuation of the paragraph and emitted "Unexpected indentation"
  for every line of the code:

  - guide/literature_search_tools_tutorial.rst
  - expand_tooluniverse/quick_start.rst
  - expand_tooluniverse/contributing/local_tools.rst
  - expand_tooluniverse/contributing/remote_tools.rst
  - guide/make_your_data_agent_searchable.rst

**Heading-style + indentation** (3 files)

  - guide/building_ai_scientists/mcp_name_shortening.rst — strip stray
    leading spaces from two section titles + downgrade unknown
    ``.. critical::`` to ``.. important::``
  - about/deployment.rst — remove rogue ``=========`` underline below
    numbered-list items that mis-led the parser into skipping heading
    levels
  - guide/make_your_data_agent_searchable.rst — extend four "title
    underline too short" underlines + convert four markdown ``` fences
    to RST literal blocks

**Misc directive / target fixes**

  - guide/python_guide.rst — replace nonexistent ``.. success::`` with
    a tip-styled ``.. admonition::``
  - guide/euhealth_tools_tutorial.rst — indent ``.. note::`` body so it
    is no longer an empty admonition
  - help/troubleshooting.rst — same fix + remove rogue ``=========``
    line that was being read as a section overline
  - tools/cellosaurus_tools.rst — wrap ``CVCL_`` in literal backticks
    so the trailing underscore stops triggering missing-target lookups
  - expand_tooluniverse/index.rst — promote two leading-space bullet
    lists to standalone lists so the indentation is correct
  - expand_tooluniverse/reference/architecture.rst — switch ``.. graphviz::``
    (extension not installed) to a plain ``.. code-block:: text``;
    the embedded content was Mermaid pseudo-code anyway
  - guide/tools.rst — strip leading space on a section title

* docs: clear all remaining content warnings (lists, headings, refs, grids)

Round-4 build cleanup. Builds now finish with 0 structural ERRORs and 0
content WARNINGs; the only remaining ~11 warnings are pre-existing autodoc
infrastructure noise (duplicate object index entries from autosummary, and
the ghost_tool / medrxiv_tool modules that genuinely fail to import) — none
are in hand-written documentation.

Fixes in this commit:

**sphinx-design grids** (python_guide.rst)

  Re-indent two ``.. grid::`` blocks whose first card + options used 1-space
  indentation (Sphinx silently dropped them → "parent of grid-item should be
  grid-row"). Also fix a ``.. button-ref::`` whose content was indented 1
  space, producing a broken ``:any:`` cross-reference, and point it at the
  absolute ``/api/modules``.

**Numbered/bulleted sub-lists** (tool_composition, literature_search ×2,
architecture, literature_search_web_ui, make_your_data, agentic_tools,
finding_tools, euhealth)

  Insert the required blank line before nested lists and re-indent 1-space
  sub-bullets to align under their parent list marker. Clears ~80
  "list ends without a blank line; unexpected unindent" warnings.

**Title underlines** (logging, tool_caller, loading_tools, tool_composition,
euhealth, make_your_data, contributing/local_tools, reference/index,
remote_tools/tutorial, troubleshooting + bulk pass)

  Extend underlines shorter than their title text; strip stray leading spaces
  from section titles that Sphinx read as block quotes.

**Stray markdown in RST** (make_your_data, local_tools)

  Convert leftover ``###`` headings and ``` ``` fences to proper RST
  directives; remove a rogue ``------`` separator that was being parsed as a
  section underline.

**Duplicate autosectionlabel** (make_your_data)

  Rename the second "How it works" heading to "How sharing works".

**uniprot_tools** (JSON + generated RST)

  Rephrase the ``min_length`` / ``max_length`` descriptions so the open-ended
  range syntax no longer contains a bare ``*`` that RST read as an unterminated
  emphasis marker. Fixed in the JSON source so it survives doc regeneration.
2026-05-30 22:34:05 -07:00

398 lines
10 KiB
ReStructuredText
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Tool Loading Tutorial
=====================
**Complete Tutorial to loading and managing tools in ToolUniverse**
This Tutorial covers two main approaches to load and access ToolUniverse tools: Python API using ``load_tools()`` method and MCP (Model Context Protocol) server using terminal commands.
Python API: Using load_tools()
---------------------------------
The ``load_tools()`` method is the primary way to load tools when using ToolUniverse programmatically in Python.
.. note::
**For complete Python API documentation**, see :doc:`../api/modules` for the full API reference.
.. autofunction:: tooluniverse.execute_function.ToolUniverse.load_tools
:noindex:
Basic Usage
~~~~~~~~~~~
Load all available tools:
.. code-block:: python
from tooluniverse import ToolUniverse
# Initialize ToolUniverse
tu = ToolUniverse()
# Load all tools from all categories
tu.load_tools()
# Check how many tools were loaded
print(f"Loaded {len(tu.all_tools)} tools")
# List first 5 tools
tool_names = tu.list_built_in_tools(mode='list_name')
for tool in tool_names[:5]:
print(f" • {tool}")
Selective Tool Loading
~~~~~~~~~~~~~~~~~~~~~~
Load specific tool categories:
.. code-block:: python
# Load only specific categories
tu.load_tools(tool_type=["uniprot", "ChEMBL", "opentarget"])
# Load tools but exclude certain categories
tu.load_tools(exclude_categories=["mcp_auto_loader", "special_tools"])
Load specific tools by name:
.. code-block:: python
# Load only specific tools
tu.load_tools(include_tools=[
"UniProt_get_entry_by_accession",
"ChEMBL_get_molecule_by_chembl_id",
"OpenTargets_get_associated_targets_by_disease_efoId"
])
# Load tools from a file
tu.load_tools(tools_file="/path/to/tool_names.txt")
Advanced Filtering
~~~~~~~~~~~~~~~~~~
Filter by tool types:
.. code-block:: python
# Include only specific tool types
tu.load_tools(include_tool_types=["OpenTarget", "ChEMBLTool"])
# Exclude specific tool types
tu.load_tools(exclude_tool_types=["ToolFinderEmbedding", "Unknown"])
Exclude specific tools:
.. code-block:: python
# Load all tools except specific ones
tu.load_tools(exclude_tools=["problematic_tool", "slow_tool"])
Load Additional Configurations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add custom tool configuration files:
.. code-block:: python
# Load additional config files
tu.load_tools(tool_config_files={
"custom_tools": "/path/to/custom_tools.json",
"local_analysis": "/path/to/local_tools.json"
})
Note: tool_config_files is a dictionary of tool category names and the path to the tool configuration file,
but it does not mean that the tool is loaded.
You need to load the tool with tool_type or include_tools or include_tool_types.
Combined Parameters
~~~~~~~~~~~~~~~~~~~
Combine multiple loading options:
.. code-block:: python
tu.load_tools(
tool_type=["uniprot", "ChEMBL", "custom"], # Load specific categories
exclude_tools=["problematic_tool"], # Exclude specific tools
exclude_tool_types=["Unknown"], # Exclude tool types
tool_config_files={ # Add custom tools
"custom": "/path/to/custom.json"
}
)
.. _mcp-server-functions:
MCP Server Functions
-------------------------------------------
ToolUniverse provides two main MCP server functions for different use cases:
.. seealso::
For a comprehensive MCP overview, detailed configuration, best practices, and troubleshooting, see :doc:`building_ai_scientists/mcp_support`.
1. **`tooluniverse-smcp`** - Full-featured server with configurable transport (HTTP, SSE, stdio)
2. **`tooluniverse-smcp-stdio`** - Specialized server for stdio transport (for desktop AI applications)
Both functions expose the same 1000+ scientific tools through the Model Context Protocol (MCP), but with different transport configurations and argument handling.
tooluniverse-smcp Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `tooluniverse-smcp` function is the main entry point for ToolUniverse's SMCP server, providing full configurability for different deployment scenarios.
Basic Server Startup
^^^^^^^^^^^^^^^^^^^^
Start a basic MCP server with all tools:
.. code-block:: bash
# Start server on default port 7000
tooluniverse-smcp
# Start server on specific port
tooluniverse-smcp --port 8000
# Start with custom server name
tooluniverse-smcp --name "My ToolUniverse Server" --port 8000
.. _hook-configuration:
Hook Configuration
^^^^^^^^^^^^^^^^^^
Enable intelligent output processing hooks:
.. code-block:: bash
# Enable hooks with default SummarizationHook
tooluniverse-smcp --hooks-enabled --port 8000
# Use specific hook type
tooluniverse-smcp --hook-type SummarizationHook --port 8000
tooluniverse-smcp --hook-type FileSaveHook --port 8000
# Use custom hook configuration
tooluniverse-smcp --hook-config-file /path/to/hook_config.json --port 8000
Available Hook Types
^^^^^^^^^^^^^^^^^^^^
- **SummarizationHook**: AI-powered summarization of long outputs
- **FileSaveHook**: Save outputs to files with metadata
For detailed hook configuration, see :doc:`hooks/index`.
Transport Configuration
^^^^^^^^^^^^^^^^^^^^^^^
Different transport protocols:
.. code-block:: bash
# HTTP transport (default)
tooluniverse-smcp --transport http --port 8000
# STDIO transport (for desktop apps)
tooluniverse-smcp --transport stdio
# Server-Sent Events transport
tooluniverse-smcp --transport sse --port 8000
.. _category-based-loading:
Category-Based Loading
^^^^^^^^^^^^^^^^^^^^^^
Load only specific tool categories:
.. code-block:: bash
# Load specific categories
tooluniverse-smcp --categories uniprot ChEMBL opentarget --port 8000
# Load all except certain categories
tooluniverse-smcp --exclude-categories mcp_auto_loader special_tools --port 8000
.. _tool-specific-loading:
Tool-Specific Loading
^^^^^^^^^^^^^^^^^^^^^
Load specific tools by name:
.. code-block:: bash
# Load only specific tools
tooluniverse-smcp --include-tools "UniProt_get_entry_by_accession" "ChEMBL_get_molecule_by_chembl_id" --port 8000
# Load tools from a file
tooluniverse-smcp --tools-file "/path/to/tool_names.txt" --port 8000
.. _type-based-filtering:
Type-Based Filtering
^^^^^^^^^^^^^^^^^^^^
Filter by tool types:
.. code-block:: bash
# Include only specific tool types
tooluniverse-smcp --include-tool-types "OpenTarget" "ToolFinderEmbedding" --port 8000
# Exclude specific tool types
tooluniverse-smcp --exclude-tool-types "ToolFinderLLM" "Unknown" --port 8000
.. _server-configuration:
Server Configuration
^^^^^^^^^^^^^^^^^^^^
Advanced server configuration:
.. code-block:: bash
# Configure server parameters
tooluniverse-smcp \
--port 8000 \
--host 0.0.0.0 \
--max-workers 10 \
--transport http \
--verbose
.. _discovery-commands:
Discovery Commands
^^^^^^^^^^^^^^^^^^
List available categories and tools:
.. code-block:: bash
# List all available categories
tooluniverse-smcp --list-categories
# List all available tools
tooluniverse-smcp --list-tools
Custom Configuration Files
^^^^^^^^^^^^^^^^^^^^^^^^^^
Load additional tool configurations:
.. code-block:: bash
# Load custom config files
tooluniverse-smcp --tool-config-files "custom:/path/to/custom_tools.json" --port 8000
tooluniverse-smcp-stdio Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The `tooluniverse-smcp-stdio` function is specifically designed for stdio transport, making it ideal for Claude Desktop integration and other desktop AI applications. **By default, this function enables output processing hooks for intelligent post-processing of tool outputs.**
Basic Stdio Server Startup
^^^^^^^^^^^^^^^^^^^^^^^^^^
Start a stdio server with default settings (hooks enabled):
.. code-block:: bash
# Start stdio server with default SummarizationHook enabled
tooluniverse-smcp-stdio
# Start with specific categories
tooluniverse-smcp-stdio --categories uniprot ChEMBL opentarget
Hook Configuration
^^^^^^^^^^^^^^^^^^
The stdio server supports intelligent output processing hooks:
.. code-block:: bash
# Disable hooks (default is enabled)
tooluniverse-smcp-stdio --no-hooks
# Use FileSaveHook instead of SummarizationHook
tooluniverse-smcp-stdio --hook-type FileSaveHook
# Use custom hook configuration
tooluniverse-smcp-stdio --hook-config-file /path/to/hook_config.json
Available Hook Types
^^^^^^^^^^^^^^^^^^^^
- **SummarizationHook** (default): AI-powered summarization of long outputs
- **FileSaveHook**: Save outputs to files with metadata
For detailed hook configuration, see :doc:`hooks/index`.
️ Practical Examples
----------------------
Research Workflow Setup
~~~~~~~~~~~~~~~~~~~~~~~
Setting up for scientific research:
.. code-block:: python
# Python approach
from tooluniverse import ToolUniverse
tu = ToolUniverse()
# Load tools for drug discovery research
tu.load_tools(tool_type=[
"uniprot", # Protein information
"ChEMBL", # Chemical data
"opentarget", # Target-disease associations
"pubchem", # Chemical compounds
"fda_drug_adverse_event" # Safety data
])
# Ready for research queries
result = tu.run({
"name": "UniProt_get_entry_by_accession",
"arguments": {"accession": "P04637"} # p53 protein
})
.. code-block:: bash
# MCP server approach (run_smcp_server)
tooluniverse-smcp \
--categories uniprot ChEMBL opentarget pubchem fda_drug_adverse_event \
--port 8000 \
--name "Drug Discovery Server"
# Or stdio server approach (run_stdio_server) with hooks enabled by default
tooluniverse-smcp-stdio \
--categories uniprot ChEMBL opentarget pubchem fda_drug_adverse_event \
--name "Drug Discovery Tools"
# Stdio server with FileSaveHook for data archiving
tooluniverse-smcp-stdio \
--categories uniprot ChEMBL opentarget pubchem fda_drug_adverse_event \
--hook-type FileSaveHook \
--name "Drug Discovery Tools with File Archiving"
️ File Formats
----------------
Tool Names File Format
~~~~~~~~~~~~~~~~~~~~~~
Create a text file with one tool name per line:
.. code-block:: text
# my_tools.txt - Lines starting with # are comments
OpenTargets_get_associated_targets_by_disease_efoId
Tool_Finder_LLM
ChEMBL_search_similar_molecules
# You can add comments anywhere
Tool_Finder_Keyword