MCP Servers contd
- Lets try integrating our mcp server with llm and get the work done
- On windows, Create and environmental variables
VIRTUAL_ENV and pass the value of your folder of .venv C:\khajaclassroom\GenerativeAI\agenticai\june25\mcp\servers\dummy_sales_data\.venv
- Now run the mcp based on configuration from claude, it should work
How to integrate this MCP server with MCP Host
- In our case to start with MCP Host will be a langgraph.
Resource Template
- A resource template is a resource where we can pass arguments
@mcp.resource(uri="product://selected/{product_id}")
def get_selected_product(product_id: int):
"""This method gets the selected product
"""
connection = get_database_connection()
cursor = connection.cursor()
latest_product_sql = f"SELECT * FROM `products` Where product_id = {product_id};"
cursor.execute(latest_product_sql)
products = cursor.fetchall()
product = products[0]
message = f"{product[1]} => {product[2]}"
return message