Spaces:
Sleeping
Sleeping
Commit
Β·
ed036f6
1
Parent(s):
c4352b7
Fix: Query input now properly affects search results - dynamic content based on user input
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
## π **Microsoft Learn Docs Search**
|
| 91 |
|
| 92 |
**Query:** `{query}`
|
| 93 |
|
| 94 |
-
### π **
|
| 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 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
- **
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
|
|
|
|
|
|
| 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 |
-
### π§ **
|
| 126 |
|
| 127 |
| Resource Type | Count | Status |
|
| 128 |
|---------------|-------|--------|
|
| 129 |
| Resource Groups | 5 | β
Active |
|
| 130 |
-
| Storage Accounts |
|
| 131 |
-
| Virtual Machines |
|
| 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 |
-
### π **
|
| 155 |
|
| 156 |
#### Repository Statistics
|
| 157 |
```json
|
| 158 |
-
{
|
| 159 |
-
"repositories_found":
|
| 160 |
-
"open_issues":
|
| 161 |
-
"pull_requests":
|
| 162 |
-
"recent_commits":
|
| 163 |
-
"contributors":
|
| 164 |
-
}
|
| 165 |
```
|
| 166 |
|
| 167 |
#### Top Repositories
|
| 168 |
-
|
| 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 |
-
### π **
|
| 188 |
|
| 189 |
> **{server_info['description']}**
|
| 190 |
|
| 191 |
-
This is a **demo simulation
|
| 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=
|
| 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 |
|