list_examples
Discover and filter Ilograph example diagrams by complexity level (beginner, intermediate, advanced) to simplify learning and implementation.
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
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| category | No |
Implementation Reference
- The handler function that implements the core logic of the list_examples tool, filtering examples by optional category parameter and returning summaries.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'.", }
- Pydantic BaseModel schema defining the structure of each example's metadata, used in tool responses.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) @property def file_path(self) -> Path: """Returns the full path to the example file.""" return EXAMPLES_DIR / self.name
- src/ilograph_mcp/tools/register_example_tools.py:105-112 (registration)The @mcp.tool decorator that registers the list_examples tool on the FastMCP instance, including name and annotations for schema and description.@mcp.tool( name="list_examples", annotations={ "title": "List Available Example Diagrams", "readOnlyHint": True, "description": "Lists available Ilograph example diagrams with their categories and descriptions.", }, )
- src/ilograph_mcp/server.py:67-68 (registration)The call to register_example_tools(mcp) in the server setup, which triggers the registration of the list_examples tool.register_example_tools(mcp) logger.info("Registered example_tools")
- The in-memory database of example metadata that the handler uses to list available examples.EXAMPLES_DATABASE: Dict[str, ExampleMetadata] = { "serverless-on-aws.ilograph": ExampleMetadata( name="serverless-on-aws.ilograph", category="intermediate", description="A comprehensive diagram of a serverless web application architecture on AWS, using services like Lambda, API Gateway, S3, and DynamoDB.", learning_objectives=[ "Understand how to model serverless architectures.", "Learn the relationships between API Gateway, Lambda, and DynamoDB.", "See how to represent S3 buckets for static content hosting.", ], patterns_demonstrated=[ "Serverless", "AWS", "API Gateway", "Lambda", "DynamoDB", "Microservices", ], ), "stack-overflow-architecture-2016.ilograph": ExampleMetadata( name="stack-overflow-architecture-2016.ilograph", category="advanced", description="The 2016 architecture of Stack Overflow, showcasing a high-traffic, resilient web application with a mix of .NET technologies, Redis, and SQL Server.", learning_objectives=[ "Analyze a real-world, high-scale web architecture.", "Understand patterns for redundancy, caching, and load balancing.", "Learn to model complex interactions between various services and data stores.", ], patterns_demonstrated=[ "Web Architecture", "High Availability", "Caching", "Load Balancing", "SQL", "Redis", ], ), "aws-distributed-load-testing.ilograph": ExampleMetadata( name="aws-distributed-load-testing.ilograph", category="advanced", description="A sophisticated AWS architecture for a distributed load testing solution, featuring containerized tasks, event-driven flows, and detailed networking.", learning_objectives=[ "Model complex, event-driven systems on AWS.", "Understand how to represent container orchestration with Fargate.", "Learn advanced networking concepts like VPCs, subnets, and security groups.", ], patterns_demonstrated=[ "Cloud Architecture", "Distributed Systems", "Event-Driven", "AWS Fargate", "Networking", "Scalability", ], ), }