Skip to main content
Glama
nilay320

Tavily Web Search MCP Server

by nilay320

generate_qr_code

Create QR codes for text or URLs with customizable error correction, border size, and pixel dimensions to share information quickly.

Instructions

Generate a QR code for the given data.

Args: data: The text or URL to encode in the QR code error_correction: Error correction level - "L" (Low ~7%), "M" (Medium ~15%), "Q" (Quartile ~25%), "H" (High ~30%) border: Size of the border (minimum is 4) box_size: Size of each box in pixels (default 10)

Returns: Base64 encoded PNG image of the QR code that can be displayed or saved

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dataYes
error_correctionNoM
borderNo
box_sizeNo

Implementation Reference

  • The main handler function for the 'generate_qr_code' tool, decorated with @mcp.tool() which also registers it in the MCP server. It generates a QR code from input data using the qrcode library, applies specified error correction, border, and box size, and returns a base64-encoded PNG image.
    @mcp.tool()
    def generate_qr_code(data: str, error_correction: str = "M", border: int = 4, box_size: int = 10) -> str:
        """
        Generate a QR code for the given data.
        
        Args:
            data: The text or URL to encode in the QR code
            error_correction: Error correction level - "L" (Low ~7%), "M" (Medium ~15%), "Q" (Quartile ~25%), "H" (High ~30%)
            border: Size of the border (minimum is 4)
            box_size: Size of each box in pixels (default 10)
        
        Returns:
            Base64 encoded PNG image of the QR code that can be displayed or saved
        """
        try:
            # Set error correction level
            error_levels = {
                "L": qrcode.constants.ERROR_CORRECT_L,
                "M": qrcode.constants.ERROR_CORRECT_M, 
                "Q": qrcode.constants.ERROR_CORRECT_Q,
                "H": qrcode.constants.ERROR_CORRECT_H
            }
            
            if error_correction not in error_levels:
                return f"Error: Invalid error correction level. Use L, M, Q, or H"
            
            # Create QR code instance
            qr = qrcode.QRCode(
                version=1,  # Controls size (1 is smallest)
                error_correction=error_levels[error_correction],
                box_size=box_size,
                border=max(border, 4),  # Minimum border is 4
            )
            
            # Add data
            qr.add_data(data)
            qr.make(fit=True)
            
            # Create image
            img = qr.make_image(fill_color="black", back_color="white")
            
            # Convert to base64 for easy transmission
            img_buffer = io.BytesIO()
            img.save(img_buffer, format='PNG')
            img_str = base64.b64encode(img_buffer.getvalue()).decode()
            
            return f"QR code generated successfully for: '{data[:50]}{'...' if len(data) > 50 else ''}'\nBase64 PNG: data:image/png;base64,{img_str}"
            
        except Exception as e:
            return f"Error generating QR code: {str(e)}"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the return format (Base64 encoded PNG image) but lacks details on performance, rate limits, error handling, or side effects. For a tool with no annotations, this is a significant gap in transparency.

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

Conciseness4/5

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

The description is well-structured with a clear purpose statement followed by Args and Returns sections. It's appropriately sized with no redundant information, though the parameter explanations could be slightly more concise (e.g., the error correction percentages are detailed but not strictly necessary).

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

Completeness3/5

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

Given no annotations, no output schema, and 4 parameters, the description is moderately complete. It covers parameters well and specifies the return format, but lacks context on behavioral aspects like error conditions or usage limits, making it adequate but with clear gaps for a tool of this complexity.

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?

Schema description coverage is 0%, so the description must compensate. It provides detailed semantic explanations for all four parameters: 'data' as text/URL to encode, 'error_correction' with levels and percentages, 'border' with minimum value, and 'box_size' with default. This adds substantial meaning beyond the bare schema.

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

Purpose4/5

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

The description clearly states the tool's purpose as 'Generate a QR code for the given data,' which is a specific verb+resource combination. However, it doesn't differentiate from sibling tools (roll_dice, scientific_calculator, web_search) since they serve completely different domains, so sibling differentiation isn't relevant here.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention any prerequisites, constraints, or scenarios where this tool is preferred over other methods for generating QR codes or handling the data.

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/nilay320/MCP-Session-Code'

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