tool.py•3.72 kB
"""
Tool management commands for the MCP Connection Hub CLI.
This module provides commands for managing tools and plugins.
"""
import typer
from typing import Optional
from rich.console import Console
from rich.table import Table
# Create Typer app for tool commands
app = typer.Typer(name="tool", help="Manage tools and plugins")
# Create Console for rich output
console = Console()
@app.command("list")
def list_tools(
verbose: bool = typer.Option(False, "--verbose", "-v", help="Show detailed information")
):
"""
List all available tools.
"""
table = Table(title="Available Tools")
if verbose:
table.add_column("Name", style="cyan")
table.add_column("Description", style="green")
table.add_column("Version", style="blue")
table.add_column("Status", style="yellow")
table.add_column("Execution Mode", style="magenta")
# Add placeholder data (will be implemented properly in future milestones)
table.add_row(
"brave_web_search",
"Performs web searches using the Brave Search API",
"0.1.0",
"Enabled",
"Sync"
)
else:
table.add_column("Name", style="cyan")
table.add_column("Status", style="green")
# Add placeholder data (will be implemented properly in future milestones)
table.add_row("brave_web_search", "Enabled")
console.print(table)
@app.command("enable")
def enable_tool(
name: str = typer.Argument(..., help="Name of the tool to enable")
):
"""
Enable a tool.
"""
# Placeholder implementation (will be implemented properly in future milestones)
console.print(f"[green]Tool '{name}' has been enabled[/green]")
@app.command("disable")
def disable_tool(
name: str = typer.Argument(..., help="Name of the tool to disable")
):
"""
Disable a tool.
"""
# Placeholder implementation (will be implemented properly in future milestones)
console.print(f"[yellow]Tool '{name}' has been disabled[/yellow]")
@app.command("info")
def tool_info(
name: str = typer.Argument(..., help="Name of the tool to get info for")
):
"""
Show detailed information about a tool.
"""
# Placeholder implementation (will be implemented properly in future milestones)
if name == "brave_web_search":
console.print(f"[bold cyan]Tool: {name}[/bold cyan]")
console.print("Description: Performs web searches using the Brave Search API")
console.print("Version: 0.1.0")
console.print("Status: Enabled")
console.print("Execution Mode: Sync")
console.print("\nFunctions:")
console.print(" - web_search: Perform a web search")
console.print(" - local_search: Search for local businesses and places")
else:
console.print(f"[red]Tool '{name}' not found[/red]")
@app.command("configure")
def configure_tool(
name: str = typer.Argument(..., help="Name of the tool to configure"),
param: Optional[str] = typer.Option(None, "--param", "-p", help="Parameter to set"),
value: Optional[str] = typer.Option(None, "--value", "-v", help="Value to set")
):
"""
Configure a tool's parameters.
"""
# Placeholder implementation (will be implemented properly in future milestones)
if param and value:
console.print(f"[green]Set {name}.{param} = {value}[/green]")
else:
# Show current configuration
console.print(f"[bold cyan]Configuration for {name}:[/bold cyan]")
console.print("enabled = true")
console.print("execution_mode = sync")
console.print("timeout = 10")
console.print("max_results = 10")