Skip to main content
Glama
jseifeddine

NetBox MCP Server

by jseifeddine

netbox_get_object_by_id

Retrieve detailed information about a specific network infrastructure object from NetBox by providing its object type and numeric ID.

Instructions

Get detailed information about a specific NetBox object by its ID.

Args: object_type: String representing the NetBox object type (e.g. "devices", "ip-addresses") object_id: The numeric ID of the object

Returns: Complete object details

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_typeYes
object_idYes

Implementation Reference

  • The main handler function for netbox_get_object_by_id, decorated with @mcp.tool() for registration and execution. It validates the object_type, constructs the API endpoint, and fetches the object details from NetBox.
    @mcp.tool()
    def netbox_get_object_by_id(object_type: str, object_id: int):
        """
        Get detailed information about a specific NetBox object by its ID.
        
        Args:
            object_type: String representing the NetBox object type (e.g. "devices", "ip-addresses")
            object_id: The numeric ID of the object
        
        Returns:
            Complete object details
        """
        # Validate object_type exists in mapping
        if object_type not in NETBOX_OBJECT_TYPES:
            valid_types = "\n".join(f"- {t}" for t in sorted(NETBOX_OBJECT_TYPES.keys()))
            raise ValueError(f"Invalid object_type. Must be one of:\n{valid_types}")
            
        # Get API endpoint from mapping
        endpoint = f"{NETBOX_OBJECT_TYPES[object_type]}/{object_id}"
        
        return netbox.get(endpoint)
  • Input schema definition for the netbox_get_object_by_id tool used in the LLM chatbot's tool calling configuration.
        "type": "function",
        "function": {
            "name": "netbox_get_object_by_id",
            "description": "Get detailed information about a specific NetBox object by its ID.",
            "parameters": {
                "type": "object",
                "properties": {
                    "object_type": {
                        "type": "string",
                        "description": "Type of NetBox object"
                    },
                    "object_id": {
                        "type": "integer",
                        "description": "The numeric ID of the object"
                    }
                },
                "required": ["object_type", "object_id"]
            }
        }
    },
  • Global mapping of NetBox object types to their corresponding API endpoints, used by the netbox_get_object_by_id handler to construct the correct API URL.
    # Mapping of simple object names to API endpoints
    NETBOX_OBJECT_TYPES = {
        # DCIM (Device and Infrastructure)
        "cables": "dcim/cables",
        "console-ports": "dcim/console-ports", 
        "console-server-ports": "dcim/console-server-ports",
        "devices": "dcim/devices",
        "device-bays": "dcim/device-bays",
        "device-roles": "dcim/device-roles",
        "device-types": "dcim/device-types",
        "front-ports": "dcim/front-ports",
        "interfaces": "dcim/interfaces",
        "inventory-items": "dcim/inventory-items",
        "locations": "dcim/locations",
        "manufacturers": "dcim/manufacturers",
        "modules": "dcim/modules",
        "module-bays": "dcim/module-bays",
        "module-types": "dcim/module-types",
        "platforms": "dcim/platforms",
        "power-feeds": "dcim/power-feeds",
        "power-outlets": "dcim/power-outlets",
        "power-panels": "dcim/power-panels",
        "power-ports": "dcim/power-ports",
        "racks": "dcim/racks",
        "rack-reservations": "dcim/rack-reservations",
        "rack-roles": "dcim/rack-roles",
        "regions": "dcim/regions",
        "sites": "dcim/sites",
        "site-groups": "dcim/site-groups",
        "virtual-chassis": "dcim/virtual-chassis",
        
        # IPAM (IP Address Management)
        "asns": "ipam/asns",
        "asn-ranges": "ipam/asn-ranges", 
        "aggregates": "ipam/aggregates",
        "fhrp-groups": "ipam/fhrp-groups",
        "ip-addresses": "ipam/ip-addresses",
        "ip-ranges": "ipam/ip-ranges",
        "prefixes": "ipam/prefixes",
        "rirs": "ipam/rirs",
        "roles": "ipam/roles",
        "route-targets": "ipam/route-targets",
        "services": "ipam/services",
        "vlans": "ipam/vlans",
        "vlan-groups": "ipam/vlan-groups",
        "vrfs": "ipam/vrfs",
        
        # Circuits
        "circuits": "circuits/circuits",
        "circuit-types": "circuits/circuit-types",
        "circuit-terminations": "circuits/circuit-terminations",
        "providers": "circuits/providers",
        "provider-networks": "circuits/provider-networks",
        
        # Virtualization
        "clusters": "virtualization/clusters",
        "cluster-groups": "virtualization/cluster-groups",
        "cluster-types": "virtualization/cluster-types",
        "virtual-machines": "virtualization/virtual-machines",
        "vm-interfaces": "virtualization/interfaces",
        
        # Tenancy
        "tenants": "tenancy/tenants",
        "tenant-groups": "tenancy/tenant-groups",
        "contacts": "tenancy/contacts",
        "contact-groups": "tenancy/contact-groups",
        "contact-roles": "tenancy/contact-roles",
        
        # VPN
        "ike-policies": "vpn/ike-policies",
        "ike-proposals": "vpn/ike-proposals",
        "ipsec-policies": "vpn/ipsec-policies",
        "ipsec-profiles": "vpn/ipsec-profiles",
        "ipsec-proposals": "vpn/ipsec-proposals",
        "l2vpns": "vpn/l2vpns",
        "tunnels": "vpn/tunnels",
        "tunnel-groups": "vpn/tunnel-groups",
        
        # Wireless
        "wireless-lans": "wireless/wireless-lans",
        "wireless-lan-groups": "wireless/wireless-lan-groups",
        "wireless-links": "wireless/wireless-links",
    
        # Extras
        "config-contexts": "extras/config-contexts",
        "custom-fields": "extras/custom-fields",
        "export-templates": "extras/export-templates",
        "image-attachments": "extras/image-attachments",
        "jobs": "extras/jobs",
        "saved-filters": "extras/saved-filters",
        "scripts": "extras/scripts",
        "tags": "extras/tags",
        "webhooks": "extras/webhooks",
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • addedInput schema / title
      Added value: +"netbox_get_object_by_idArguments"
  2. First observed

TDQS

C2.9/5.0
Behavior2/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. It states this is a read operation ('Get'), implying it's non-destructive, but doesn't disclose behavioral traits like authentication requirements, rate limits, error handling, or what 'Complete object details' entails (e.g., format, depth). For a tool with no annotations, this leaves significant gaps in understanding how it behaves.

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?

The description is appropriately sized and front-loaded: the first sentence states the core purpose clearly. The 'Args' and 'Returns' sections are structured but slightly verbose for such a simple tool. Every sentence adds value, though it could be more concise by integrating the parameter details into the main text.

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

Completeness3/5

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

Given the tool's low complexity (2 parameters, no nested objects) but lack of annotations and output schema, the description is minimally adequate. It covers the basic what and how but misses context like error cases, performance, or integration with siblings. For a read-only tool, this is passable but leaves the agent to guess about behavioral nuances.

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

Parameters3/5

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

The description adds basic meaning for both parameters: 'object_type' is described as 'String representing the NetBox object type (e.g. "devices", "ip-addresses")' and 'object_id' as 'The numeric ID of the object.' With schema description coverage at 0%, this compensates somewhat by providing examples and clarifications. However, it doesn't detail constraints (e.g., valid object types, ID ranges) or advanced usage, keeping it at a baseline level.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Get detailed information about a specific NetBox object by its ID.' It specifies the verb ('Get'), resource ('NetBox object'), and key constraint ('by its ID'). However, it doesn't explicitly distinguish this from sibling tools like 'netbox_get_objects' (which likely lists objects rather than fetching a specific one).

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention sibling tools like 'netbox_get_objects' (for listing) or 'netbox_get_changelogs' (for history), nor does it specify prerequisites or contexts where this tool is preferred. The agent must infer usage from the name and description alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.