Troubleshooting Tutorial

This Tutorial helps you diagnose and resolve common issues with ToolUniverse.

Quick Diagnostic

Run this diagnostic script to check your ToolUniverse installation:

from tooluniverse import ToolUniverse

# Run basic system check
try:
    tu = ToolUniverse()
    tu.load_tools()
    print(f"✅ ToolUniverse working correctly! {len(tu.all_tools)} tools loaded.")
except Exception as e:
    print(f"❌ Issue detected: {e}")

Most common installation problems and solutions.

Installation Issues

ImportError: No module named ‘tooluniverse’

Symptom: Python can’t find the ToolUniverse module.

Diagnosis:

python -c "import tooluniverse; print(tooluniverse.__version__)"

Solutions:

pip install tooluniverse

Dependency conflicts

Symptom: Conflicting package versions during installation.

Check dependencies:

pip check

Solutions:

  1. Create clean environment:

    conda create -n tooluniverse python=3.10
    conda activate tooluniverse
    pip install tooluniverse
    
  2. Update conflicting packages:

    pip install --upgrade requests urllib3 certifi
    
  3. Install specific versions:

    pip install 'requests>=2.25.0,<3.0.0'
    

Runtime Errors

Tool not found errors

Symptom: ToolNotFoundError: Tool 'XYZ' not found

Diagnosis:

from tooluniverse import ToolUniverse

tu = ToolUniverse()
tu.load_tools()

# List available tools
print("Available tools:")
for tool_name in tu.list_tools():
    print(f"  - {tool_name}")

Solutions:

  1. Check tool name spelling:

    # Correct tool names
    correct_names = [
        "OpenTargets_get_associated_targets_by_disease_efoId",
        "PubChem_get_compound_info",
        "UniProt_get_protein_info"
    ]
    
  2. Verify tool is loaded:

    if "OpenTargets_tool" not in tu.list_tools():
        print("OpenTargets tool not loaded")
        # Check for missing dependencies
    
  3. Manual tool loading:

    from tooluniverse.opentargets_tool import OpenTargetsTool
    tool = OpenTargetsTool()
    tu.register_tool(tool)
    

API Authentication errors

Symptom: 401 Unauthorized or 403 Forbidden errors.

Diagnosis:

import os

# Check if API keys are set
api_keys = {
    'OPENTARGETS_API_KEY': os.getenv('OPENTARGETS_API_KEY'),
    'NCBI_API_KEY': os.getenv('NCBI_API_KEY'),
    'CHEMBL_API_KEY': os.getenv('CHEMBL_API_KEY')
}

for key, value in api_keys.items():
    status = "✓ Set" if value else "✗ Missing"
    print(f"{key}: {status}")

Solutions:

  1. Set API keys:

    export OPENTARGETS_API_KEY="your_key_here"
    export NCBI_API_KEY="your_ncbi_key"
    
  2. In Python:

    import os
    os.environ['OPENTARGETS_API_KEY'] = 'your_key_here'
    
  3. Use .env file:

    # Create .env file
    echo "OPENTARGETS_API_KEY=your_key" >> .env
    echo "NCBI_API_KEY=your_ncbi_key" >> .env
    
    from dotenv import load_dotenv
    load_dotenv()
    

Rate limiting errors

Symptom: 429 Too Many Requests or RateLimitExceeded

Diagnosis:

# Check rate limit status
from tooluniverse.utils import check_rate_limits

status = check_rate_limits()
print(f"Rate limit status: {status}")

Solutions:

  1. Add delays between requests:

    import time
    
    for query in queries:
         result = tu.run(query)
         time.sleep(1)  # Wait 1 second between requests
    
  2. Use batch processing:

    # Process in smaller batches
    batch_size = 5
    for i in range(0, len(queries), batch_size):
         batch = queries[i:i+batch_size]
         results = tu.run_batch(batch)
         time.sleep(2)  # Pause between batches
    
  3. Get API keys for higher limits:

    Most services offer higher rate limits with API keys.

Network & Connectivity

Connection timeouts

Symptom: ConnectionTimeout or ReadTimeout errors.

Diagnosis:

import requests

# Test basic connectivity
try:
    response = requests.get('https://httpbin.org/delay/1', timeout=5)
    print(f"Network OK: {response.status_code}")
except requests.exceptions.Timeout:
    print("Network timeout - check connection")

Solutions:

  1. Increase timeout:

    tu = ToolUniverse(timeout=30)  # 30 second timeout
    
  2. Check network connection:

    ping google.com
    curl -I https://platform-api.opentargets.org
    
  3. Configure proxy (if needed):

    import os
    os.environ['HTTP_PROXY'] = 'http://proxy.company.com:8080'
    os.environ['HTTPS_PROXY'] = 'http://proxy.company.com:8080'
    

SSL Certificate errors

Symptom: SSLError or certificate verification failures.

Solutions:

  1. Update certificates:

    pip install --upgrade certifi requests urllib3
    
  2. Temporary bypass (not recommended for production):

    import ssl
    ssl._create_default_https_context = ssl._create_unverified_context
    
  3. Corporate firewall:

    Contact your IT department for proper certificate configuration.

Performance Issues

Slow query performance

Diagnosis:

import time
from tooluniverse import ToolUniverse

tu = ToolUniverse()

# Time a query
start_time = time.time()
result = tu.run({"name": "tool_name", "arguments": {}})
elapsed = time.time() - start_time

print(f"Query took {elapsed:.2f} seconds")

Optimization strategies:

  1. Enable caching:

    tu = ToolUniverse(enable_cache=True, cache_ttl=3600)
    
  2. Use async operations:

    import asyncio
    
    async def run_queries():
         tasks = [tu.run_async(query) for query in queries]
         results = await asyncio.gather(*tasks)
         return results
    
  3. Batch similar queries:

    # Instead of individual queries
    gene_info = []
    for gene in genes:
         info = tu.run({
             "name": "UniProt_get_protein_info",
             "arguments": {"gene_symbol": gene}
         })
         gene_info.append(info)
    
    # Use batch processing
    queries = [
         {"name": "UniProt_get_protein_info", "arguments": {"gene_symbol": gene}}
         for gene in genes
    ]
    results = tu.run_batch(queries)
    

Memory usage issues

Symptom: High memory consumption or MemoryError.

Diagnosis:

import psutil
import os

process = psutil.Process(os.getpid())
memory_mb = process.memory_info().rss / 1024 / 1024
print(f"Memory usage: {memory_mb:.1f} MB")

Solutions:

  1. Process data in chunks:

    def process_large_dataset(data, chunk_size=100):
         for i in range(0, len(data), chunk_size):
             chunk = data[i:i+chunk_size]
             yield tu.run_batch(chunk)
    
  2. Clear cache periodically:

    tu.clear_cache()
    
  3. Use generators for large results:

    def yield_results(queries):
         for query in queries:
             yield tu.run(query)
    

MCP Server Issues

MCP server won’t start

Symptom: Server fails to start or crashes immediately.

Diagnosis:

# Test server directly
python -m tooluniverse.smcp_server --debug

Solutions:

  1. Check port availability:

    # Check if port is in use
    lsof -i :3000  # Linux/Mac
    netstat -an | findstr :3000  # Windows
    
  2. Use different port:

    python -m tooluniverse.smcp_server --port 3001
    
  3. Check permissions:

    # Ensure user can bind to port
    sudo python -m tooluniverse.smcp_server  # If needed
    

Claude/AI assistant not finding tools

Diagnosis:

  1. Verify MCP server is running:

    curl http://localhost:3000/health
    
  2. Check Claude configuration:

    Ensure MCP server is properly configured in Claude Desktop settings.

Solutions:

  1. Restart both server and Claude

  2. Check Claude logs for connection errors

  3. Verify tool registration:

    # In MCP server
    tools = tu.list_tools()
    print(f"Registered {len(tools)} tools")
    

Advanced Debugging

Enable debug logging

import logging

# Enable debug logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger('tooluniverse')
logger.setLevel(logging.DEBUG)

# Now run your code
tu = ToolUniverse()

Capture detailed error information

import traceback

try:
    result = tu.run(query)
except Exception as e:
    print(f"Error: {e}")
    print(f"Type: {type(e).__name__}")
    print("Traceback:")
    traceback.print_exc()

Profile performance bottlenecks

import cProfile
import pstats

# Profile your code
profiler = cProfile.Profile()
profiler.enable()

# Your ToolUniverse code here
tu = ToolUniverse()
result = tu.run(query)

profiler.disable()

# Analyze results
stats = pstats.Stats(profiler)
stats.sort_stats('cumulative')
stats.print_stats(10)

Getting Help

If none of these solutions work:

  1. Check the FAQ: FAQ - Frequently Asked Questions

  2. Search GitHub issues: Issues

  3. Create a bug report with:

    • ToolUniverse version: tooluniverse.__version__

    • Python version: python --version

    • Operating system

    • Full error message and traceback

    • Minimal code example that reproduces the issue

  4. Join our community: Discord server link

from tooluniverse.diagnostics import run_diagnostic
print(run_diagnostic())

Include this output in your bug report.