Skip to main content
Glama
jseifeddine

NetBox MCP Server

by jseifeddine

netbox_get_changelogs

Retrieve object change records from NetBox using filters to track modifications by user, object type, action, or time period for audit and monitoring purposes.

Instructions

Get object change records (changelogs) from NetBox based on filters.

Args: filters: dict of filters to apply to the API call based on the NetBox API filtering options

Returns: List of changelog objects matching the specified filters

Filtering options include:

  • user_id: Filter by user ID who made the change

  • user: Filter by username who made the change

  • changed_object_type_id: Filter by ContentType ID of the changed object

  • changed_object_id: Filter by ID of the changed object

  • object_repr: Filter by object representation (usually contains object name)

  • action: Filter by action type (created, updated, deleted)

  • time_before: Filter for changes made before a given time (ISO 8601 format)

  • time_after: Filter for changes made after a given time (ISO 8601 format)

  • q: Search term to filter by object representation

Example: To find all changes made to a specific device with ID 123: {"changed_object_type_id": "dcim.device", "changed_object_id": 123}

To find all deletions in the last 24 hours: {"action": "delete", "time_after": "2023-01-01T00:00:00Z"}

Each changelog entry contains:

  • id: The unique identifier of the changelog entry

  • user: The user who made the change

  • user_name: The username of the user who made the change

  • request_id: The unique identifier of the request that made the change

  • action: The type of action performed (created, updated, deleted)

  • changed_object_type: The type of object that was changed

  • changed_object_id: The ID of the object that was changed

  • object_repr: String representation of the changed object

  • object_data: The object's data after the change (null for deletions)

  • object_data_v2: Enhanced data representation

  • prechange_data: The object's data before the change (null for creations)

  • postchange_data: The object's data after the change (null for deletions)

  • time: The timestamp when the change was made

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filtersYes

Implementation Reference

  • MCP tool handler function that implements the netbox_get_changelogs tool by querying the NetBox 'core/object-changes' API endpoint with the provided filters dictionary.
    @mcp.tool() def netbox_get_changelogs(filters: dict): """ Get object change records (changelogs) from NetBox based on filters. Args: filters: dict of filters to apply to the API call based on the NetBox API filtering options Returns: List of changelog objects matching the specified filters Filtering options include: - user_id: Filter by user ID who made the change - user: Filter by username who made the change - changed_object_type_id: Filter by ContentType ID of the changed object - changed_object_id: Filter by ID of the changed object - object_repr: Filter by object representation (usually contains object name) - action: Filter by action type (created, updated, deleted) - time_before: Filter for changes made before a given time (ISO 8601 format) - time_after: Filter for changes made after a given time (ISO 8601 format) - q: Search term to filter by object representation Example: To find all changes made to a specific device with ID 123: {"changed_object_type_id": "dcim.device", "changed_object_id": 123} To find all deletions in the last 24 hours: {"action": "delete", "time_after": "2023-01-01T00:00:00Z"} Each changelog entry contains: - id: The unique identifier of the changelog entry - user: The user who made the change - user_name: The username of the user who made the change - request_id: The unique identifier of the request that made the change - action: The type of action performed (created, updated, deleted) - changed_object_type: The type of object that was changed - changed_object_id: The ID of the object that was changed - object_repr: String representation of the changed object - object_data: The object's data after the change (null for deletions) - object_data_v2: Enhanced data representation - prechange_data: The object's data before the change (null for creations) - postchange_data: The object's data after the change (null for deletions) - time: The timestamp when the change was made """ endpoint = "core/object-changes" # Make API call return netbox.get(endpoint, params=filters)
  • OpenAI tool calling schema definition for netbox_get_changelogs used by the LLM chatbot to invoke the tool, specifying 'filters' as an object parameter.
    "function": { "name": "netbox_get_changelogs", "description": "Get object change records (changelogs) from NetBox based on filters. Use this to see audit trails and recent changes.", "parameters": { "type": "object", "properties": { "filters": { "type": "object", "description": "Filters to apply to the API call. Common filters include 'limit', 'time_after', 'time_before', 'action', 'user', 'changed_object_id'" } }, "required": [] } }
  • Helper logic in the LLM chatbot's fallback tool selection that automatically invokes netbox_get_changelogs with a default limit=10 filter when user input contains keywords like 'change' or 'log'.
    elif any(word in user_input.lower() for word in ['change', 'log']): tool_name = "netbox_get_changelogs" arguments = {"filters": {"limit": 10}}
  • Helper function to format the response text specifically for netbox_get_changelogs tool results in the LLM chatbot.
    elif tool_name == "netbox_get_changelogs": response_text += f"I found {len(tool_result)} recent changes in your NetBox instance."
  • server.py:229-229 (registration)
    MCP decorator that registers the netbox_get_changelogs function as a tool in the FastMCP server.
    @mcp.tool()

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/jseifeddine/netbox-mcp-chatbot'

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