feat: list command enhancements with tool filtering and brief output#62
feat: list command enhancements with tool filtering and brief output#62yuhp wants to merge 8 commits intosteipete:mainfrom
Conversation
Implements --brief flag for concise tool signatures and adds positional argument support for filtering tools by name patterns.
Prioritizes positional argument as tool pattern instead of target name when ephemeral flags (e.g. --http-url) are present.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0e0e5f877
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Handle --brief output mode | ||
| if (flags.brief) { | ||
| if (metadataEntries.length === 0) { | ||
| if (toolPattern) { | ||
| console.log(`No tools matching pattern '${toolPattern}'.`); | ||
| } else { | ||
| console.log('No tools available.'); | ||
| } | ||
| return; | ||
| } | ||
| printBriefToolList(metadataEntries, { colorize: true }); | ||
| return; |
There was a problem hiding this comment.
Reject or honor --json when --brief is set
When --brief is supplied alongside --json, the handler bypasses JSON output and prints text signatures, then returns early. That breaks callers that rely on --json for machine-readable output (e.g., mcporter list server --json --brief), because the format silently changes to plain text. Either treat --brief as mutually exclusive with --json in extractListFlags, or emit a JSON payload for brief mode so the --json contract is preserved.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed this by making --brief and --json mutually exclusive in [extractListFlags]. Supplying both will now throw an error with a clear message, ensuring the --json contract isn't silently broken.
I've also updated the following to reflect this change:
- Help output in [src/cli/list-command.ts]
README.mddocs/cli-reference.md
|
Synced with latest upstream changes
|
Description: Enhance list command with tool filtering and brief output
💡 Motivation
When an MCP server provides a large number of tools, the default list command outputs extensive tool descriptions. This leads to two main issues:
mcporteris used by LLMs to discover tools, providing full descriptions for dozens of irrelevant tools quickly exhausts the context window and increases costs.This PR introduces filtering and a
--briefmode to allow both users and LLMs to interact with tools more efficiently.Key Changes
🚀 Features
[tool-pattern]positional argument. You can now filter tools by name using simple string matching (e.g.,mcporter list context "query*").--brief): Show only tool names, omitting descriptions. This significantly reduces token usage and stdout noise when a server has many tools.🐛 Bug Fixes
--http-urlor--command).📝 Documentation
Examples
Get a concise list of all tool names (Token-efficient):
Filter for specific tool sets:
mcporter list context7 "query-*"Show full details for only one specific tool: