Skip to content

Commit 987937f

Browse files
committed
feat(command): Add info command and simplify search output
1 parent 2432b3b commit 987937f

File tree

7 files changed

+11072
-7
lines changed

7 files changed

+11072
-7
lines changed

package-lock.json

Lines changed: 10717 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mcpm/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
add,
1313
client,
1414
config,
15+
info,
1516
inspector,
1617
list,
1718
pop,
@@ -147,6 +148,7 @@ def main(ctx, help_flag, version):
147148

148149
commands_table.add_row("[yellow]server[/]")
149150
commands_table.add_row(" [cyan]search[/]", "Search available MCP servers.")
151+
commands_table.add_row(" [cyan]info[/]", "Show detailed information about a specific MCP server.")
150152
commands_table.add_row(" [cyan]add[/]", "Add an MCP server directly to a client.")
151153
commands_table.add_row(" [cyan]cp[/]", "Copy a server from one client/profile to another.")
152154
commands_table.add_row(" [cyan]mv[/]", "Move a server from one client/profile to another.")
@@ -175,6 +177,7 @@ def main(ctx, help_flag, version):
175177

176178
# Register commands
177179
main.add_command(search.search)
180+
main.add_command(info.info)
178181
main.add_command(remove.remove, name="rm")
179182
main.add_command(add.add)
180183
main.add_command(list.list, name="ls")

src/mcpm/commands/info.py

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
"""
2+
Info command for MCPM - Show detailed information about a specific MCP server
3+
"""
4+
5+
import click
6+
from rich.console import Console
7+
8+
from mcpm.utils.display import print_error
9+
from mcpm.utils.repository import RepositoryManager
10+
11+
console = Console()
12+
repo_manager = RepositoryManager()
13+
14+
15+
@click.command()
16+
@click.argument("server_name", required=True)
17+
@click.help_option("-h", "--help")
18+
def info(server_name):
19+
"""Display detailed information about a specific MCP server.
20+
21+
Provides comprehensive details about a single MCP server, including installation instructions,
22+
dependencies, environment variables, and examples.
23+
24+
Examples:
25+
26+
\b
27+
mcpm info github # Show details for the GitHub server
28+
mcpm info pinecone # Show details for the Pinecone server
29+
"""
30+
console.print(f"[bold green]Showing information for MCP server:[/] [bold cyan]{server_name}[/]")
31+
32+
try:
33+
# Get the server information
34+
server = repo_manager.get_server_metadata(server_name)
35+
36+
if not server:
37+
console.print(f"[yellow]Server '[bold]{server_name}[/]' not found.[/]")
38+
return
39+
40+
# Display detailed information for this server
41+
_display_server_info(server)
42+
43+
except Exception as e:
44+
print_error(f"Error retrieving information for server '{server_name}'", str(e))
45+
46+
47+
def _display_server_info(server):
48+
"""Display detailed information about a server"""
49+
# Get server data
50+
name = server["name"]
51+
display_name = server.get("display_name", name)
52+
description = server.get("description", "No description")
53+
license_info = server.get("license", "Unknown")
54+
55+
# Get author info
56+
author_info = server.get("author", {})
57+
author_name = author_info.get("name", "Unknown")
58+
author_email = author_info.get("email", "")
59+
author_url = author_info.get("url", "")
60+
61+
# Build categories and tags
62+
categories = server.get("categories", [])
63+
tags = server.get("tags", [])
64+
65+
# Get installation details
66+
installations = server.get("installations", {})
67+
installation = server.get("installation", {})
68+
package = installation.get("package", "")
69+
70+
# Print server header
71+
console.print(f"[bold cyan]{display_name}[/] [dim]({name})[/]")
72+
console.print(f"[italic]{description}[/]\n")
73+
74+
# Server information section
75+
console.print("[bold yellow]Server Information:[/]")
76+
if categories:
77+
console.print(f"Categories: {', '.join(categories)}")
78+
if tags:
79+
console.print(f"Tags: {', '.join(tags)}")
80+
if package:
81+
console.print(f"Package: {package}")
82+
console.print(f"Author: {author_name}" + (f" ({author_email})" if author_email else ""))
83+
console.print(f"License: {license_info}")
84+
console.print("")
85+
86+
# URLs section
87+
console.print("[bold yellow]URLs:[/]")
88+
89+
# Repository URL
90+
if "repository" in server and "url" in server["repository"]:
91+
repo_url = server["repository"]["url"]
92+
console.print(f"Repository: [blue underline]{repo_url}[/]")
93+
94+
# Homepage URL
95+
if "homepage" in server:
96+
homepage_url = server["homepage"]
97+
console.print(f"Homepage: [blue underline]{homepage_url}[/]")
98+
99+
# Documentation URL
100+
if "documentation" in server:
101+
doc_url = server["documentation"]
102+
console.print(f"Documentation: [blue underline]{doc_url}[/]")
103+
104+
# Author URL
105+
if author_url:
106+
console.print(f"Author URL: [blue underline]{author_url}[/]")
107+
108+
console.print("")
109+
110+
# Installation details section
111+
if installations:
112+
console.print("[bold yellow]Installation Details:[/]")
113+
for method_name, method in installations.items():
114+
method_type = method.get("type", "unknown")
115+
description = method.get("description", f"{method_type} installation")
116+
recommended = " [green](recommended)[/]" if method.get("recommended", False) else ""
117+
118+
console.print(f"[cyan]{method_type}[/]: {description}{recommended}")
119+
120+
# Show command if available
121+
if "command" in method:
122+
cmd = method["command"]
123+
args = method.get("args", [])
124+
cmd_str = f"{cmd} {' '.join(args)}" if args else cmd
125+
console.print(f"Command: [green]{cmd_str}[/]")
126+
127+
# Show dependencies if available
128+
dependencies = method.get("dependencies", [])
129+
if dependencies:
130+
console.print("Dependencies: " + ", ".join(dependencies))
131+
132+
# Show environment variables if available
133+
env_vars = method.get("env", {})
134+
if env_vars:
135+
console.print("Environment Variables:")
136+
for key, value in env_vars.items():
137+
console.print(f' [bold blue]{key}[/] = [green]"{value}"[/]')
138+
console.print("")
139+
140+
# Examples section
141+
examples = server.get("examples", [])
142+
if examples:
143+
console.print("[bold yellow]Examples:[/]")
144+
for i, example in enumerate(examples):
145+
if "title" in example:
146+
console.print(f"[bold]{i+1}. {example['title']}[/]")
147+
if "description" in example:
148+
console.print(f" {example['description']}")
149+
if "code" in example:
150+
console.print(f" Code: [green]{example['code']}[/]")
151+
if "prompt" in example:
152+
console.print(f" Prompt: [green]{example['prompt']}[/]")
153+
console.print("")

src/mcpm/commands/search.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import click
66
from rich.console import Console
77

8-
from mcpm.utils.display import print_error, print_servers_table
8+
from mcpm.utils.display import print_error, print_servers_table, print_simple_servers_list
99
from mcpm.utils.repository import RepositoryManager
1010

1111
console = Console()
@@ -15,17 +15,20 @@
1515
@click.command()
1616
@click.argument("query", required=False)
1717
@click.option("--detailed", is_flag=True, help="Show detailed server information")
18+
@click.option("--table", is_flag=True, help="Display results in table format with descriptions")
1819
@click.help_option("-h", "--help")
19-
def search(query, detailed=False):
20+
def search(query, detailed=False, table=False):
2021
"""Search available MCP servers.
2122
2223
Searches the MCP registry for available servers. Without arguments, lists all available servers.
24+
By default, only shows server names. Use --table for more details or --detailed for full information.
2325
2426
Examples:
2527
2628
\b
27-
mcpm search # List all available servers
29+
mcpm search # List all available servers (names only)
2830
mcpm search github # Search for github server
31+
mcpm search --table # Show results in a table with descriptions
2932
mcpm search --detailed # Show detailed information
3033
"""
3134
# Show appropriate search message
@@ -52,8 +55,10 @@ def search(query, detailed=False):
5255
# Show different views based on detail level
5356
if detailed:
5457
_display_detailed_results(servers)
55-
else:
58+
elif table:
5659
print_servers_table(servers)
60+
else:
61+
print_simple_servers_list(servers)
5762

5863
# Show summary count
5964
console.print(f"\n[green]Found {len(servers)} server(s) matching search criteria[/]")

src/mcpm/utils/display.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,25 @@ def print_servers_table(servers):
8080
console.print(table)
8181

8282

83+
def print_simple_servers_list(servers):
84+
"""Display a simple list of server names.
85+
86+
Args:
87+
servers: List of server dictionaries containing server information
88+
"""
89+
# Sort servers by name for consistent display
90+
sorted_servers = sorted(servers, key=lambda s: s["name"])
91+
92+
# Calculate the number of servers to display in each column
93+
total_servers = len(sorted_servers)
94+
95+
# Format and print each server name
96+
for server in sorted_servers:
97+
name = server["name"]
98+
display_name = server.get("display_name", name)
99+
console.print(f"[cyan]{name}[/]")
100+
101+
83102
def print_error(message, details=None):
84103
"""Print a standardized error message.
85104

0 commit comments

Comments
 (0)