Core Concepts

Tools

Tools are Python functions decorated with @tool that give agents the ability to take actions - querying APIs, running commands, fetching data, or interacting with external systems.

Basic tool:

from ncp import tool

@tool
def ping_device(ip_address: str, timeout: int = 5) -> dict:
    """Ping a network device and return the result."""
    ...

Async tool:

@tool
async def backup_device_config(device_ip: str, backup_type: str = "running") -> dict:
    """Asynchronously back up a device configuration."""
    ...

Best practices:

  • Always provide a clear docstring - the LLM uses it to decide when to call the tool

  • Use type hints for all parameters

  • Return structured data (dict or list) where possible

  • Handle errors gracefully within the tool

Agents

Agents combine an LLM with a set of tools to handle tasks autonomously. They are configured with a name, description, instructions, and a list of tools.

LLM configuration:

Project Structure

Every NCP SDK agent follows a standard project layout:

Last updated