Skip to content

Add shell tab completion scripts for zsh and bash #257

Description

@KryptosAI

Summary

Add shell tab completion for zsh and bash so users can autocomplete commands, flags, and server names when using the CLI.

Files to modify

  • scripts/completions/_mcp-observatory (new zsh completion script)
  • scripts/completions/mcp-observatory.bash (new bash completion script)
  • package.json — add a postinstall script hint or note in README about sourcing completions

What to change

  1. Create a zsh completion file at scripts/completions/_mcp-observatory that:
    • Autocompletes top-level commands: test, scan, report, history, setup-ci, demo
    • Autocompletes flags: --json, --watch, --accessible, --quiet, --timeout, etc.
    • Autocompletes --format values: json, markdown, terminal, html
  2. Create a bash completion file at scripts/completions/mcp-observatory.bash with the same completions.
  3. Add a note to the README installation section:
    # zsh
    source <(mcp-observatory completion zsh)
    # bash
    source <(mcp-observatory completion bash)
  4. Follow the existing command definitions in src/commands/ to ensure all flags and subcommands are covered.

Reference

Use existing CLI command definitions in src/commands/*.ts for flag names. See similar completions in projects like gh or kubectl for patterns.

Estimated time

~20 minutes

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:cliCLI UX, command surface, and error messaginggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions