Spaces:
Sleeping
Sleeping
MCP Demo
commited on
Commit
·
dc0efab
1
Parent(s):
650d166
Deploy Microsoft MCP Servers Demo
Browse files- .gitignore +49 -0
- README.md +88 -6
- app.py +297 -0
- requirements.txt +9 -0
.gitignore
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Environment variables
|
2 |
+
.env
|
3 |
+
.env.local
|
4 |
+
.env.production
|
5 |
+
|
6 |
+
# Python
|
7 |
+
__pycache__/
|
8 |
+
*.py[cod]
|
9 |
+
*$py.class
|
10 |
+
*.so
|
11 |
+
.Python
|
12 |
+
build/
|
13 |
+
develop-eggs/
|
14 |
+
dist/
|
15 |
+
downloads/
|
16 |
+
eggs/
|
17 |
+
.eggs/
|
18 |
+
lib/
|
19 |
+
lib64/
|
20 |
+
parts/
|
21 |
+
sdist/
|
22 |
+
var/
|
23 |
+
wheels/
|
24 |
+
*.egg-info/
|
25 |
+
.installed.cfg
|
26 |
+
*.egg
|
27 |
+
|
28 |
+
# Virtual environments
|
29 |
+
venv/
|
30 |
+
env/
|
31 |
+
ENV/
|
32 |
+
|
33 |
+
# IDE
|
34 |
+
.vscode/
|
35 |
+
.idea/
|
36 |
+
*.swp
|
37 |
+
*.swo
|
38 |
+
|
39 |
+
# OS
|
40 |
+
.DS_Store
|
41 |
+
Thumbs.db
|
42 |
+
|
43 |
+
# Logs
|
44 |
+
*.log
|
45 |
+
|
46 |
+
# Gradio
|
47 |
+
gradio_cached_examples/
|
48 |
+
flagged/
|
49 |
+
|
README.md
CHANGED
@@ -1,12 +1,94 @@
|
|
1 |
---
|
2 |
-
title: Microsoft
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version:
|
8 |
app_file: app.py
|
9 |
pinned: false
|
|
|
10 |
---
|
11 |
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
title: Microsoft MCP Servers Demo
|
3 |
+
emoji: 🚀
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: purple
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 4.44.0
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
+
license: mit
|
11 |
---
|
12 |
|
13 |
+
# 🚀 Microsoft MCP Servers Demo
|
14 |
+
|
15 |
+
Khám phá 10 Microsoft MCP Servers để tăng tốc development workflow của bạn!
|
16 |
+
|
17 |
+
## 🌟 Tính năng
|
18 |
+
|
19 |
+
Ứng dụng này demo các Microsoft MCP (Model Context Protocol) Servers:
|
20 |
+
|
21 |
+
### 📚 Microsoft Learn Docs MCP Server
|
22 |
+
- Tìm kiếm semantic qua tài liệu Microsoft chính thức
|
23 |
+
- Truy cập real-time đến Microsoft Learn, Azure docs, Microsoft 365 docs
|
24 |
+
- Tool: `microsoft_docs_search`
|
25 |
+
|
26 |
+
### ☁️ Azure MCP Server
|
27 |
+
- Quản lý 15+ Azure services
|
28 |
+
- Resource management, database connectivity
|
29 |
+
- Azure Monitor logs với KQL queries
|
30 |
+
- Cosmos DB integration
|
31 |
+
|
32 |
+
### 🐙 GitHub MCP Server
|
33 |
+
- Tương tác với GitHub repositories
|
34 |
+
- Quản lý issues, pull requests
|
35 |
+
- Search repositories và code
|
36 |
+
|
37 |
+
### 🔄 Azure DevOps MCP Server
|
38 |
+
- Quản lý Azure DevOps work items
|
39 |
+
- Builds và releases management
|
40 |
+
- Project tracking
|
41 |
+
|
42 |
+
### 📝 MarkItDown MCP Server
|
43 |
+
- Chuyển đổi documents sang Markdown format
|
44 |
+
- Hỗ trợ nhiều định dạng file
|
45 |
+
|
46 |
+
### 🗃️ SQL Server MCP Server
|
47 |
+
- Kết nối và truy vấn SQL Server
|
48 |
+
- Database schema exploration
|
49 |
+
- Query execution
|
50 |
+
|
51 |
+
### 🎭 Playwright MCP Server
|
52 |
+
- Web automation và testing
|
53 |
+
- Screenshot capture
|
54 |
+
- Browser navigation
|
55 |
+
|
56 |
+
## 🛠️ Cách sử dụng
|
57 |
+
|
58 |
+
1. **Chọn MCP Server**: Chọn server bạn muốn test
|
59 |
+
2. **Chọn Tool/Function**: Chọn function cụ thể của server
|
60 |
+
3. **Nhập Query**: Nhập query hoặc input cho function
|
61 |
+
4. **Test**: Click "Test MCP Server" để xem kết quả
|
62 |
+
|
63 |
+
## 🔧 Environment Variables
|
64 |
+
|
65 |
+
Để sử dụng đầy đủ tính năng, cần cấu hình các biến môi trường:
|
66 |
+
|
67 |
+
- `OPENAI_API_KEY`: OpenAI API key để sử dụng AI features
|
68 |
+
- `OPENAI_API_BASE`: OpenAI API base URL (optional)
|
69 |
+
|
70 |
+
## 📖 Tài liệu tham khảo
|
71 |
+
|
72 |
+
- [Microsoft MCP Servers Blog Post](https://devblogs.microsoft.com/blog/10-microsoft-mcp-servers-to-accelerate-your-development-workflow)
|
73 |
+
- [Model Context Protocol](https://modelcontextprotocol.io/)
|
74 |
+
- [Microsoft Learn Documentation](https://learn.microsoft.com/)
|
75 |
+
|
76 |
+
## 🚀 Deployment
|
77 |
+
|
78 |
+
Space này được deploy trên Hugging Face Spaces với:
|
79 |
+
- **SDK**: Gradio 4.44.0
|
80 |
+
- **Python**: 3.11+
|
81 |
+
- **Framework**: Gradio + OpenAI
|
82 |
+
|
83 |
+
## 📝 License
|
84 |
+
|
85 |
+
MIT License - Xem file LICENSE để biết thêm chi tiết.
|
86 |
+
|
87 |
+
## 🤝 Đóng góp
|
88 |
+
|
89 |
+
Mọi đóng góp đều được chào đón! Hãy tạo issue hoặc pull request.
|
90 |
+
|
91 |
+
---
|
92 |
+
|
93 |
+
**Lưu ý**: Đây là demo mô phỏng các MCP servers. Để sử dụng thực tế, cần cài đặt và cấu hình các MCP servers tương ứng.
|
94 |
+
|
app.py
ADDED
@@ -0,0 +1,297 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
import asyncio
|
4 |
+
import json
|
5 |
+
import httpx
|
6 |
+
from openai import OpenAI
|
7 |
+
from typing import List, Dict, Any
|
8 |
+
import logging
|
9 |
+
|
10 |
+
# Cấu hình logging
|
11 |
+
logging.basicConfig(level=logging.INFO)
|
12 |
+
logger = logging.getLogger(__name__)
|
13 |
+
|
14 |
+
# Khởi tạo OpenAI client
|
15 |
+
client = OpenAI(
|
16 |
+
api_key=os.getenv("OPENAI_API_KEY"),
|
17 |
+
base_url=os.getenv("OPENAI_API_BASE", "https://api.openai.com/v1")
|
18 |
+
)
|
19 |
+
|
20 |
+
class MCPServerDemo:
|
21 |
+
def __init__(self):
|
22 |
+
self.servers = {
|
23 |
+
"Microsoft Learn Docs": {
|
24 |
+
"url": "https://learn.microsoft.com/api/mcp",
|
25 |
+
"description": "Tìm kiếm tài liệu Microsoft Learn chính thức",
|
26 |
+
"tools": ["microsoft_docs_search"]
|
27 |
+
},
|
28 |
+
"Azure MCP": {
|
29 |
+
"description": "Quản lý tài nguyên Azure",
|
30 |
+
"tools": ["azure_resource_list", "azure_monitor_query"]
|
31 |
+
},
|
32 |
+
"GitHub MCP": {
|
33 |
+
"description": "Tương tác với GitHub repositories",
|
34 |
+
"tools": ["github_search_repos", "github_create_issue"]
|
35 |
+
},
|
36 |
+
"Azure DevOps MCP": {
|
37 |
+
"description": "Quản lý Azure DevOps work items",
|
38 |
+
"tools": ["devops_create_workitem", "devops_query_workitems"]
|
39 |
+
},
|
40 |
+
"MarkItDown MCP": {
|
41 |
+
"description": "Chuyển đổi documents sang Markdown",
|
42 |
+
"tools": ["convert_to_markdown"]
|
43 |
+
},
|
44 |
+
"SQL Server MCP": {
|
45 |
+
"description": "Truy vấn SQL Server database",
|
46 |
+
"tools": ["sql_query", "sql_schema"]
|
47 |
+
},
|
48 |
+
"Playwright MCP": {
|
49 |
+
"description": "Web automation và testing",
|
50 |
+
"tools": ["playwright_navigate", "playwright_screenshot"]
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
async def search_microsoft_docs(self, query: str) -> str:
|
55 |
+
"""Tìm kiếm tài liệu Microsoft Learn"""
|
56 |
+
try:
|
57 |
+
async with httpx.AsyncClient() as client:
|
58 |
+
response = await client.post(
|
59 |
+
"https://learn.microsoft.com/api/mcp",
|
60 |
+
json={
|
61 |
+
"method": "tools/call",
|
62 |
+
"params": {
|
63 |
+
"name": "microsoft_docs_search",
|
64 |
+
"arguments": {"query": query}
|
65 |
+
}
|
66 |
+
},
|
67 |
+
headers={"Content-Type": "application/json"}
|
68 |
+
)
|
69 |
+
|
70 |
+
if response.status_code == 200:
|
71 |
+
result = response.json()
|
72 |
+
return f"Kết quả tìm kiếm cho '{query}':\n\n{json.dumps(result, indent=2, ensure_ascii=False)}"
|
73 |
+
else:
|
74 |
+
return f"Lỗi khi tìm kiếm: {response.status_code}"
|
75 |
+
except Exception as e:
|
76 |
+
logger.error(f"Error searching Microsoft docs: {e}")
|
77 |
+
return f"Lỗi: {str(e)}"
|
78 |
+
|
79 |
+
def simulate_mcp_call(self, server_name: str, tool_name: str, query: str) -> str:
|
80 |
+
"""Mô phỏng gọi MCP server"""
|
81 |
+
if server_name not in self.servers:
|
82 |
+
return "Server không tồn tại"
|
83 |
+
|
84 |
+
server_info = self.servers[server_name]
|
85 |
+
|
86 |
+
# Mô phỏng kết quả dựa trên server và tool
|
87 |
+
if server_name == "Microsoft Learn Docs" and tool_name == "microsoft_docs_search":
|
88 |
+
return f"""
|
89 |
+
🔍 **Tìm kiếm Microsoft Learn Docs**
|
90 |
+
Query: {query}
|
91 |
+
|
92 |
+
📚 **Kết quả mô phỏng:**
|
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 |
+
✅ **Tính năng thực tế:**
|
106 |
+
- Semantic search qua toàn bộ Microsoft Learn
|
107 |
+
- Truy cập real-time đến tài liệu mới nhất
|
108 |
+
- Kết quả có context và source links
|
109 |
+
"""
|
110 |
+
|
111 |
+
elif server_name == "Azure MCP":
|
112 |
+
return f"""
|
113 |
+
☁️ **Azure MCP Server**
|
114 |
+
Action: {tool_name}
|
115 |
+
Query: {query}
|
116 |
+
|
117 |
+
🔧 **Kết quả mô phỏng:**
|
118 |
+
- Resource Groups: 5 active
|
119 |
+
- Storage Accounts: 12 total
|
120 |
+
- Virtual Machines: 3 running
|
121 |
+
- App Services: 8 deployed
|
122 |
+
|
123 |
+
✅ **Tính năng thực tế:**
|
124 |
+
- Quản lý 15+ Azure services
|
125 |
+
- Monitor logs với KQL queries
|
126 |
+
- Database connectivity (PostgreSQL, SQL Server)
|
127 |
+
- Cosmos DB integration
|
128 |
+
"""
|
129 |
+
|
130 |
+
elif server_name == "GitHub MCP":
|
131 |
+
return f"""
|
132 |
+
🐙 **GitHub MCP Server**
|
133 |
+
Action: {tool_name}
|
134 |
+
Query: {query}
|
135 |
+
|
136 |
+
📊 **Kết quả mô phỏng:**
|
137 |
+
- Repositories found: 25
|
138 |
+
- Open Issues: 12
|
139 |
+
- Pull Requests: 8
|
140 |
+
- Recent commits: 45
|
141 |
+
|
142 |
+
✅ **Tính năng thực tế:**
|
143 |
+
- Tạo và quản lý GitHub issues
|
144 |
+
- Search repositories và code
|
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 |
+
📋 **Mô phỏng kết quả:**
|
156 |
+
{server_info['description']}
|
157 |
+
|
158 |
+
Đây là demo mô phỏng. Trong thực tế, server này sẽ:
|
159 |
+
- Kết nối trực tiếp với service
|
160 |
+
- Thực hiện các thao tác real-time
|
161 |
+
- Trả về dữ liệu chính xác từ API
|
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 "Vui lòng nhập query để test MCP server"
|
170 |
+
|
171 |
+
return demo_instance.simulate_mcp_call(server_name, tool_name, query)
|
172 |
+
|
173 |
+
def get_tools_for_server(server_name: str) -> gr.Dropdown:
|
174 |
+
if server_name in demo_instance.servers:
|
175 |
+
tools = demo_instance.servers[server_name]["tools"]
|
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.Soft(),
|
182 |
+
css="""
|
183 |
+
.gradio-container {
|
184 |
+
max-width: 1200px !important;
|
185 |
+
}
|
186 |
+
.server-info {
|
187 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
188 |
+
color: white;
|
189 |
+
padding: 20px;
|
190 |
+
border-radius: 10px;
|
191 |
+
margin: 10px 0;
|
192 |
+
}
|
193 |
+
"""
|
194 |
+
) as demo:
|
195 |
+
|
196 |
+
gr.HTML("""
|
197 |
+
<div class="server-info">
|
198 |
+
<h1>🚀 Microsoft MCP Servers Demo</h1>
|
199 |
+
<p>Khám phá 10 Microsoft MCP Servers để tăng tốc development workflow của bạn!</p>
|
200 |
+
<p><strong>Model Context Protocol (MCP)</strong> cho phép AI assistant kết nối với external tools và data sources.</p>
|
201 |
+
</div>
|
202 |
+
""")
|
203 |
+
|
204 |
+
with gr.Row():
|
205 |
+
with gr.Column(scale=1):
|
206 |
+
gr.HTML("<h3>🛠️ Chọn MCP Server</h3>")
|
207 |
+
server_dropdown = gr.Dropdown(
|
208 |
+
choices=list(demo_instance.servers.keys()),
|
209 |
+
value="Microsoft Learn Docs",
|
210 |
+
label="MCP Server",
|
211 |
+
info="Chọn server để test"
|
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="Chọn function để gọi"
|
219 |
+
)
|
220 |
+
|
221 |
+
query_input = gr.Textbox(
|
222 |
+
label="Query/Input",
|
223 |
+
placeholder="Nhập query để test MCP server...",
|
224 |
+
lines=3,
|
225 |
+
value="ASP.NET Core authentication"
|
226 |
+
)
|
227 |
+
|
228 |
+
submit_btn = gr.Button("🔍 Test MCP Server", variant="primary")
|
229 |
+
|
230 |
+
with gr.Column(scale=2):
|
231 |
+
gr.HTML("<h3>📊 Kết quả</h3>")
|
232 |
+
output_text = gr.Textbox(
|
233 |
+
label="MCP Server Response",
|
234 |
+
lines=20,
|
235 |
+
max_lines=30,
|
236 |
+
show_copy_button=True
|
237 |
+
)
|
238 |
+
|
239 |
+
# Server info section
|
240 |
+
with gr.Row():
|
241 |
+
gr.HTML("""
|
242 |
+
<div style="background: #f8f9fa; padding: 20px; border-radius: 10px; margin: 20px 0;">
|
243 |
+
<h3>📚 Thông tin về Microsoft MCP Servers</h3>
|
244 |
+
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 15px; margin-top: 15px;">
|
245 |
+
<div style="background: white; padding: 15px; border-radius: 8px; border-left: 4px solid #0078d4;">
|
246 |
+
<h4>📚 Microsoft Learn Docs</h4>
|
247 |
+
<p>Tìm kiếm semantic qua tài liệu Microsoft chính thức</p>
|
248 |
+
</div>
|
249 |
+
<div style="background: white; padding: 15px; border-radius: 8px; border-left: 4px solid #00bcf2;">
|
250 |
+
<h4>☁️ Azure MCP</h4>
|
251 |
+
<p>Quản lý 15+ Azure services và resources</p>
|
252 |
+
</div>
|
253 |
+
<div style="background: white; padding: 15px; border-radius: 8px; border-left: 4px solid #24292e;">
|
254 |
+
<h4>🐙 GitHub MCP</h4>
|
255 |
+
<p>Tương tác với GitHub repos, issues, PRs</p>
|
256 |
+
</div>
|
257 |
+
<div style="background: white; padding: 15px; border-radius: 8px; border-left: 4px solid #0078d4;">
|
258 |
+
<h4>🔄 Azure DevOps</h4>
|
259 |
+
<p>Quản lý work items, builds, releases</p>
|
260 |
+
</div>
|
261 |
+
</div>
|
262 |
+
</div>
|
263 |
+
""")
|
264 |
+
|
265 |
+
# Event handlers
|
266 |
+
server_dropdown.change(
|
267 |
+
fn=lambda server: gr.Dropdown(
|
268 |
+
choices=demo_instance.servers[server]["tools"] if server in demo_instance.servers else [],
|
269 |
+
value=demo_instance.servers[server]["tools"][0] if server in demo_instance.servers and demo_instance.servers[server]["tools"] else None
|
270 |
+
),
|
271 |
+
inputs=[server_dropdown],
|
272 |
+
outputs=[tool_dropdown]
|
273 |
+
)
|
274 |
+
|
275 |
+
submit_btn.click(
|
276 |
+
fn=process_mcp_request,
|
277 |
+
inputs=[server_dropdown, tool_dropdown, query_input],
|
278 |
+
outputs=[output_text]
|
279 |
+
)
|
280 |
+
|
281 |
+
# Load initial result
|
282 |
+
demo.load(
|
283 |
+
fn=lambda: demo_instance.simulate_mcp_call("Microsoft Learn Docs", "microsoft_docs_search", "ASP.NET Core authentication"),
|
284 |
+
outputs=[output_text]
|
285 |
+
)
|
286 |
+
|
287 |
+
return demo
|
288 |
+
|
289 |
+
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 |
+
)
|
297 |
+
|
requirements.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio==4.44.0
|
2 |
+
openai==1.54.3
|
3 |
+
requests==2.31.0
|
4 |
+
python-dotenv==1.0.0
|
5 |
+
mcp==1.0.0
|
6 |
+
httpx==0.27.0
|
7 |
+
asyncio-mqtt==0.16.2
|
8 |
+
aiofiles==23.2.1
|
9 |
+
|