rajsinghparihar
commited on
Commit
·
2cc44c8
1
Parent(s):
437ee38
add tag: mcp-server-track
Browse files
README.md
CHANGED
@@ -8,6 +8,7 @@ sdk_version: 5.33.0
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
short_description: A Gradio Application that uses Agentic AI to plan travels
|
|
|
11 |
---
|
12 |
|
13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
8 |
app_file: app.py
|
9 |
pinned: false
|
10 |
short_description: A Gradio Application that uses Agentic AI to plan travels
|
11 |
+
tag: mcp-server-track
|
12 |
---
|
13 |
|
14 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
CHANGED
@@ -104,7 +104,7 @@ def search_hotels(
|
|
104 |
|
105 |
|
106 |
with gr.Blocks(title="Travel Itinerary MCP Server") as app:
|
107 |
-
gr.Markdown("# Travel Itinerary MCP Server")
|
108 |
with gr.Tab("Search Flights"):
|
109 |
gr.Interface(
|
110 |
fn=search_flights,
|
|
|
104 |
|
105 |
|
106 |
with gr.Blocks(title="Travel Itinerary MCP Server") as app:
|
107 |
+
gr.Markdown("# Travel Itinerary MCP Server\nThis application allows users to search for flights and hotels using the Google Flights and Google Hotels APIs via SerpAPI.")
|
108 |
with gr.Tab("Search Flights"):
|
109 |
gr.Interface(
|
110 |
fn=search_flights,
|
script.py
DELETED
@@ -1,57 +0,0 @@
|
|
1 |
-
import asyncio
|
2 |
-
import os
|
3 |
-
from dotenv import load_dotenv
|
4 |
-
import openai
|
5 |
-
from agents import Agent, Runner, AsyncOpenAI, OpenAIChatCompletionsModel
|
6 |
-
from agents.mcp import MCPServerSse
|
7 |
-
import json
|
8 |
-
|
9 |
-
# Load environment
|
10 |
-
load_dotenv()
|
11 |
-
|
12 |
-
# Set API key
|
13 |
-
openai.api_key = os.getenv("NEBIUS_API_KEY")
|
14 |
-
openai.base_url = "https://api.studio.nebius.com/v1/"
|
15 |
-
|
16 |
-
# MCP tool URL (replace with actual URL you got from step 4.3)
|
17 |
-
TOOL_URL = "http://127.0.0.1:7860/gradio_api/mcp/sse"
|
18 |
-
|
19 |
-
async def main():
|
20 |
-
mcp_server = MCPServerSse({"url": TOOL_URL})
|
21 |
-
|
22 |
-
try:
|
23 |
-
await mcp_server.connect()
|
24 |
-
|
25 |
-
# Create an agent and register the connected tool
|
26 |
-
# ✅ Replace "MCP Agent" with a descriptive name if desired
|
27 |
-
# ✅ Update instructions to guide the agent's behavior
|
28 |
-
agent = Agent(
|
29 |
-
name="MCP Agent",
|
30 |
-
instructions="You help the user complete tasks using the connected tool.",
|
31 |
-
mcp_servers=[mcp_server],
|
32 |
-
model=OpenAIChatCompletionsModel(
|
33 |
-
model="Qwen/Qwen3-235B-A22B",
|
34 |
-
openai_client=AsyncOpenAI(base_url="https://api.studio.nebius.com/v1/", api_key=os.getenv("NEBIUS_API_KEY"))
|
35 |
-
)
|
36 |
-
)
|
37 |
-
|
38 |
-
# 🔁 Replace this task with your actual prompt or goal
|
39 |
-
task = "You are a helpful assistant. Use the connected tool to assist with tasks. Read and analyse the tool output, focusing on key information and help the user in the following task:" \
|
40 |
-
"I want to travel from Hyderabad to Phuket from 5th July to 23rd July in 2025, please help me with my flight search, what are my cheapest and fastest options."
|
41 |
-
|
42 |
-
result = await Runner.run(agent, task)
|
43 |
-
|
44 |
-
print(result.final_output)
|
45 |
-
# print(json.dumps(result.new_items, indent=4))
|
46 |
-
# print(result.raw_responses)
|
47 |
-
|
48 |
-
# for r in result:
|
49 |
-
# print(r)
|
50 |
-
# print("\n============\n")
|
51 |
-
|
52 |
-
finally:
|
53 |
-
await mcp_server.cleanup()
|
54 |
-
|
55 |
-
# Run the async main function
|
56 |
-
if __name__ == "__main__":
|
57 |
-
asyncio.run(main())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|