MCPcopy Create free account
hub / github.com/IBM/mcp-cli / token_command

Function token_command

src/mcp_cli/main.py:1417–1491  ·  view source on GitHub ↗

Manage stored tokens and credentials.

(
    action: str = typer.Argument(
        ...,
        help="Action: list, set, get, delete, clear, backends, set-provider, get-provider, delete-provider",
    ),
    name: str | None = typer.Argument(
        None, help="Token/provider name (for set/get/delete actions)"
    ),
    token_type: str = typer.Option(
        "bearer", "--type", "-t", help="Token type (bearer, api-key, generic)"
    ),
    value: str | None = typer.Option(None, "--value", help="Token value"),
    provider: str | None = typer.Option(
        None, "--provider", "-p", help="Provider name (for API keys)"
    ),
    namespace: str | None = typer.Option(
        None, "--namespace", "-n", help="Storage namespace"
    ),
    show_oauth: bool = typer.Option(
        True, "--show-oauth/--no-oauth", help="Show OAuth tokens (list)"
    ),
    show_bearer: bool = typer.Option(
        True, "--show-bearer/--no-bearer", help="Show bearer tokens (list)"
    ),
    show_api_keys: bool = typer.Option(
        True, "--show-api-keys/--no-api-keys", help="Show API keys (list)"
    ),
    show_providers: bool = typer.Option(
        True, "--show-providers/--no-providers", help="Show provider tokens (list)"
    ),
    is_oauth: bool = typer.Option(
        False, "--is-oauth", help="Delete OAuth token (delete)"
    ),
    force: bool = typer.Option(
        False, "--force", "-f", help="Skip confirmation (clear)"
    ),
    quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
    verbose: bool = typer.Option(False, "--verbose", help="Enable verbose logging"),
    log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
)

Source from the content-addressed store, hash-verified

1415# Token command - manage individual tokens (use 'tokens' to list all)
1416@app.command("token", help="Manage individual tokens (use 'tokens' to list)")
1417def token_command(
1418 action: str = typer.Argument(
1419 ...,
1420 help="Action: list, set, get, delete, clear, backends, set-provider, get-provider, delete-provider",
1421 ),
1422 name: str | None = typer.Argument(
1423 None, help="Token/provider name (for set/get/delete actions)"
1424 ),
1425 token_type: str = typer.Option(
1426 "bearer", "--type", "-t", help="Token type (bearer, api-key, generic)"
1427 ),
1428 value: str | None = typer.Option(None, "--value", help="Token value"),
1429 provider: str | None = typer.Option(
1430 None, "--provider", "-p", help="Provider name (for API keys)"
1431 ),
1432 namespace: str | None = typer.Option(
1433 None, "--namespace", "-n", help="Storage namespace"
1434 ),
1435 show_oauth: bool = typer.Option(
1436 True, "--show-oauth/--no-oauth", help="Show OAuth tokens (list)"
1437 ),
1438 show_bearer: bool = typer.Option(
1439 True, "--show-bearer/--no-bearer", help="Show bearer tokens (list)"
1440 ),
1441 show_api_keys: bool = typer.Option(
1442 True, "--show-api-keys/--no-api-keys", help="Show API keys (list)"
1443 ),
1444 show_providers: bool = typer.Option(
1445 True, "--show-providers/--no-providers", help="Show provider tokens (list)"
1446 ),
1447 is_oauth: bool = typer.Option(
1448 False, "--is-oauth", help="Delete OAuth token (delete)"
1449 ),
1450 force: bool = typer.Option(
1451 False, "--force", "-f", help="Skip confirmation (clear)"
1452 ),
1453 quiet: bool = typer.Option(False, "-q", "--quiet", help="Suppress most log output"),
1454 verbose: bool = typer.Option(False, "--verbose", help="Enable verbose logging"),
1455 log_level: str = typer.Option("WARNING", "--log-level", help="Set log level"),
1456) -> None:
1457 """Manage stored tokens and credentials."""
1458 # Configure logging for this command
1459 _setup_command_logging(quiet, verbose, log_level, "default")
1460
1461 # Use unified command system via CLI adapter
1462 from mcp_cli.adapters.cli import cli_execute
1463 import asyncio
1464
1465 # Compute default namespace
1466 default_namespace = token_type if token_type in ["bearer", "api-key"] else "generic"
1467
1468 async def _token_wrapper():
1469 return await cli_execute(
1470 "token",
1471 action=action,
1472 name=name
1473 if action not in ["set-provider", "get-provider", "delete-provider"]
1474 else None,

Callers

nothing calls this directly

Calls 3

_setup_command_loggingFunction · 0.85
_token_wrapperFunction · 0.85
runMethod · 0.80

Tested by

no test coverage detected