💡 Examples & Tutorials

Practical examples showing how to use Nexus MCP Server tools for real-world tasks. From simple calculations to complex workflows.

🎯 Interactive Learning: These examples work with Claude Desktop, VS Code, or the HTTP API. Try them out!

🧮 Basic Tool Usage

Mathematical Operations

Simple Addition

Claude Prompt:

"Can you add 15 and 27 for me?"

Expected Tool: add

Result: 42

Complex Calculation

Claude Prompt:

"Calculate the compound interest for $1000 at 5% annual rate for 10 years"

Expected Tool: compound_interest

Result: $1,628.89

Text Processing

String Cleaning

Claude Prompt:

"Clean this messy text: '  Hello   World!  '"

Expected Tool: string_clean

Result: "Hello World!"

Base64 Encoding

Claude Prompt:

"Encode 'Hello World' to base64"

Expected Tool: base64_encode

Result: "SGVsbG8gV29ybGQ="

🔒 Security Tools

Password Generation

Secure Password

Claude Prompt:

"Generate a 16-character password with uppercase, lowercase, numbers, and symbols"

Expected Tool: password_generate

Parameters:

  • Length: 16
  • Include uppercase: true
  • Include numbers: true
  • Include symbols: true

Sample Result: "K3@mP9#zX8$vN2qY"

Hash Generation

SHA256 Hash

Claude Prompt:

"Generate a SHA256 hash for the text 'nexus-mcp-server'"

Expected Tool: generate_hash

Result: b8c6f2ae89e7c6d3f4a1b5c2e8f9d7a3c5e2f8b4d6a9c1e7f3b5d8a2c4e6f1b9

🖥️ System Information

System Overview

Get System Information

Claude Prompt:

"Show me the current system information"

Expected Tool: system_overview

Sample Result:

{
  "os": "Linux",
  "platform": "linux",
  "architecture": "x86_64",
  "cpu_count": 8,
  "memory_total": "16.0 GB",
  "memory_available": "12.3 GB",
  "uptime": "2 days, 5 hours"
}

Current Time & Date

Current Timestamp

Claude Prompt:

"What's the current Unix timestamp?"

Expected Tool: current_timestamp

Result: 1705315845

Formatted Date

Claude Prompt:

"Show me the current date and time in ISO format"

Expected Tool: current_datetime

Result: "2024-01-15T10:30:45Z"

🚀 Advanced Workflows

Data Processing Workflow

CSV Data Analysis

Claude Prompt:

"I have CSV data with sales figures. Can you help me process it?

Data:
Name,Sales,Region
John,1000,North
Jane,1500,South
Bob,800,North
Alice,1200,South

Please calculate:
1. Total sales
2. Average sales per person
3. Sales by region"

Expected Workflow:

  1. Parse CSV: csv_parse tool
  2. Calculate totals: add tool multiple times
  3. Calculate average: divide tool
  4. Group by region: Data analysis tools

Expected Results:

  • Total sales: $4,500
  • Average sales: $1,125
  • North region: $1,800
  • South region: $2,700

Security Audit Workflow

Website Security Check

Claude Prompt:

"Please perform a basic security audit on example.com including:
1. Port scan
2. SSL certificate check
3. HTTP headers analysis
4. DNS information"

Expected Workflow:

  1. Port Scan: port_scan tool
  2. SSL Check: ssl_certificate_info tool
  3. Headers: http_headers_check tool
  4. DNS Lookup: dns_lookup tool

🛠️ Dynamic Tool Creation Examples

Custom Date Parser

Parse Legacy Date Format

Claude Prompt:

"I have dates in the format '15-JAN-2024 14:30' and need them converted to ISO format. Can you create a tool to parse this?"

Expected Behavior:

  1. Claude recognizes the need for a custom tool
  2. Uses create_and_run_tool to create a date parser
  3. Generates Python code to handle the specific format
  4. Tests with the provided example
  5. Returns parsed result: "2024-01-15T14:30:00"

Generated Tool Code:

from datetime import datetime

def parse_legacy_date(date_str):
    """Parse date in format '15-JAN-2024 14:30' to ISO"""
    try:
        # Parse the custom format
        dt = datetime.strptime(date_str, '%d-%b-%Y %H:%M')
        return dt.isoformat()
    except ValueError as e:
        return f"Error parsing date: {e}"

# Test with provided example
result = parse_legacy_date("15-JAN-2024 14:30")
print(f"ISO format: {result}")

Data Format Transformer

Convert Proprietary Log Format

Claude Prompt:

"I have log entries like 'USER:john|ACTION:login|TIME:1705315845|STATUS:OK' and need them converted to JSON. Can you help?"

Dynamic Tool Creation:

import json

def parse_log_entry(log_str):
    """Parse custom log format to JSON"""
    try:
        # Split by pipe and then by colon
        parts = log_str.split('|')
        result = {}
        
        for part in parts:
            if ':' in part:
                key, value = part.split(':', 1)
                result[key.lower()] = value
        
        return json.dumps(result, indent=2)
    except Exception as e:
        return f"Error: {e}"

# Test with example
log_entry = "USER:john|ACTION:login|TIME:1705315845|STATUS:OK"
result = parse_log_entry(log_entry)
print(result)

Output:

{
  "user": "john",
  "action": "login", 
  "time": "1705315845",
  "status": "OK"
}

🌐 API Integration Examples

Python Script Integration

Automated Report Generation

#!/usr/bin/env python3
"""
Daily report generator using Nexus MCP Server API
"""

import requests
import json
from datetime import datetime

NEXUS_URL = "http://localhost:9999"

def call_nexus_tool(tool_name, args):
    """Execute a Nexus tool via HTTP API"""
    response = requests.post(f"{NEXUS_URL}/execute", json={
        "tool_name": tool_name,
        "arguments": args
    })
    return response.json()

def generate_daily_report():
    """Generate a daily system report"""
    print("🚀 Daily System Report")
    print("=" * 50)
    
    # Get current time
    time_result = call_nexus_tool("current_datetime", {})
    print(f"📅 Generated: {time_result['result']['datetime']}")
    
    # Get system info
    system_result = call_nexus_tool("system_overview", {})
    system_info = system_result['result']
    
    print(f"💻 System: {system_info.get('os', 'Unknown')}")
    print(f"🔧 CPU Cores: {system_info.get('cpu_count', 'Unknown')}")
    print(f"💾 Memory: {system_info.get('memory_total', 'Unknown')}")
    print(f"⏱️  Uptime: {system_info.get('uptime', 'Unknown')}")
    
    # Generate secure password for daily use
    password_result = call_nexus_tool("password_generate", {
        "length": 12,
        "include_symbols": True
    })
    print(f"🔒 Daily Password: {password_result['result']['password']}")
    
    # Calculate some metrics
    calc_result = call_nexus_tool("add", {"a": 100, "b": 50})
    print(f"📊 Sample Calculation: {calc_result['result']['sum']}")

if __name__ == "__main__":
    generate_daily_report()

🔍 Troubleshooting Examples

Common Issues & Solutions

Tool Not Found

Problem: "Tool 'calculate' not found"

Solution:

  • Check tool name: Use add instead of calculate
  • List available tools first
  • Check configuration file

Invalid Arguments

Problem: Arguments validation fails

Solution:

  • Check parameter names and types
  • Ensure required parameters are provided
  • Use correct data types (numbers vs strings)

✨ Best Practices

💡 Tips for Effective Usage

  • Be Specific: Provide clear, detailed prompts for better tool selection
  • Use Examples: Include sample data when asking for transformations
  • Chain Operations: Break complex tasks into smaller steps
  • Validate Results: Always verify outputs, especially for critical operations
  • Error Handling: Be prepared for tool failures and have fallback strategies

Effective Prompting

✅ Good Prompt

"Generate a SHA256 hash for the password 'mySecret123' and also create a secure 16-character replacement password with symbols"

Why it's good: Clear, specific, actionable

❌ Poor Prompt

"Do some security stuff"

Why it's poor: Vague, no clear objective

🎯 Next Steps

🔌 API Examples

Explore language-specific API integration examples

API Examples →

🛠️ Dynamic Tools

Learn more about creating custom tools on-demand

Dynamic Tools →

📚 Complete Reference

Browse all available tools and their parameters

Tools Reference →

🚀 Deployment

Deploy Nexus in production environments

Deployment Guide →