| name | tooluniverse-sdk |
| description | Build AI scientist systems with the ToolUniverse Python SDK for scientific research. Covers the 3 calling patterns (`tu.run` portable dict API, `tu.tools.X` function API, direct class instantiation), tool loading, batch execution, MCP server integration, and embedding-based tool search. Use for SDK programming, custom tool composition, benchmarking pipelines, and integrating ToolUniverse into research workflows. |
ToolUniverse Python SDK
3 calling patterns -- start with pattern 1:
tu.run({"name": ..., "arguments": ...}) -- single tool call, dict API (most portable)
tu.tools.ToolName(param=value) -- function API (recommended for interactive use)
- Direct class instantiation -- advanced, bypasses caching/hooks
Installation
pip install tooluniverse
pip install tooluniverse[embedding]
pip install tooluniverse[all]
export OPENAI_API_KEY="sk-..."
export NCBI_API_KEY="..."
Quick Start
from tooluniverse import ToolUniverse
tu = ToolUniverse()
tu.load_tools()
tools = tu.run({"name": "Tool_Finder_Keyword", "arguments": {"description": "protein structure", "limit": 10}})
result = tu.run({"name": "UniProt_get_entry_by_accession", "arguments": {"accession": "P05067"}})
result = tu.tools.UniProt_get_entry_by_accession(accession="P05067")
Core Patterns
Batch Execution
calls = [
{"name": "UniProt_get_entry_by_accession", "arguments": {"accession": "P05067"}},
{"name": "UniProt_get_entry_by_accession", "arguments": {"accession": "P12345"}},
]
results = tu.run_batch(calls)
Scientific Workflow
def drug_discovery_pipeline(disease_id):
tu = ToolUniverse(use_cache=True)
tu.load_tools()
try:
targets = tu.tools.OpenTargets_get_associated_targets_by_disease_efoId(efoId=disease_id)
compound_calls = [
{"name": "ChEMBL_search_molecule_by_target",
"arguments": {"target_id": t['id'], "limit": 10}}
for t in targets['data'][:5]
]
compounds = tu.run_batch(compound_calls)
return {"targets": targets, "compounds": compounds}
finally:
tu.close()
Configuration
tu = ToolUniverse(use_cache=True)
stats = tu.get_cache_stats()
tu.clear_cache()
tu = ToolUniverse(hooks_enabled=True)
tu.load_tools(categories=["proteins", "drugs"])
Critical Notes
- Always call
load_tools() before using any tools
- Tool Finder returns nested structure: access via
tools['tools'] after isinstance(tools, dict) check
- Tool names are case-sensitive:
UniProt_get_entry_by_accession not uniprot_get_...
- Check required params:
tu.all_tool_dict["ToolName"]['parameter'].get('required', [])
- Cache deterministic calls (ML predictions, DB queries); don't cache real-time data
Error Handling
from tooluniverse.exceptions import ToolError, ToolUnavailableError, ToolValidationError
try:
result = tu.tools.some_tool(param="value")
except ToolUnavailableError:
...
except ToolValidationError as e:
tool_info = tu.all_tool_dict["some_tool"]
print(f"Required: {tool_info['parameter'].get('required', [])}")
Tool Categories
| Category | Tools | Use Cases |
|---|
| Proteins | UniProt, RCSB PDB, AlphaFold | Protein analysis, structure |
| Drugs | DrugBank, ChEMBL, PubChem | Drug discovery, compounds |
| Genomics | Ensembl, NCBI Gene, gnomAD | Gene analysis, variants |
| Diseases | OpenTargets, ClinVar | Disease-target associations |
| Literature | PubMed, Europe PMC | Literature search |
| ML Models | ADMET-AI, AlphaFold | Predictions, modeling |
| Pathways | KEGG, Reactome | Pathway analysis |
Resources