Skip to main content
Glama
list91
by list91

mcp_validate

Validate parameters for read or write operations to check if calls will succeed before execution, returning validation results and estimated token counts.

Instructions

Validate parameters for mcp_read or mcp_write without executing.

Use to check if a call will succeed before making it.

Parameters:

  • tool (required): "read" | "write"

  • params (required): Parameters object to validate

Returns:

  • valid: true/false

  • errors: List of error codes and messages

  • warnings: List of warnings

  • estimated_tokens: Estimated response token count

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toolYesTool to validate
paramsYesParameters to validate

Implementation Reference

  • Core handler function for the mcp_validate tool. Validates input parameters for mcp_read or mcp_write tools, collects errors and warnings, estimates token count, and returns a formatted validation result.
    async def mcp_validate(
        tool: str,
        params: dict,
    ) -> str:
        """
        Validate parameters for mcp_read or mcp_write without executing.
    
        Returns validation result with errors and warnings.
        """
        errors: list[str] = []
        warnings: list[str] = []
    
        if tool == "read":
            errors, warnings = await _validate_read(params)
        elif tool == "write":
            errors, warnings = await _validate_write(params)
        else:
            errors.append(f"INVALID_TOOL: Unknown tool '{tool}'. Valid: read, write")
    
        if errors:
            return f"valid:false|errors:[{'; '.join(errors)}]"
    
        warning_str = f"|warnings:[{'; '.join(warnings)}]" if warnings else ""
        estimated_tokens = _estimate_tokens(tool, params)
    
        return f"valid:true{warning_str}|estimated_tokens:{estimated_tokens}"
  • Registers the mcp_validate tool in the MCP server's list_tools() handler, including name, description, and JSON input schema.
            Tool(
                name="mcp_validate",
                description="""Validate parameters for mcp_read or mcp_write without executing.
    
    Use to check if a call will succeed before making it.
    
    Parameters:
    - tool (required): "read" | "write"
    - params (required): Parameters object to validate
    
    Returns:
    - valid: true/false
    - errors: List of error codes and messages
    - warnings: List of warnings
    - estimated_tokens: Estimated response token count""",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "tool": {
                            "type": "string",
                            "enum": ["read", "write"],
                            "description": "Tool to validate"
                        },
                        "params": {
                            "type": "object",
                            "description": "Parameters to validate"
                        }
                    },
                    "required": ["tool", "params"]
                }
            )
  • Dispatches tool calls to the mcp_validate handler function in the server's call_tool method.
    elif name == "mcp_validate":
        result = await mcp_validate(**arguments)
  • Pydantic model defining the input schema for mcp_validate tool parameters.
    class ValidateRequest(BaseModel):
        """Parameters for mcp_validate tool."""
    
        tool: Literal["read", "write"] = Field(..., description="Tool to validate")
        params: dict = Field(..., description="Parameters to validate")
  • Helper function to validate parameters specifically for the 'read' tool.
    async def _validate_read(params: dict) -> tuple[list[str], list[str]]:
        """Validate mcp_read parameters."""
        errors: list[str] = []
        warnings: list[str] = []
    
        mode = params.get("mode")
        tab = params.get("tab", "")
        index = params.get("index")
        query = params.get("query")
        search_in = params.get("search_in", "all")
        max_depth = params.get("max_depth", 2)
        max_items = params.get("max_items", 20)
        skip = params.get("skip", 0)
    
        # Validate mode
        valid_modes = [m.value for m in ReadMode]
        if not mode:
            errors.append("MISSING_PARAM: mode is required")
        elif mode not in valid_modes:
            errors.append(f"INVALID_MODE: '{mode}' not in {valid_modes}")
    
        # Mode-specific validation
        if mode == "list" or mode == "item":
            if not tab:
                errors.append(f"MISSING_PARAM: tab is required for mode={mode}")
            elif not await client.tab_exists(tab):
                errors.append(f"TAB_NOT_FOUND: {tab}")
    
        if mode == "item":
            if index is None:
                errors.append("MISSING_PARAM: index is required for mode=item")
            elif tab and await client.tab_exists(tab):
                count = await client.get_count(tab)
                if index < 0 or index >= count:
                    errors.append(f"INDEX_OUT_OF_BOUNDS: {index} (count: {count})")
    
        if mode == "search":
            if not query:
                errors.append("MISSING_PARAM: query is required for mode=search")
            if search_in not in [s.value for s in SearchIn]:
                errors.append(f"INVALID_PARAM: search_in '{search_in}' invalid")
    
        # Validate numeric params
        if max_depth < 1 or max_depth > 10:
            warnings.append(f"max_depth={max_depth} clamped to 1-10")
        if max_items < 1 or max_items > 100:
            warnings.append(f"max_items={max_items} clamped to 1-100")
        if skip < 0:
            errors.append("INVALID_PARAM: skip must be >= 0")
    
        return errors, warnings
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses key behavioral traits: it validates parameters without executing, checks for success, and returns validation results (valid/errors/warnings/estimated_tokens). This covers the core behavior well, though it could mention performance or rate limits for completeness.

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, followed by clear sections for parameters and returns. Every sentence earns its place by providing essential 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 complexity (validation without execution), no annotations, and no output schema, the description does a good job by explaining the purpose, usage, parameters, and return values. It could be more complete by detailing error handling or validation rules, but it covers the essentials adequately.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal value beyond the schema by listing parameters and their types, but doesn't provide additional syntax or format details. This meets the baseline for high schema coverage.

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 purpose: 'Validate parameters for mcp_read or mcp_write without executing.' It distinguishes this tool from its siblings (mcp_read and mcp_write) by emphasizing validation without execution, which is a clear differentiation.

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

Usage Guidelines5/5

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

The description explicitly provides usage guidance: 'Use to check if a call will succeed before making it.' This tells the agent when to use this tool (before executing mcp_read or mcp_write) and implies an alternative (using the actual tools directly), making it clear in context.

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/list91/mcp-copyq'

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