Skip to main content
Glama
piekstra

New Relic MCP Server

by piekstra

delete_log_parsing_rule

Remove a log parsing rule from New Relic to stop processing logs according to specific patterns.

Instructions

Delete a log parsing rule

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
rule_idYes
account_idNo

Implementation Reference

  • MCP tool registration and handler for 'delete_log_parsing_rule'. Validates inputs, initializes client/account, calls core delete function from log_parsing module, and formats response as JSON.
    @mcp.tool()
    async def delete_log_parsing_rule(
        rule_id: str, account_id: Optional[str] = None
    ) -> str:
        """Delete a 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:
            success = await log_parsing.delete_log_parsing_rule(client, acct_id, rule_id)
            return json.dumps({"success": success}, indent=2)
        except Exception as e:
            return json.dumps({"error": str(e)}, indent=2)
  • Core handler function that executes the GraphQL mutation to delete the specified log parsing rule using the New Relic NerdGraph API.
    async def delete_log_parsing_rule(client, account_id: str, rule_id: str) -> bool:
        """Delete a log parsing rule"""
        mutation = f"""
        mutation {{
            logConfigurationsDeleteParsingRule(
                accountId: {int(account_id)},
                id: "{rule_id}"
            ) {{
                errors {{
                    message
                    type
                }}
            }}
        }}
        """
    
        result = await client.nerdgraph_query(mutation)
    
        if result and "data" in result:
            delete_result = result["data"].get("logConfigurationsDeleteParsingRule", {})
            if delete_result.get("errors"):
                raise Exception(f"Failed to delete rule: {delete_result['errors']}")
            return True
    
        return False

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