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