MCP Demo commited on
Commit
ed036f6
Β·
1 Parent(s): c4352b7

Fix: Query input now properly affects search results - dynamic content based on user input

Browse files
Files changed (1) hide show
  1. app.py +107 -37
app.py CHANGED
@@ -84,58 +84,99 @@ class MCPServerDemo:
84
 
85
  server_info = self.servers[server_name]
86
 
87
- # Simulate results based on server and tool
88
  if server_name == "Microsoft Learn Docs" and tool_name == "microsoft_docs_search":
89
- return f"""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  ## πŸ” **Microsoft Learn Docs Search**
91
 
92
  **Query:** `{query}`
93
 
94
- ### πŸ“š **Simulated Results:**
95
-
96
- #### 1. ASP.NET Core Documentation
97
- - **URL:** [https://learn.microsoft.com/aspnet/core/](https://learn.microsoft.com/aspnet/core/)
98
- - **Description:** Comprehensive guide for ASP.NET Core development
99
- - **Relevance:** ⭐⭐⭐⭐⭐
100
-
101
- #### 2. Azure Documentation
102
- - **URL:** [https://learn.microsoft.com/azure/](https://learn.microsoft.com/azure/)
103
- - **Description:** Official Azure documentation and tutorials
104
- - **Relevance:** ⭐⭐⭐⭐
105
 
106
- #### 3. C# Programming Guide
107
- - **URL:** [https://learn.microsoft.com/dotnet/csharp/](https://learn.microsoft.com/dotnet/csharp/)
108
- - **Description:** Complete C# language reference and examples
109
- - **Relevance:** ⭐⭐⭐⭐⭐
 
 
110
 
111
- ### βœ… **Real Features:**
 
 
112
  - πŸ” Semantic search across all Microsoft Learn content
113
  - πŸ”„ Real-time access to latest documentation
114
  - πŸ”— Contextual results with source links
115
  - πŸ“Š Up to 10 high-quality content chunks returned
116
  """
 
117
 
118
  elif server_name == "Azure MCP":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  return f"""
120
  ## ☁️ **Azure MCP Server**
121
 
122
  **Action:** `{tool_name}`
123
  **Query:** `{query}`
124
 
125
- ### πŸ”§ **Simulated Results:**
126
 
127
  | Resource Type | Count | Status |
128
  |---------------|-------|--------|
129
  | Resource Groups | 5 | βœ… Active |
130
- | Storage Accounts | 12 | βœ… Running |
131
- | Virtual Machines | 3 | βœ… Running |
132
  | App Services | 8 | βœ… Deployed |
133
 
134
  ### πŸ“Š **Resource Health:**
135
- - 🟒 **Healthy:** 28 resources
136
  - 🟑 **Warning:** 2 resources
137
  - πŸ”΄ **Critical:** 0 resources
138
 
 
 
139
  ### βœ… **Real Features:**
140
  - πŸ› οΈ **15+ Azure service connectors**
141
  - πŸ“Š **Azure Monitor log analysis with KQL**
@@ -145,29 +186,55 @@ class MCPServerDemo:
145
  """
146
 
147
  elif server_name == "GitHub MCP":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  return f"""
149
  ## πŸ™ **GitHub MCP Server**
150
 
151
  **Action:** `{tool_name}`
152
  **Query:** `{query}`
153
 
154
- ### πŸ“Š **Simulated Results:**
155
 
156
  #### Repository Statistics
157
  ```json
158
- {
159
- "repositories_found": 25,
160
- "open_issues": 12,
161
- "pull_requests": 8,
162
- "recent_commits": 45,
163
- "contributors": 15
164
- }
165
  ```
166
 
167
  #### Top Repositories
168
- 1. **microsoft/vscode** - ⭐ 162k stars
169
- 2. **microsoft/TypeScript** - ⭐ 100k stars
170
- 3. **microsoft/PowerToys** - ⭐ 110k stars
171
 
172
  ### βœ… **Real Features:**
173
  - πŸ“ **Create and manage GitHub issues**
@@ -184,11 +251,11 @@ class MCPServerDemo:
184
  **Tool:** `{tool_name}`
185
  **Query:** `{query}`
186
 
187
- ### πŸ“‹ **Simulation Results:**
188
 
189
  > **{server_info['description']}**
190
 
191
- This is a **demo simulation**. In production, this server would:
192
 
193
  ### βœ… **Capabilities:**
194
  - πŸ”— Connect directly to the service
@@ -479,9 +546,12 @@ def create_demo_interface():
479
  outputs=[output_text]
480
  )
481
 
482
- # Load initial result
 
 
 
483
  demo.load(
484
- fn=lambda: demo_instance.simulate_mcp_call("Microsoft Learn Docs", "microsoft_docs_search", "ASP.NET Core authentication"),
485
  outputs=[output_text]
486
  )
487
 
 
84
 
85
  server_info = self.servers[server_name]
86
 
87
+ # Simulate results based on server and tool with actual query
88
  if server_name == "Microsoft Learn Docs" and tool_name == "microsoft_docs_search":
89
+ # Generate different results based on query keywords
90
+ results = []
91
+ query_lower = query.lower()
92
+
93
+ if "auth" in query_lower or "security" in query_lower:
94
+ results = [
95
+ ("ASP.NET Core Authentication", "https://learn.microsoft.com/aspnet/core/security/authentication/", "Complete guide to authentication in ASP.NET Core"),
96
+ ("Azure Active Directory", "https://learn.microsoft.com/azure/active-directory/", "Enterprise identity and access management"),
97
+ ("Identity Framework", "https://learn.microsoft.com/aspnet/core/security/authentication/identity", "ASP.NET Core Identity framework documentation")
98
+ ]
99
+ elif "azure" in query_lower:
100
+ results = [
101
+ ("Azure Documentation", "https://learn.microsoft.com/azure/", "Official Azure documentation and tutorials"),
102
+ ("Azure Functions", "https://learn.microsoft.com/azure/azure-functions/", "Serverless compute service documentation"),
103
+ ("Azure Storage", "https://learn.microsoft.com/azure/storage/", "Cloud storage solutions and best practices")
104
+ ]
105
+ elif "c#" in query_lower or "csharp" in query_lower:
106
+ results = [
107
+ ("C# Programming Guide", "https://learn.microsoft.com/dotnet/csharp/", "Complete C# language reference and examples"),
108
+ (".NET Documentation", "https://learn.microsoft.com/dotnet/", "Official .NET platform documentation"),
109
+ ("C# Language Features", "https://learn.microsoft.com/dotnet/csharp/whats-new/", "Latest C# features and improvements")
110
+ ]
111
+ else:
112
+ results = [
113
+ ("ASP.NET Core Documentation", "https://learn.microsoft.com/aspnet/core/", "Comprehensive guide for ASP.NET Core development"),
114
+ ("Azure Documentation", "https://learn.microsoft.com/azure/", "Official Azure documentation and tutorials"),
115
+ ("C# Programming Guide", "https://learn.microsoft.com/dotnet/csharp/", "Complete C# language reference and examples")
116
+ ]
117
+
118
+ result_md = f"""
119
  ## πŸ” **Microsoft Learn Docs Search**
120
 
121
  **Query:** `{query}`
122
 
123
+ ### πŸ“š **Search Results for "{query}":**
 
 
 
 
 
 
 
 
 
 
124
 
125
+ """
126
+ for i, (title, url, desc) in enumerate(results, 1):
127
+ result_md += f"""#### {i}. {title}
128
+ - **URL:** [{url}]({url})
129
+ - **Description:** {desc}
130
+ - **Relevance:** {'⭐' * (6-i)}
131
 
132
+ """
133
+
134
+ result_md += """### βœ… **Real Features:**
135
  - πŸ” Semantic search across all Microsoft Learn content
136
  - πŸ”„ Real-time access to latest documentation
137
  - πŸ”— Contextual results with source links
138
  - πŸ“Š Up to 10 high-quality content chunks returned
139
  """
140
+ return result_md
141
 
142
  elif server_name == "Azure MCP":
143
+ # Generate different results based on query
144
+ query_lower = query.lower()
145
+ if "vm" in query_lower or "virtual" in query_lower:
146
+ resource_focus = "Virtual Machines"
147
+ vm_count = 8
148
+ storage_count = 15
149
+ elif "storage" in query_lower:
150
+ resource_focus = "Storage Accounts"
151
+ vm_count = 3
152
+ storage_count = 25
153
+ else:
154
+ resource_focus = "All Resources"
155
+ vm_count = 5
156
+ storage_count = 12
157
+
158
  return f"""
159
  ## ☁️ **Azure MCP Server**
160
 
161
  **Action:** `{tool_name}`
162
  **Query:** `{query}`
163
 
164
+ ### πŸ”§ **Results for "{query}":**
165
 
166
  | Resource Type | Count | Status |
167
  |---------------|-------|--------|
168
  | Resource Groups | 5 | βœ… Active |
169
+ | Storage Accounts | {storage_count} | βœ… Running |
170
+ | Virtual Machines | {vm_count} | βœ… Running |
171
  | App Services | 8 | βœ… Deployed |
172
 
173
  ### πŸ“Š **Resource Health:**
174
+ - 🟒 **Healthy:** {28 + vm_count} resources
175
  - 🟑 **Warning:** 2 resources
176
  - πŸ”΄ **Critical:** 0 resources
177
 
178
+ **Focus Area:** {resource_focus}
179
+
180
  ### βœ… **Real Features:**
181
  - πŸ› οΈ **15+ Azure service connectors**
182
  - πŸ“Š **Azure Monitor log analysis with KQL**
 
186
  """
187
 
188
  elif server_name == "GitHub MCP":
189
+ # Generate different results based on query
190
+ query_lower = query.lower()
191
+ if "microsoft" in query_lower:
192
+ repo_count = 50
193
+ top_repos = [
194
+ ("microsoft/vscode", "162k", "Visual Studio Code editor"),
195
+ ("microsoft/TypeScript", "100k", "TypeScript language"),
196
+ ("microsoft/PowerToys", "110k", "Windows system utilities")
197
+ ]
198
+ elif "python" in query_lower:
199
+ repo_count = 35
200
+ top_repos = [
201
+ ("python/cpython", "62k", "Python programming language"),
202
+ ("psf/requests", "52k", "HTTP library for Python"),
203
+ ("pallets/flask", "67k", "Micro web framework")
204
+ ]
205
+ else:
206
+ repo_count = 25
207
+ top_repos = [
208
+ ("facebook/react", "228k", "JavaScript library for UIs"),
209
+ ("vuejs/vue", "207k", "Progressive JavaScript framework"),
210
+ ("angular/angular", "96k", "Platform for mobile and desktop")
211
+ ]
212
+
213
+ repo_list = ""
214
+ for i, (repo, stars, desc) in enumerate(top_repos, 1):
215
+ repo_list += f"{i}. **{repo}** - ⭐ {stars} stars\n - {desc}\n\n"
216
+
217
  return f"""
218
  ## πŸ™ **GitHub MCP Server**
219
 
220
  **Action:** `{tool_name}`
221
  **Query:** `{query}`
222
 
223
+ ### πŸ“Š **Search Results for "{query}":**
224
 
225
  #### Repository Statistics
226
  ```json
227
+ {{
228
+ "repositories_found": {repo_count},
229
+ "open_issues": {repo_count // 2},
230
+ "pull_requests": {repo_count // 3},
231
+ "recent_commits": {repo_count * 2},
232
+ "contributors": {repo_count // 2}
233
+ }}
234
  ```
235
 
236
  #### Top Repositories
237
+ {repo_list}
 
 
238
 
239
  ### βœ… **Real Features:**
240
  - πŸ“ **Create and manage GitHub issues**
 
251
  **Tool:** `{tool_name}`
252
  **Query:** `{query}`
253
 
254
+ ### πŸ“‹ **Results for "{query}":**
255
 
256
  > **{server_info['description']}**
257
 
258
+ This is a **demo simulation** for your query: **"{query}"**
259
 
260
  ### βœ… **Capabilities:**
261
  - πŸ”— Connect directly to the service
 
546
  outputs=[output_text]
547
  )
548
 
549
+ # Load initial result with dynamic query
550
+ def load_initial_result():
551
+ return demo_instance.simulate_mcp_call("Microsoft Learn Docs", "microsoft_docs_search", "ASP.NET Core authentication")
552
+
553
  demo.load(
554
+ fn=load_initial_result,
555
  outputs=[output_text]
556
  )
557