list_examples
List available example diagrams, optionally filtering by category to find beginner, intermediate, or advanced examples.
Instructions
Lists available Ilograph example diagrams, optionally filtering by category.
Args:
category: Filter examples by complexity ('beginner', 'intermediate', 'advanced').
Returns:
A dictionary containing a list of available examples and a message guiding the user.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No |
Implementation Reference
- The list_examples_tool async function - the actual handler that lists available example diagrams, optionally filtered by category.
async def list_examples_tool( category: Optional[Literal["beginner", "intermediate", "advanced"]] = None, ) -> Dict[str, Any]: """ Lists available Ilograph example diagrams, optionally filtering by category. Args: category: Filter examples by complexity ('beginner', 'intermediate', 'advanced'). Returns: A dictionary containing a list of available examples and a message guiding the user. """ examples_to_list: List[ExampleMetadata] = list(EXAMPLES_DATABASE.values()) if category: examples_to_list = [ex for ex in examples_to_list if ex.category == category] if not examples_to_list: return { "message": f"No examples found for category '{category}'. Try again without a category to see all examples." } return { "examples": [_get_example_summary(ex) for ex in examples_to_list], "message": "To get the full content of an example, use the 'fetch_example' tool with its 'example_name'.", } - The ExampleMetadata Pydantic schema used for input/output validation of example data.
class ExampleMetadata(BaseModel): """Defines the metadata structure for an Ilograph example.""" name: str category: Literal["beginner", "intermediate", "advanced"] description: str learning_objectives: List[str] = Field(default_factory=list) patterns_demonstrated: List[str] = Field(default_factory=list) - src/ilograph_mcp/tools/register_example_tools.py:102-112 (registration)The register_example_tools function that decorates the handler with @mcp.tool(name='list_examples') to register it with FastMCP.
def register_example_tools(mcp: FastMCP) -> None: """Register the example diagram tools with the FastMCP server.""" @mcp.tool( name="list_examples", annotations={ "title": "List Available Example Diagrams", "readOnlyHint": True, "description": "Lists available Ilograph example diagrams with their categories and descriptions.", }, ) - The _get_example_summary helper function that returns a concise summary of an example (name, category, description).
def _get_example_summary(metadata: ExampleMetadata) -> Dict[str, Any]: """Returns a concise summary of an example.""" return metadata.model_dump(include={"name", "category", "description"}) - src/ilograph_mcp/server.py:67-68 (registration)The call to register_example_tools(mcp) in the main server creation function, which triggers registration of the list_examples tool.
register_example_tools(mcp) logger.info("Registered example_tools")