get_tutorial
Retrieve a complete Magento 2 GraphQL tutorial with all steps in order. Provide the tutorial name (e.g., 'checkout') to get the full step-by-step guide.
Instructions
Get complete tutorial with all steps in order
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tutorial_name | Yes | Tutorial name, e.g., 'checkout' |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- magento_graphql_docs_mcp/server.py:326-374 (registration)Registration of the 'get_tutorial' tool using @mcp.tool decorator with name and description
@mcp.tool( name="get_tutorial", description="Get complete tutorial with all steps in order" ) def get_tutorial( tutorial_name: Annotated[str, Field(description="Tutorial name, e.g., 'checkout'")] ) -> str: """Get sequential tutorial steps""" db = Database(DB_PATH) # Search for tutorial documents docs = list(db.query( "SELECT * FROM documents WHERE category = 'tutorials' AND (subcategory = ? OR file_path LIKE ?) ORDER BY file_path", [tutorial_name, f"tutorials/{tutorial_name}%"] )) if not docs: return f"Tutorial not found: {tutorial_name}\n\nAvailable tutorials: Use list_categories() to see all tutorials." # Format tutorial lines = [f"# {tutorial_name.title()} Tutorial", ""] for i, doc in enumerate(docs, 1): lines.append(f"## Step {i}: {doc['title']}") lines.append("") lines.append(f"**File:** {doc['file_path']}") lines.append("") if doc.get('description'): lines.append(doc['description']) lines.append("") # Get code examples code_blocks = list(db.query( "SELECT * FROM code_blocks WHERE document_id = ? AND language IN ('graphql', 'json') LIMIT 2", [doc['id']] )) if code_blocks: for block in code_blocks: lines.append(f"```{block['language']}") lines.append(block['code']) lines.append("```") lines.append("") lines.append("---") lines.append("") return "\n".join(lines) - Handler function implementing the tool logic: queries the database for tutorial documents with matching tutorial_name in the 'tutorials' category, formats them sequentially with step numbers, code examples, and returns as a formatted string
def get_tutorial( tutorial_name: Annotated[str, Field(description="Tutorial name, e.g., 'checkout'")] ) -> str: """Get sequential tutorial steps""" db = Database(DB_PATH) # Search for tutorial documents docs = list(db.query( "SELECT * FROM documents WHERE category = 'tutorials' AND (subcategory = ? OR file_path LIKE ?) ORDER BY file_path", [tutorial_name, f"tutorials/{tutorial_name}%"] )) if not docs: return f"Tutorial not found: {tutorial_name}\n\nAvailable tutorials: Use list_categories() to see all tutorials." # Format tutorial lines = [f"# {tutorial_name.title()} Tutorial", ""] for i, doc in enumerate(docs, 1): lines.append(f"## Step {i}: {doc['title']}") lines.append("") lines.append(f"**File:** {doc['file_path']}") lines.append("") if doc.get('description'): lines.append(doc['description']) lines.append("") # Get code examples code_blocks = list(db.query( "SELECT * FROM code_blocks WHERE document_id = ? AND language IN ('graphql', 'json') LIMIT 2", [doc['id']] )) if code_blocks: for block in code_blocks: lines.append(f"```{block['language']}") lines.append(block['code']) lines.append("```") lines.append("") lines.append("---") lines.append("") return "\n".join(lines) - Input schema: tutorial_name parameter (string) with Field description 'Tutorial name, e.g., checkout'
tutorial_name: Annotated[str, Field(description="Tutorial name, e.g., 'checkout'")] - Example usage of get_tutorial tool in the example script
result = await session.call_tool("get_tutorial", arguments={ "tutorial_name": "checkout" }) - tests/verify_server.py:87-89 (helper)Test usage of get_tutorial tool in verify_server test script
result = await session.call_tool("get_tutorial", arguments={ "tutorial_name": "checkout" })