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 ("" )
0 commit comments