sales_assistant / chat_mcp_server.py
ZweliM's picture
Create chat_mcp_server.py
8f4cf69 verified
raw
history blame
4.59 kB
from mcp.server.fastmcp import FastMCP
mcp = FastMCP("chatbot")
@mcp.tool()
def product_recommendation(product_name: str) -> str:
"""
Recommend a product based on the provided product name.
Args:
product_name (str): The name of the product to recommend.
Returns:
str: A recommendation for the product.
"""
return f"I recommend you try {product_name}."
@mcp.tool()
def cart_managemnt(action: str, product_name: str) -> str:
"""
Manage the shopping cart by adding or removing products.
Args:
action (str): The action to perform ('add' or 'remove').
product_name (str): The name of the product to add or remove.
Returns:
str: A message indicating the result of the action.
"""
if action == "add":
return f"{product_name} has been added to your cart."
elif action == "remove":
return f"{product_name} has been removed from your cart."
else:
return "Invalid action. Please specify 'add' or 'remove'."
@mcp.tool()
def abondoned_cart_recovery() -> str:
"""
Recover abandoned carts by sending a reminder to the user.
Returns:
str: A reminder message for the user to complete their purchase.
"""
return "Don't forget to complete your purchase! Your cart is waiting for you."
@mcp.tool()
def order_tracking(order_id: str) -> str:
"""
Track an order based on the provided order ID.
Args:
order_id (str): The ID of the order to track.
Returns:
str: A message with the current status of the order.
"""
return f"Your order {order_id} is currently being processed and will be shipped soon."
@mcp.tool()
def checkout() -> str:
"""
Perform the checkout process.
Returns:
str: A message indicating that the checkout process has been completed.
"""
return "Checkout completed successfully! Thank you for your purchase."
@mcp.tool()
def customer_support(issue: str) -> str:
"""
Provide customer support for the specified issue.
Args:
issue (str): The issue or question the user has.
Returns:
str: A response to the customer's issue.
"""
return f"Our customer support team is looking into your issue: {issue}. We will get back to you shortly."
@mcp.tool()
def product_search(query: str) -> str:
"""
Search for products based on the provided query.
Args:
query (str): The search query for products.
Returns:
str: A message with the search results.
"""
return f"Here are the products matching your search for '{query}': [Product List]."
@mcp.tool()
def multi_channel_support(channel: str, message: str) -> str:
"""
Provide support through multiple channels.
Args:
channel (str): The support channel (e.g., 'email', 'chat', 'phone').
message (str): The message or issue to address.
Returns:
str: A response indicating the support provided through the specified channel.
"""
return f"We have received your message via {channel}: '{message}'. Our team will respond shortly."
@mcp.tool()
def personalized_recommendations(user_id: str) -> str:
"""
Provide personalized product recommendations based on the user's ID.
Args:
user_id (str): The ID of the user for whom to provide recommendations.
Returns:
str: A message with personalized product recommendations.
"""
return f"Based on your preferences, we recommend the following products for you, User {user_id}: [Personalized Product List]."
@mcp.tool()
def inventory_management(product_name: str, action: str) -> str:
"""
Manage inventory by adding or removing products.
Args:
product_name (str): The name of the product to manage.
action (str): The action to perform ('add' or 'remove').
Returns:
str: A message indicating the result of the inventory management action.
"""
if action == "add":
return f"{product_name} has been added to the inventory."
elif action == "remove":
return f"{product_name} has been removed from the inventory."
else:
return "Invalid action. Please specify 'add' or 'remove'."
@mcp.tool()
def stock_awareness(product_name: str) -> str:
"""
Check the stock availability of a product.
Args:
product_name (str): The name of the product to check.
Returns:
str: A message indicating the stock status of the product.
"""
return f"The current stock status for {product_name} is: [Stock Status]."