Spaces:
Sleeping
Sleeping
MCP Demo
commited on
Commit
·
c4352b7
1
Parent(s):
dc0efab
Update: English language, dark theme optimization, improved markdown display
Browse files- app.py +311 -110
- requirements.txt +1 -0
app.py
CHANGED
@@ -6,12 +6,13 @@ import httpx
|
|
6 |
from openai import OpenAI
|
7 |
from typing import List, Dict, Any
|
8 |
import logging
|
|
|
9 |
|
10 |
-
#
|
11 |
logging.basicConfig(level=logging.INFO)
|
12 |
logger = logging.getLogger(__name__)
|
13 |
|
14 |
-
#
|
15 |
client = OpenAI(
|
16 |
api_key=os.getenv("OPENAI_API_KEY"),
|
17 |
base_url=os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
|
@@ -22,37 +23,37 @@ class MCPServerDemo:
|
|
22 |
self.servers = {
|
23 |
"Microsoft Learn Docs": {
|
24 |
"url": "https://learn.microsoft.com/api/mcp",
|
25 |
-
"description": "
|
26 |
"tools": ["microsoft_docs_search"]
|
27 |
},
|
28 |
"Azure MCP": {
|
29 |
-
"description": "
|
30 |
"tools": ["azure_resource_list", "azure_monitor_query"]
|
31 |
},
|
32 |
"GitHub MCP": {
|
33 |
-
"description": "
|
34 |
"tools": ["github_search_repos", "github_create_issue"]
|
35 |
},
|
36 |
"Azure DevOps MCP": {
|
37 |
-
"description": "
|
38 |
"tools": ["devops_create_workitem", "devops_query_workitems"]
|
39 |
},
|
40 |
"MarkItDown MCP": {
|
41 |
-
"description": "
|
42 |
"tools": ["convert_to_markdown"]
|
43 |
},
|
44 |
"SQL Server MCP": {
|
45 |
-
"description": "
|
46 |
"tools": ["sql_query", "sql_schema"]
|
47 |
},
|
48 |
"Playwright MCP": {
|
49 |
-
"description": "Web automation
|
50 |
"tools": ["playwright_navigate", "playwright_screenshot"]
|
51 |
}
|
52 |
}
|
53 |
|
54 |
async def search_microsoft_docs(self, query: str) -> str:
|
55 |
-
"""
|
56 |
try:
|
57 |
async with httpx.AsyncClient() as client:
|
58 |
response = await client.post(
|
@@ -69,104 +70,151 @@ class MCPServerDemo:
|
|
69 |
|
70 |
if response.status_code == 200:
|
71 |
result = response.json()
|
72 |
-
return f"
|
73 |
else:
|
74 |
-
return f"
|
75 |
except Exception as e:
|
76 |
logger.error(f"Error searching Microsoft docs: {e}")
|
77 |
-
return f"
|
78 |
|
79 |
def simulate_mcp_call(self, server_name: str, tool_name: str, query: str) -> str:
|
80 |
-
"""
|
81 |
if server_name not in self.servers:
|
82 |
-
return "Server
|
83 |
|
84 |
server_info = self.servers[server_name]
|
85 |
|
86 |
-
#
|
87 |
if server_name == "Microsoft Learn Docs" and tool_name == "microsoft_docs_search":
|
88 |
return f"""
|
89 |
-
🔍 **
|
90 |
-
Query: {query}
|
91 |
|
92 |
-
|
93 |
-
1. **ASP.NET Core Documentation**
|
94 |
-
- URL: https://learn.microsoft.com/aspnet/core/
|
95 |
-
- Mô tả: Comprehensive guide for ASP.NET Core development
|
96 |
-
|
97 |
-
2. **Azure Documentation**
|
98 |
-
- URL: https://learn.microsoft.com/azure/
|
99 |
-
- Mô tả: Official Azure documentation and tutorials
|
100 |
-
|
101 |
-
3. **C# Programming Guide**
|
102 |
-
- URL: https://learn.microsoft.com/dotnet/csharp/
|
103 |
-
- Mô tả: Complete C# language reference and examples
|
104 |
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
"""
|
110 |
|
111 |
elif server_name == "Azure MCP":
|
112 |
return f"""
|
113 |
-
☁️ **Azure MCP Server**
|
114 |
-
|
115 |
-
|
|
|
116 |
|
117 |
-
🔧 **
|
118 |
-
- Resource Groups: 5 active
|
119 |
-
- Storage Accounts: 12 total
|
120 |
-
- Virtual Machines: 3 running
|
121 |
-
- App Services: 8 deployed
|
122 |
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
"""
|
129 |
|
130 |
elif server_name == "GitHub MCP":
|
131 |
return f"""
|
132 |
-
🐙 **GitHub MCP Server**
|
133 |
-
|
134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
|
136 |
-
|
137 |
-
-
|
138 |
-
-
|
139 |
-
-
|
140 |
-
- Recent commits: 45
|
141 |
|
142 |
-
✅ **
|
143 |
-
-
|
144 |
-
- Search repositories
|
145 |
-
- Manage pull requests
|
146 |
-
- Repository analytics
|
|
|
147 |
"""
|
148 |
|
149 |
else:
|
150 |
return f"""
|
151 |
-
🛠️ **{server_name}**
|
152 |
-
Tool: {tool_name}
|
153 |
-
Query: {query}
|
154 |
|
155 |
-
|
156 |
-
{
|
157 |
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
"""
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
def create_demo_interface():
|
165 |
demo_instance = MCPServerDemo()
|
166 |
|
167 |
def process_mcp_request(server_name: str, tool_name: str, query: str) -> str:
|
168 |
if not query.strip():
|
169 |
-
return "
|
170 |
|
171 |
return demo_instance.simulate_mcp_call(server_name, tool_name, query)
|
172 |
|
@@ -176,88 +224,241 @@ def create_demo_interface():
|
|
176 |
return gr.Dropdown(choices=tools, value=tools[0] if tools else None)
|
177 |
return gr.Dropdown(choices=[], value=None)
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
with gr.Blocks(
|
180 |
title="Microsoft MCP Servers Demo",
|
181 |
-
theme=gr.themes.
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
margin: 10px 0;
|
192 |
-
}
|
193 |
-
"""
|
194 |
) as demo:
|
195 |
|
196 |
gr.HTML("""
|
197 |
-
<div class="server-
|
198 |
<h1>🚀 Microsoft MCP Servers Demo</h1>
|
199 |
-
<p>
|
200 |
-
<p><strong>Model Context Protocol (MCP)</strong>
|
201 |
</div>
|
202 |
""")
|
203 |
|
204 |
with gr.Row():
|
205 |
with gr.Column(scale=1):
|
206 |
-
gr.HTML("<h3>🛠️
|
207 |
server_dropdown = gr.Dropdown(
|
208 |
choices=list(demo_instance.servers.keys()),
|
209 |
value="Microsoft Learn Docs",
|
210 |
label="MCP Server",
|
211 |
-
info="
|
|
|
212 |
)
|
213 |
|
214 |
tool_dropdown = gr.Dropdown(
|
215 |
choices=demo_instance.servers["Microsoft Learn Docs"]["tools"],
|
216 |
value="microsoft_docs_search",
|
217 |
label="Tool/Function",
|
218 |
-
info="
|
|
|
219 |
)
|
220 |
|
221 |
query_input = gr.Textbox(
|
222 |
label="Query/Input",
|
223 |
-
placeholder="
|
224 |
lines=3,
|
225 |
-
value="ASP.NET Core authentication"
|
|
|
226 |
)
|
227 |
|
228 |
-
submit_btn = gr.Button(
|
|
|
|
|
|
|
|
|
229 |
|
230 |
with gr.Column(scale=2):
|
231 |
-
gr.HTML("<h3>📊
|
232 |
-
output_text = gr.
|
233 |
label="MCP Server Response",
|
234 |
-
|
235 |
-
|
236 |
-
show_copy_button=True
|
|
|
|
|
237 |
)
|
238 |
|
239 |
-
# Server info section
|
240 |
with gr.Row():
|
241 |
gr.HTML("""
|
242 |
-
<div
|
243 |
-
<h3>📚
|
244 |
-
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(
|
245 |
-
<div
|
246 |
<h4>📚 Microsoft Learn Docs</h4>
|
247 |
-
<p>
|
|
|
248 |
</div>
|
249 |
-
<div
|
250 |
<h4>☁️ Azure MCP</h4>
|
251 |
-
<p>
|
|
|
252 |
</div>
|
253 |
-
<div
|
254 |
<h4>🐙 GitHub MCP</h4>
|
255 |
-
<p>
|
|
|
256 |
</div>
|
257 |
-
<div
|
258 |
<h4>🔄 Azure DevOps</h4>
|
259 |
-
<p>
|
|
|
260 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
</div>
|
262 |
</div>
|
263 |
""")
|
@@ -290,7 +491,7 @@ if __name__ == "__main__":
|
|
290 |
demo = create_demo_interface()
|
291 |
demo.launch(
|
292 |
server_name="0.0.0.0",
|
293 |
-
server_port=7860,
|
294 |
share=False,
|
295 |
show_error=True
|
296 |
)
|
|
|
6 |
from openai import OpenAI
|
7 |
from typing import List, Dict, Any
|
8 |
import logging
|
9 |
+
import markdown
|
10 |
|
11 |
+
# Configure logging
|
12 |
logging.basicConfig(level=logging.INFO)
|
13 |
logger = logging.getLogger(__name__)
|
14 |
|
15 |
+
# Initialize OpenAI client
|
16 |
client = OpenAI(
|
17 |
api_key=os.getenv("OPENAI_API_KEY"),
|
18 |
base_url=os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
|
|
|
23 |
self.servers = {
|
24 |
"Microsoft Learn Docs": {
|
25 |
"url": "https://learn.microsoft.com/api/mcp",
|
26 |
+
"description": "Search official Microsoft Learn documentation",
|
27 |
"tools": ["microsoft_docs_search"]
|
28 |
},
|
29 |
"Azure MCP": {
|
30 |
+
"description": "Manage Azure resources and services",
|
31 |
"tools": ["azure_resource_list", "azure_monitor_query"]
|
32 |
},
|
33 |
"GitHub MCP": {
|
34 |
+
"description": "Interact with GitHub repositories",
|
35 |
"tools": ["github_search_repos", "github_create_issue"]
|
36 |
},
|
37 |
"Azure DevOps MCP": {
|
38 |
+
"description": "Manage Azure DevOps work items",
|
39 |
"tools": ["devops_create_workitem", "devops_query_workitems"]
|
40 |
},
|
41 |
"MarkItDown MCP": {
|
42 |
+
"description": "Convert documents to Markdown format",
|
43 |
"tools": ["convert_to_markdown"]
|
44 |
},
|
45 |
"SQL Server MCP": {
|
46 |
+
"description": "Query SQL Server databases",
|
47 |
"tools": ["sql_query", "sql_schema"]
|
48 |
},
|
49 |
"Playwright MCP": {
|
50 |
+
"description": "Web automation and testing",
|
51 |
"tools": ["playwright_navigate", "playwright_screenshot"]
|
52 |
}
|
53 |
}
|
54 |
|
55 |
async def search_microsoft_docs(self, query: str) -> str:
|
56 |
+
"""Search Microsoft Learn documentation"""
|
57 |
try:
|
58 |
async with httpx.AsyncClient() as client:
|
59 |
response = await client.post(
|
|
|
70 |
|
71 |
if response.status_code == 200:
|
72 |
result = response.json()
|
73 |
+
return f"Search results for '{query}':\n\n{json.dumps(result, indent=2, ensure_ascii=False)}"
|
74 |
else:
|
75 |
+
return f"Search error: {response.status_code}"
|
76 |
except Exception as e:
|
77 |
logger.error(f"Error searching Microsoft docs: {e}")
|
78 |
+
return f"Error: {str(e)}"
|
79 |
|
80 |
def simulate_mcp_call(self, server_name: str, tool_name: str, query: str) -> str:
|
81 |
+
"""Simulate MCP server call with markdown formatting"""
|
82 |
if server_name not in self.servers:
|
83 |
+
return "❌ **Server not found**"
|
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**
|
142 |
+
- 🗄️ **Database connectivity** (PostgreSQL, SQL Server)
|
143 |
+
- 🌐 **Cosmos DB integration**
|
144 |
+
- 📈 **Resource management and monitoring**
|
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**
|
174 |
+
- 🔍 **Search repositories and code**
|
175 |
+
- 🔄 **Manage pull requests**
|
176 |
+
- 📊 **Repository analytics and insights**
|
177 |
+
- 👥 **Team collaboration tools**
|
178 |
"""
|
179 |
|
180 |
else:
|
181 |
return f"""
|
182 |
+
## 🛠️ **{server_name}**
|
|
|
|
|
183 |
|
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
|
195 |
+
- ⚡ Perform real-time operations
|
196 |
+
- 📊 Return accurate data from APIs
|
197 |
+
- 🔄 Execute live commands and queries
|
198 |
+
|
199 |
+
### 🚀 **Integration Benefits:**
|
200 |
+
- **Stay in flow** - No context switching
|
201 |
+
- **AI-powered** - Natural language queries
|
202 |
+
- **Chainable** - Combine multiple servers
|
203 |
+
- **Extensible** - Build custom integrations
|
204 |
"""
|
205 |
|
206 |
+
def format_markdown_response(self, content: str) -> str:
|
207 |
+
"""Format response with proper markdown rendering"""
|
208 |
+
# Convert markdown to HTML for better rendering
|
209 |
+
html_content = markdown.markdown(content, extensions=['tables', 'fenced_code'])
|
210 |
+
return html_content
|
211 |
+
|
212 |
def create_demo_interface():
|
213 |
demo_instance = MCPServerDemo()
|
214 |
|
215 |
def process_mcp_request(server_name: str, tool_name: str, query: str) -> str:
|
216 |
if not query.strip():
|
217 |
+
return "❌ **Please enter a query to test the MCP server**"
|
218 |
|
219 |
return demo_instance.simulate_mcp_call(server_name, tool_name, query)
|
220 |
|
|
|
224 |
return gr.Dropdown(choices=tools, value=tools[0] if tools else None)
|
225 |
return gr.Dropdown(choices=[], value=None)
|
226 |
|
227 |
+
# Dark theme optimized CSS
|
228 |
+
dark_theme_css = """
|
229 |
+
.gradio-container {
|
230 |
+
max-width: 1400px !important;
|
231 |
+
background: #0d1117 !important;
|
232 |
+
}
|
233 |
+
|
234 |
+
.server-header {
|
235 |
+
background: linear-gradient(135deg, #1f6feb 0%, #8b5cf6 100%);
|
236 |
+
color: white;
|
237 |
+
padding: 24px;
|
238 |
+
border-radius: 12px;
|
239 |
+
margin: 16px 0;
|
240 |
+
box-shadow: 0 8px 32px rgba(31, 111, 235, 0.2);
|
241 |
+
}
|
242 |
+
|
243 |
+
.server-info-grid {
|
244 |
+
background: #161b22;
|
245 |
+
padding: 24px;
|
246 |
+
border-radius: 12px;
|
247 |
+
margin: 20px 0;
|
248 |
+
border: 1px solid #30363d;
|
249 |
+
}
|
250 |
+
|
251 |
+
.server-card {
|
252 |
+
background: #21262d;
|
253 |
+
padding: 20px;
|
254 |
+
border-radius: 10px;
|
255 |
+
border-left: 4px solid #1f6feb;
|
256 |
+
margin: 12px 0;
|
257 |
+
transition: all 0.3s ease;
|
258 |
+
}
|
259 |
+
|
260 |
+
.server-card:hover {
|
261 |
+
background: #262c36;
|
262 |
+
transform: translateY(-2px);
|
263 |
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
264 |
+
}
|
265 |
+
|
266 |
+
.markdown-content {
|
267 |
+
background: #0d1117;
|
268 |
+
color: #e6edf3;
|
269 |
+
font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
|
270 |
+
}
|
271 |
+
|
272 |
+
.markdown-content h2 {
|
273 |
+
color: #1f6feb;
|
274 |
+
border-bottom: 2px solid #21262d;
|
275 |
+
padding-bottom: 8px;
|
276 |
+
}
|
277 |
+
|
278 |
+
.markdown-content h3 {
|
279 |
+
color: #7c3aed;
|
280 |
+
}
|
281 |
+
|
282 |
+
.markdown-content code {
|
283 |
+
background: #161b22;
|
284 |
+
color: #79c0ff;
|
285 |
+
padding: 2px 6px;
|
286 |
+
border-radius: 4px;
|
287 |
+
border: 1px solid #30363d;
|
288 |
+
}
|
289 |
+
|
290 |
+
.markdown-content pre {
|
291 |
+
background: #161b22 !important;
|
292 |
+
border: 1px solid #30363d;
|
293 |
+
border-radius: 8px;
|
294 |
+
padding: 16px;
|
295 |
+
}
|
296 |
+
|
297 |
+
.markdown-content table {
|
298 |
+
border-collapse: collapse;
|
299 |
+
width: 100%;
|
300 |
+
margin: 16px 0;
|
301 |
+
}
|
302 |
+
|
303 |
+
.markdown-content th,
|
304 |
+
.markdown-content td {
|
305 |
+
border: 1px solid #30363d;
|
306 |
+
padding: 12px;
|
307 |
+
text-align: left;
|
308 |
+
}
|
309 |
+
|
310 |
+
.markdown-content th {
|
311 |
+
background: #21262d;
|
312 |
+
color: #1f6feb;
|
313 |
+
font-weight: 600;
|
314 |
+
}
|
315 |
+
|
316 |
+
.markdown-content blockquote {
|
317 |
+
border-left: 4px solid #1f6feb;
|
318 |
+
background: #161b22;
|
319 |
+
padding: 16px;
|
320 |
+
margin: 16px 0;
|
321 |
+
border-radius: 0 8px 8px 0;
|
322 |
+
}
|
323 |
+
|
324 |
+
/* Gradio component styling for dark theme */
|
325 |
+
.gr-textbox, .gr-dropdown {
|
326 |
+
background: #21262d !important;
|
327 |
+
border: 1px solid #30363d !important;
|
328 |
+
color: #e6edf3 !important;
|
329 |
+
}
|
330 |
+
|
331 |
+
.gr-button {
|
332 |
+
background: linear-gradient(135deg, #1f6feb 0%, #8b5cf6 100%) !important;
|
333 |
+
border: none !important;
|
334 |
+
color: white !important;
|
335 |
+
font-weight: 600 !important;
|
336 |
+
transition: all 0.3s ease !important;
|
337 |
+
}
|
338 |
+
|
339 |
+
.gr-button:hover {
|
340 |
+
transform: translateY(-2px) !important;
|
341 |
+
box-shadow: 0 4px 16px rgba(31, 111, 235, 0.4) !important;
|
342 |
+
}
|
343 |
+
"""
|
344 |
+
|
345 |
with gr.Blocks(
|
346 |
title="Microsoft MCP Servers Demo",
|
347 |
+
theme=gr.themes.Base().set(
|
348 |
+
body_background_fill="#0d1117",
|
349 |
+
body_text_color="#e6edf3",
|
350 |
+
background_fill_primary="#161b22",
|
351 |
+
background_fill_secondary="#21262d",
|
352 |
+
border_color_primary="#30363d",
|
353 |
+
color_accent="#1f6feb",
|
354 |
+
color_accent_soft="#1f6feb20"
|
355 |
+
),
|
356 |
+
css=dark_theme_css
|
|
|
|
|
|
|
357 |
) as demo:
|
358 |
|
359 |
gr.HTML("""
|
360 |
+
<div class="server-header">
|
361 |
<h1>🚀 Microsoft MCP Servers Demo</h1>
|
362 |
+
<p>Explore 10 Microsoft MCP Servers to accelerate your development workflow!</p>
|
363 |
+
<p><strong>Model Context Protocol (MCP)</strong> enables AI assistants to connect with external tools and data sources.</p>
|
364 |
</div>
|
365 |
""")
|
366 |
|
367 |
with gr.Row():
|
368 |
with gr.Column(scale=1):
|
369 |
+
gr.HTML("<h3>🛠️ Select MCP Server</h3>")
|
370 |
server_dropdown = gr.Dropdown(
|
371 |
choices=list(demo_instance.servers.keys()),
|
372 |
value="Microsoft Learn Docs",
|
373 |
label="MCP Server",
|
374 |
+
info="Choose a server to test",
|
375 |
+
elem_classes=["gr-dropdown"]
|
376 |
)
|
377 |
|
378 |
tool_dropdown = gr.Dropdown(
|
379 |
choices=demo_instance.servers["Microsoft Learn Docs"]["tools"],
|
380 |
value="microsoft_docs_search",
|
381 |
label="Tool/Function",
|
382 |
+
info="Select function to call",
|
383 |
+
elem_classes=["gr-dropdown"]
|
384 |
)
|
385 |
|
386 |
query_input = gr.Textbox(
|
387 |
label="Query/Input",
|
388 |
+
placeholder="Enter your query to test the MCP server...",
|
389 |
lines=3,
|
390 |
+
value="ASP.NET Core authentication",
|
391 |
+
elem_classes=["gr-textbox"]
|
392 |
)
|
393 |
|
394 |
+
submit_btn = gr.Button(
|
395 |
+
"🔍 Test MCP Server",
|
396 |
+
variant="primary",
|
397 |
+
elem_classes=["gr-button"]
|
398 |
+
)
|
399 |
|
400 |
with gr.Column(scale=2):
|
401 |
+
gr.HTML("<h3>📊 Results</h3>")
|
402 |
+
output_text = gr.Markdown(
|
403 |
label="MCP Server Response",
|
404 |
+
value="",
|
405 |
+
elem_classes=["markdown-content"],
|
406 |
+
show_copy_button=True,
|
407 |
+
line_breaks=True,
|
408 |
+
sanitize_html=False
|
409 |
)
|
410 |
|
411 |
+
# Server info section with improved styling
|
412 |
with gr.Row():
|
413 |
gr.HTML("""
|
414 |
+
<div class="server-info-grid">
|
415 |
+
<h3>📚 Microsoft MCP Servers Overview</h3>
|
416 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 20px;">
|
417 |
+
<div class="server-card">
|
418 |
<h4>📚 Microsoft Learn Docs</h4>
|
419 |
+
<p>Semantic search across official Microsoft documentation</p>
|
420 |
+
<code>microsoft_docs_search</code>
|
421 |
</div>
|
422 |
+
<div class="server-card">
|
423 |
<h4>☁️ Azure MCP</h4>
|
424 |
+
<p>Manage 15+ Azure services and resources</p>
|
425 |
+
<code>azure_resource_list, azure_monitor_query</code>
|
426 |
</div>
|
427 |
+
<div class="server-card">
|
428 |
<h4>🐙 GitHub MCP</h4>
|
429 |
+
<p>Interact with GitHub repos, issues, PRs</p>
|
430 |
+
<code>github_search_repos, github_create_issue</code>
|
431 |
</div>
|
432 |
+
<div class="server-card">
|
433 |
<h4>🔄 Azure DevOps</h4>
|
434 |
+
<p>Manage work items, builds, releases</p>
|
435 |
+
<code>devops_create_workitem, devops_query_workitems</code>
|
436 |
</div>
|
437 |
+
<div class="server-card">
|
438 |
+
<h4>📝 MarkItDown</h4>
|
439 |
+
<p>Convert documents to Markdown format</p>
|
440 |
+
<code>convert_to_markdown</code>
|
441 |
+
</div>
|
442 |
+
<div class="server-card">
|
443 |
+
<h4>🗃️ SQL Server</h4>
|
444 |
+
<p>Query SQL Server databases</p>
|
445 |
+
<code>sql_query, sql_schema</code>
|
446 |
+
</div>
|
447 |
+
<div class="server-card">
|
448 |
+
<h4>🎭 Playwright</h4>
|
449 |
+
<p>Web automation and testing</p>
|
450 |
+
<code>playwright_navigate, playwright_screenshot</code>
|
451 |
+
</div>
|
452 |
+
</div>
|
453 |
+
|
454 |
+
<div style="margin-top: 24px; padding: 20px; background: #21262d; border-radius: 10px; border-left: 4px solid #7c3aed;">
|
455 |
+
<h4>🚀 Key Benefits</h4>
|
456 |
+
<ul style="margin: 12px 0; padding-left: 20px;">
|
457 |
+
<li><strong>Stay in flow</strong> - No context switching required</li>
|
458 |
+
<li><strong>AI-powered queries</strong> - Natural language instead of exact syntax</li>
|
459 |
+
<li><strong>Chainable operations</strong> - Combine multiple servers</li>
|
460 |
+
<li><strong>Extensible ecosystem</strong> - Build custom integrations</li>
|
461 |
+
</ul>
|
462 |
</div>
|
463 |
</div>
|
464 |
""")
|
|
|
491 |
demo = create_demo_interface()
|
492 |
demo.launch(
|
493 |
server_name="0.0.0.0",
|
494 |
+
server_port=int(os.getenv("GRADIO_SERVER_PORT", 7860)),
|
495 |
share=False,
|
496 |
show_error=True
|
497 |
)
|
requirements.txt
CHANGED
@@ -6,4 +6,5 @@ mcp==1.0.0
|
|
6 |
httpx==0.27.0
|
7 |
asyncio-mqtt==0.16.2
|
8 |
aiofiles==23.2.1
|
|
|
9 |
|
|
|
6 |
httpx==0.27.0
|
7 |
asyncio-mqtt==0.16.2
|
8 |
aiofiles==23.2.1
|
9 |
+
markdown==3.6
|
10 |
|