Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

update_log_parsing_rule

Modify an existing log parsing rule in New Relic to change its configuration, such as Grok patterns, NRQL queries, or enablement status.

Instructions

Update an existing log parsing rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYes
descriptionNo
grokNo
nrqlNo
enabledNo
luceneNo
account_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler decorated with @mcp.tool(), which handles input parameters, client validation, and delegates to the log_parsing helper function.
    @mcp.tool()
    async def update_log_parsing_rule(
        rule_id: str,
        description: Optional[str] = None,
        grok: Optional[str] = None,
        nrql: Optional[str] = None,
        enabled: Optional[bool] = None,
        lucene: Optional[str] = None,
        account_id: Optional[str] = None,
    ) -> str:
        """Update an existing 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.update_log_parsing_rule(
                client, acct_id, rule_id, description, grok, nrql, enabled, lucene
            )
            return json.dumps(result, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, indent=2)
  • The @mcp.tool() decorator registers this function as an MCP tool named 'update_log_parsing_rule'.
    @mcp.tool()
    async def update_log_parsing_rule(
        rule_id: str,
        description: Optional[str] = None,
        grok: Optional[str] = None,
        nrql: Optional[str] = None,
        enabled: Optional[bool] = None,
        lucene: Optional[str] = None,
        account_id: Optional[str] = None,
    ) -> str:
        """Update an existing 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.update_log_parsing_rule(
                client, acct_id, rule_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 that constructs and executes the GraphQL mutation to update a log parsing rule in New Relic via NerdGraph API.
    async def update_log_parsing_rule(
        client,
        account_id: str,
        rule_id: str,
        description: Optional[str] = None,
        grok: Optional[str] = None,
        nrql: Optional[str] = None,
        enabled: Optional[bool] = None,
        lucene: Optional[str] = None,
    ) -> Dict[str, Any]:
        """Update an existing log parsing rule"""
    
        # Build the update fields
        rule_fields = []
        if description is not None:
            rule_fields.append(f'description: "{description}"')
        if enabled is not None:
            rule_fields.append(f"enabled: {str(enabled).lower()}")
        if grok is not None:
            # grok_escaped = grok.replace("\\", "\\\\")
            rule_fields.append(f'grok: "{grok}"')
        if lucene is not None:
            rule_fields.append(f'lucene: "{lucene}"')
        if nrql is not None:
            rule_fields.append(f'nrql: "{nrql}"')
    
        rule_object = "{ " + ", ".join(rule_fields) + " }"
    
        mutation = f"""
        mutation {{
            logConfigurationsUpdateParsingRule(
                accountId: {int(account_id)},
                id: "{rule_id}",
                rule: {rule_object}
            ) {{
                rule {{
                    id
                    description
                    enabled
                    grok
                    lucene
                    nrql
                    updatedAt
                }}
                errors {{
                    message
                    type
                }}
            }}
        }}
        """
    
        result = await client.nerdgraph_query(mutation)
    
        if result and "data" in result:
            update_result = result["data"].get("logConfigurationsUpdateParsingRule", {})
            if update_result.get("errors"):
                raise Exception(f"Failed to update rule: {update_result['errors']}")
            return update_result.get("rule", {})
    
        raise Exception("Failed to update parsing rule")
Behavior1/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers none. It doesn't indicate whether this is a read-only or destructive operation, what permissions are required, whether changes are reversible, what happens to unspecified fields, or what the output contains. For a mutation tool with 7 parameters, this lack of behavioral context is critically inadequate.

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, direct sentence with zero wasted words. It's appropriately front-loaded and efficiently communicates the core action, though this brevity comes at the cost of completeness. Every word earns its place by stating the essential function without fluff.

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

Completeness2/5

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

Given the tool's complexity (7 parameters, mutation operation, no annotations) and the presence of an output schema, the description is severely incomplete. While the output schema may cover return values, the description fails to address behavioral traits, parameter meanings, or usage guidelines. For a tool that modifies log parsing rules—a potentially impactful operation—this leaves too many gaps for reliable agent use.

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 all 7 parameters lack documentation in the schema. The description provides no information about any parameters—not even the required 'rule_id' or what fields like 'grok', 'nrql', or 'lucene' represent. This forces the agent to guess parameter meanings, which is unacceptable for a tool with this complexity.

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 'Update an existing log parsing rule' is a tautology that restates the tool name with minimal elaboration. It specifies the verb ('update') and resource ('log parsing rule') but lacks specificity about what aspects can be updated or how this differs from sibling tools like 'create_log_parsing_rule' or 'delete_log_parsing_rule'. This provides only basic purpose information without meaningful differentiation.

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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites (e.g., needing an existing rule ID), compare it to sibling tools like 'create_log_parsing_rule' or 'test_log_parsing_rule', or indicate appropriate contexts. The agent must infer usage from the tool name alone, which is insufficient for informed 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