Skip to content

Conversation

@technicalpickles
Copy link

@technicalpickles technicalpickles commented Sep 6, 2025

Summary

Adds non-interactive CLI commands for listing MCP server capabilities, allowing users to inspect tools, resources, and prompts without entering interactive mode.

New Commands

  • mcp-cli list-tools <server> - List available tools with descriptions
  • mcp-cli list-resources <server> - List static resources and resource templates
  • mcp-cli list-prompts <server> - List available prompts with arguments
  • mcp-cli list-all <server> - Show overview of all server capabilities

Features

  • Works with existing server types: Uses the same stdio commands, remote HTTP/SSE endpoints, and config file entries that interactive mode already supports
  • Two output formats: Human-readable output (default) and JSON output with --json flag
  • Reuses existing auth: OAuth flows for remote servers work the same as interactive mode
  • Consistent with existing patterns: Uses same connection logic, error handling, and server discovery

Usage Examples

# Server defined in config file
mcp-cli list-tools sqlite

# Direct stdio command (same as interactive mode)
mcp-cli list-tools npx @modelcontextprotocol/server-sqlite /path/to/db

# Remote server via URL flag
mcp-cli --url http://localhost:8000/mcp list-resources

# JSON output for scripting
mcp-cli list-all sqlite --json

# Custom config file
mcp-cli --config ./my-config.json list-tools my-server-name

Implementation Notes

  • Extends existing listPrimitives function used by interactive mode
  • Adds new CLI routing for list commands alongside existing patterns
  • New formatting functions for human-readable output
  • Maintains all existing functionality - no changes to interactive mode behavior

Backward Compatibility

  • No breaking changes to existing CLI interface
  • Interactive mode unchanged
  • All existing server configurations work as before

🤖 Generated with Claude Code

@technicalpickles technicalpickles force-pushed the add-list-commands branch 4 times, most recently from f8fe988 to ed968aa Compare September 6, 2025 21:15
@technicalpickles technicalpickles changed the title Add non-interactive listing commands for MCP servers Add non-interactive MCP server listing commands with optimized architecture Sep 6, 2025
@technicalpickles technicalpickles changed the title Add non-interactive MCP server listing commands with optimized architecture feat: Add non-interactive MCP server listing commands Sep 6, 2025
Add comprehensive CLI commands for listing MCP server capabilities without interactive mode:
- list-tools: List all available tools with descriptions
- list-resources: List static resources and resource templates
- list-prompts: List available prompts with arguments
- list-all: Comprehensive overview of all server capabilities

Features:
- Multiple server types: config stdio, remote HTTP/SSE, URL servers in config
- Dual output formats: human-readable with colors + JSON (--json flag)
- OAuth authentication support for remote servers
- Consistent data structure across all commands
- Performance optimized with concurrent Promise.all API calls

Architecture:
- Type-specific formatters (formatListTools, formatListPrompts, formatListResources)
- Compositional design with formatListAll reusing existing formatters
- Single unified data format: {capabilities, tools, prompts, resources, resourceTemplates}
- Zero code duplication with helper functions like shouldInclude
- Clean separation of data fetching, filtering, and formatting

Maintains full backward compatibility - no breaking changes to existing CLI interface.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
technicalpickles and others added 4 commits September 6, 2025 23:02
Add comprehensive documentation for the new non-interactive list commands:
- list-tools, list-resources, list-prompts, list-all
- Examples for config-based, stdio, and remote servers
- JSON output flag usage for scripting

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fix regression in interactive mode where no primitives were shown after
connecting to server. The filtering logic in listPrimitives was incorrectly
excluding all primitive types when filter=null (interactive mode).

Refactored to use existing shouldInclude() helper function which properly
handles null filters for interactive mode while maintaining compatibility
with filtered list commands.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fix ERR_INVALID_ARG_TYPE error when using HTTP/SSE MCP servers from config
in interactive mode. The runWithConfig function was incorrectly trying to
use StdioClientTransport for all servers regardless of transport type.

Now properly detects URL-based servers and uses connectRemoteServer with
HTTP transport, while maintaining stdio support for command-based servers.

Matches the logic already implemented in runListCommand for consistency.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Fix regression where selecting primitives in interactive mode would not execute them.
The choices array structure was changed during list commands refactoring but the
selection handler still expected the old format with type and value properties.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@technicalpickles technicalpickles marked this pull request as ready for review September 9, 2025 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant