query_comments
Retrieve user comments from a culinary recipes database to analyze feedback, improve dishes, and understand community preferences.
Instructions
Queries the 'comments' collection of the 'recipies' MongoDB database.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No |
Implementation Reference
- main.py:382-385 (registration)Registration of the 'query_comments' tool using the @mcp.tool decorator, specifying name and description.@mcp.tool( name="query_comments", description="Queries the 'comments' collection of the 'recipies' MongoDB database.", )
- main.py:386-395 (handler)The main handler function for the 'query_comments' tool. It connects to the local MongoDB instance, queries the 'comments' collection in the 'recipies' database with the provided query dictionary (or empty), converts results to JSON-serializable format using _to_jsonable, and returns the list of dictionaries.async def query_comments(query: Optional[Dict] = None) -> List[Dict]: """Interroge la collection 'comments' de la base de données MongoDB 'recipies'.""" client = MongoClient('mongodb://localhost:27017/') db = client['recipies'] collection = db['comments'] query = query or {} results = list(collection.find(query)) client.close() return [_to_jsonable(doc) for doc in results]