Skip to main content
Glama
wagonbomb

Megaraptor MCP

by wagonbomb

run_vql

Execute Velociraptor Query Language queries for forensic analysis, endpoint management, and threat hunting investigations.

Instructions

Execute an arbitrary VQL (Velociraptor Query Language) query.

VQL is the query language used by Velociraptor for forensic analysis. It follows a SQL-like syntax with plugins instead of tables.

Common VQL patterns:

  • SELECT * FROM info() -- Get server info

  • SELECT * FROM clients() -- List all clients

  • SELECT * FROM pslist() -- List processes (client artifact)

  • SELECT * FROM Artifact.Windows.System.Pslist() -- Run artifact

Args: query: The VQL query to execute env: Optional environment variables to pass to the query. Use this to safely pass dynamic values instead of string interpolation. max_rows: Maximum number of rows to return (default 10000) org_id: Optional organization ID for multi-tenant deployments

Returns: Query results as JSON.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
envNo
max_rowsNo
org_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler implementation for the `run_vql` tool, which executes VQL queries against a Velociraptor client, including input validation and error handling.
    @mcp.tool()
    async def run_vql(
        query: str,
        env: Optional[dict[str, Any]] = None,
        max_rows: int = 10000,
        org_id: Optional[str] = None,
    ) -> list[TextContent]:
        """Execute an arbitrary VQL (Velociraptor Query Language) query.
    
        VQL is the query language used by Velociraptor for forensic analysis.
        It follows a SQL-like syntax with plugins instead of tables.
    
        Common VQL patterns:
        - SELECT * FROM info()  -- Get server info
        - SELECT * FROM clients()  -- List all clients
        - SELECT * FROM pslist()  -- List processes (client artifact)
        - SELECT * FROM Artifact.Windows.System.Pslist()  -- Run artifact
    
        Args:
            query: The VQL query to execute
            env: Optional environment variables to pass to the query.
                 Use this to safely pass dynamic values instead of string interpolation.
            max_rows: Maximum number of rows to return (default 10000)
            org_id: Optional organization ID for multi-tenant deployments
    
        Returns:
            Query results as JSON.
        """
        try:
            # Input validation
            if not query or not query.strip():
                return [TextContent(
                    type="text",
                    text=json.dumps({
                        "error": "query parameter is required and cannot be empty"
                    })
                )]
    
            max_rows = validate_limit(max_rows)
            query = validate_vql_syntax_basics(query)
    
            # Add LIMIT if not already present and query doesn't have one
            query_upper = query.upper()
            if "LIMIT" not in query_upper:
                query = f"{query.rstrip(';')} LIMIT {max_rows}"
            client = get_client()
            results = client.query(query, env=env, org_id=org_id)
    
            return [TextContent(
                type="text",
                text=json.dumps({
                    "query": query,
                    "row_count": len(results),
                    "results": results,
                }, indent=2, default=str)
            )]
    
        except grpc.RpcError as e:
            error_response = map_grpc_error(e, "VQL query execution")
    
            # For INVALID_ARGUMENT errors, try to extract VQL-specific hints
            if error_response.get("grpc_status") == "INVALID_ARGUMENT":
                error_message = str(e)
                vql_hint = extract_vql_error_hint(error_message)
                if vql_hint:
                    error_response["vql_hint"] = vql_hint
    
            error_response["query"] = query
            return [TextContent(
                type="text",
                text=json.dumps(error_response)
            )]
    
        except ValueError as e:
            # Validation errors
            return [TextContent(
                type="text",
                text=json.dumps({
                    "error": str(e),
                    "hint": "Check VQL syntax and max_rows parameter"
                })
            )]
    
        except Exception:
            # Generic errors - don't expose internals
            return [TextContent(
                type="text",
                text=json.dumps({
                    "error": "Failed to execute VQL query",
                    "hint": "Check VQL syntax and Velociraptor server connection"
                })
            )]
Behavior4/5

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

No annotations provided, so description carries full burden. Adds critical safety context about 'env' parameter enabling safe dynamic value passing vs string interpolation, documents default max_rows limit (10000), notes JSON return format, and mentions multi-tenancy support. Missing explicit notes on query side effects or resource limits.

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?

Well-structured with front-loaded purpose statement, VQL syntax explanation, bulleted common patterns, and Args/Returns sections. Slightly verbose but justified given complexity of query language tool and need to compensate for empty schema descriptions. No filler content.

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

Completeness5/5

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

Comprehensive for a complex query execution tool. Covers language basics, practical examples, all parameters (compensating for schema gaps), and return format. Output schema exists, so minimal return value description is appropriate. Addresses multi-tenant and safety considerations.

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 has 0% description coverage (only titles), but description fully compensates by documenting all 4 parameters with clear semantics: query syntax, env safety purpose, max_rows default, and org_id multi-tenant behavior. The env explanation adds significant value beyond basic type info.

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?

Description opens with specific verb 'Execute' and resource 'arbitrary VQL query', clearly distinguishing it from siblings like 'collect_artifact' (predefined artifacts) and 'vql_help' (documentation). The forensic analysis context further clarifies scope.

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

Usage Guidelines3/5

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

Provides common VQL patterns and examples that implicitly guide usage, but lacks explicit 'when to use this vs alternatives' guidance. Does not clarify when to prefer 'collect_artifact' over arbitrary VQL or vice versa.

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/wagonbomb/megaraptor-mcp'

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