Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

create_log_parsing_rule

Define custom parsing rules to extract structured data from log entries, enabling targeted analysis and monitoring of application logs.

Instructions

Create a new log parsing rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYes
grokYes
nrqlYes
enabledNo
luceneNo
account_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler function decorated with @mcp.tool(). Handles input parameters, client initialization check, delegates to log_parsing helper, and formats response as JSON.
    @mcp.tool()
    async def create_log_parsing_rule(
        description: str,
        grok: str,
        nrql: str,
        enabled: bool = True,
        lucene: str = "",
        account_id: Optional[str] = None,
    ) -> str:
        """Create a new log parsing rule"""
        if not client:
            return json.dumps({"error": "New Relic client not initialized"})
    
        acct_id = account_id or client.account_id
        if not acct_id:
            return json.dumps({"error": "Account ID required but not provided"})
    
        try:
            result = await log_parsing.create_log_parsing_rule(
                client, acct_id, description, grok, nrql, enabled, lucene
            )
            return json.dumps(result, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, indent=2)
  • Helper function containing the core logic: constructs and executes NerdGraph GraphQL mutation to create the log parsing rule in New Relic.
    async def create_log_parsing_rule(
        client,
        account_id: str,
        description: str,
        grok: str,
        nrql: str,
        enabled: bool = True,
        lucene: str = "",
    ) -> Dict[str, Any]:
        """Create a new log parsing rule"""
        # Escape special characters in GROK pattern for GraphQL
        # grok_escaped = grok.replace("\\", "\\\\")
    
        mutation = f"""
        mutation {{
            logConfigurationsCreateParsingRule(
                accountId: {int(account_id)},
                rule: {{
                    description: "{description}"
                    enabled: {str(enabled).lower()}
                    grok: "{grok}"
                    lucene: "{lucene}"
                    nrql: "{nrql}"
                }}
            ) {{
                rule {{
                    id
                    description
                    enabled
                    grok
                    lucene
                    nrql
                    updatedAt
                }}
                errors {{
                    message
                    type
                }}
            }}
        }}
        """
    
        result = await client.nerdgraph_query(mutation)
    
        if result and "data" in result:
            create_result = result["data"].get("logConfigurationsCreateParsingRule", {})
            if create_result.get("errors"):
                raise Exception(f"Failed to create rule: {create_result['errors']}")
            return create_result.get("rule", {})
    
        raise Exception("Failed to create parsing rule")
Behavior1/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 only states the action ('create') without detailing permissions, side effects, rate limits, or response format. For a mutation tool with zero annotation coverage, this is inadequate and leaves critical behavioral traits unspecified.

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 a single, efficient sentence with no wasted words. It is appropriately sized and front-loaded, though its brevity contributes to underspecification rather than clarity. Every word serves the purpose, earning a high score for conciseness despite content gaps.

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

Completeness1/5

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

Given the complexity of a 6-parameter mutation tool with no annotations and 0% schema coverage, the description is severely incomplete. It lacks purpose differentiation, usage guidelines, behavioral context, and parameter semantics. Although an output schema exists, the description does not provide enough context for effective tool use, making it inadequate overall.

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

Parameters1/5

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

Schema description coverage is 0%, meaning none of the 6 parameters are documented in the schema. The description adds no information about parameters, failing to compensate for this gap. It does not explain what 'grok', 'nrql', or other fields mean, their formats, or how they interact, leaving parameters entirely undocumented.

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

Purpose2/5

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

The description 'Create a new log parsing rule' restates the tool name with minimal elaboration. It specifies the verb ('create') and resource ('log parsing rule'), but does not distinguish from siblings like 'generate_log_parsing_rule' or 'update_log_parsing_rule', leaving ambiguity about when to use each. This is a tautological restatement rather than a clear, differentiated purpose.

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

Usage Guidelines1/5

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

No guidance is provided on when to use this tool versus alternatives. Siblings include 'generate_log_parsing_rule' and 'update_log_parsing_rule', but the description does not mention these or explain prerequisites, contexts, or exclusions. This lack of guidance could lead to incorrect tool selection.

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/piekstra/newrelic-mcp-server'

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