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.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "query_comments"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
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]