Skip to main content
Glama

fetch_example

Read-only

Retrieve static example diagrams with content, learning objectives, and patterns to understand Ilograph diagram structure and usage.

Instructions

    Retrieves a static example diagram with its content and learning context.

    Args:
        example_name: The filename of the example to fetch (e.g., 'serverless-on-aws.ilograph').

    Returns:
        A dictionary containing the example's content, metadata, learning objectives, and patterns.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
example_nameYes

Implementation Reference

  • The main handler function `fetch_example_tool` that executes the tool logic: retrieves example metadata from the database, reads the diagram file content, handles missing files or errors, and returns the content with metadata.
    async def fetch_example_tool(example_name: str, ctx: Context) -> Dict[str, Any]:
        """
        Retrieves a static example diagram with its content and learning context.
    
        Args:
            example_name: The filename of the example to fetch (e.g., 'serverless-on-aws.ilograph').
    
        Returns:
            A dictionary containing the example's content, metadata, learning objectives, and patterns.
        """
        await ctx.info(f"Attempting to fetch example: {example_name}")
        metadata = EXAMPLES_DATABASE.get(example_name)
    
        if not metadata:
            await ctx.error(f"Example '{example_name}' not found.")
            available = ", ".join(EXAMPLES_DATABASE.keys())
            return {
                "error": "not_found",
                "message": f"Example '{example_name}' not found. Use the 'list_examples' tool to see available examples.",
                "available_examples": available.split(", "),
            }
    
        file_path = metadata.file_path
        if not file_path.is_file():
            await ctx.error(f"Example file not found on disk: {file_path}")
            return {
                "error": "internal_error",
                "message": "The example file could not be found on the server, even though it is listed in the database.",
            }
    
        try:
            content = file_path.read_text(encoding="utf-8")
            await ctx.info(f"Successfully read example file: {example_name}")
            response = metadata.model_dump()
            response["content"] = content
            return response
        except Exception as e:
            await ctx.error(f"Failed to read example file '{example_name}': {e}")
            logger.exception(f"Error reading example file {file_path}")
            return {
                "error": "internal_error",
                "message": f"An unexpected error occurred while reading the example file: {e}",
            }
  • The `@mcp.tool` decorator registers the `fetch_example` tool on the FastMCP server instance, specifying its name, title, read-only hint, and description.
    @mcp.tool(
        name="fetch_example",
        annotations={
            "title": "Get Example Diagram",
            "readOnlyHint": True,
            "description": "Retrieves a specific Ilograph example diagram with its content and rich metadata.",
        },
    )
  • Pydantic `BaseModel` `ExampleMetadata` defines the schema/structure for example metadata, which is included in the tool's response along with the diagram content.
    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
  • `EXAMPLES_DATABASE` is the in-memory manifest providing metadata for all available examples, used by the handler to lookup and validate requested 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",
            ],
        ),
    }
  • In the main server setup, `register_example_tools(mcp)` is called to register the example tools group, which includes the `fetch_example` tool.
    register_example_tools(mcp)
    logger.info("Registered example_tools")
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare readOnlyHint=true, indicating a safe read operation. The description adds valuable context beyond this by specifying what is retrieved ('content, metadata, learning objectives, and patterns') and that the example is 'static' (implying no modifications). It does not contradict annotations and enhances understanding of the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by concise sections for Args and Returns. Every sentence earns its place by providing necessary information without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema), the description is nearly complete: it covers purpose, parameter semantics, and return structure. However, it lacks details on error handling or example availability, which could be useful context. With annotations covering safety, it is mostly adequate.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description fully compensates by explaining the parameter 'example_name' as 'The filename of the example to fetch' and providing an example ('serverless-on-aws.ilograph'). This adds essential meaning beyond the bare schema, clarifying the parameter's purpose and format.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Retrieves') and resource ('a static example diagram with its content and learning context'), distinguishing it from siblings like 'list_examples' (which likely lists available examples without content) and 'fetch_documentation_tool' (which targets documentation). It provides a precise verb+resource combination that avoids tautology.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage when a specific example diagram is needed with full content and context, but does not explicitly state when to use it versus alternatives like 'list_examples' (for browsing) or other fetch tools. It provides clear context (retrieving a specific example) but lacks explicit exclusions or named alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/QuincyMillerDev/ilograph-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server