mcp_registry_client.commands
Command pattern implementation for CLI commands.
BaseCommand
Bases: ABC
Abstract base class for CLI commands.
Provides a standard interface for command validation, execution, and output formatting.
Source code in mcp_registry_client/commands/base.py
__init__(args)
Initialize command with parsed arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command line arguments |
required |
execute()
abstractmethod
async
Execute the command logic.
Returns:
| Type | Description |
|---|---|
Any
|
Command execution result |
Raises:
| Type | Description |
|---|---|
Exception
|
Various exceptions based on command implementation |
format_output(result)
abstractmethod
Format and display command output.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Any
|
Result from execute() method |
required |
run()
async
Run the complete command workflow.
Returns:
| Type | Description |
|---|---|
int
|
Exit code (0 for success, non-zero for error) |
Source code in mcp_registry_client/commands/base.py
validate_args()
abstractmethod
InfoCommand
Bases: BaseCommand
Command to get detailed information about a specific server.
Source code in mcp_registry_client/commands/info.py
__init__(args)
Initialize info command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command line arguments containing 'server_name' and 'json' |
required |
execute()
async
Execute the info command.
Returns:
| Type | Description |
|---|---|
Server
|
Server information from the registry client |
Raises:
| Type | Description |
|---|---|
RegistryAPIError
|
If API request fails |
RegistryClientError
|
If client processing fails |
RequestError
|
If HTTP request fails |
ValidationError
|
If response validation fails |
ValueError
|
If server is not found |
Source code in mcp_registry_client/commands/info.py
format_output(result)
Format and display server information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
Server
|
Server object with detailed information |
required |
Source code in mcp_registry_client/commands/info.py
validate_args()
Validate info command arguments.
Raises:
| Type | Description |
|---|---|
ValueError
|
If server name is invalid |
SearchCommand
Bases: BaseCommand
Command to search for MCP servers in the registry.
Source code in mcp_registry_client/commands/search.py
__init__(args)
Initialize search command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
args
|
Namespace
|
Parsed command line arguments containing 'name' and 'json' |
required |
execute()
async
Execute the search command.
Returns:
| Type | Description |
|---|---|
SearchResponse
|
Search result from the registry client |
Raises:
| Type | Description |
|---|---|
RegistryAPIError
|
If API request fails |
RegistryClientError
|
If client processing fails |
RequestError
|
If HTTP request fails |
ValidationError
|
If response validation fails |
Source code in mcp_registry_client/commands/search.py
format_output(result)
Format and display search results.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
result
|
SearchResponse
|
Search result containing servers list |
required |
Source code in mcp_registry_client/commands/search.py
validate_args()
Validate search command arguments.
Raises:
| Type | Description |
|---|---|
ValueError
|
If search term is invalid |