Get Tools and pass them to LangGraph Agent

The get_tools function in the Knit LangGraph SDK allows you to retrieve specific tools based on your filtering criteria. This guide explains how to use this function to fetch the exact tools you need for your LLM agent integrations.

After discovering tools using find_tools, use get_tools to fetch the actual tool definitions that will be passed to your LLM model. This function converts the tool summaries into usable tool objects that your LangGraph agents can interact with.

Get Tools for an App

Parameters Overview

  • tools: A list of ToolFilter objects that define which tools you want to retrieve. Each filter can specify:
    • app_id: The application ID to fetch tools from
    • tool_ids: A list of specific tool IDs to retrieve

The function returns a list of tool definitions that can be directly used with LangGraph agents. These are fully functional tool objects that your LLM can use to interact with external applications.

Example Usage

from knit_langgraph import KnitLangGraph, ToolFilter

# Initialize the Knit SDK with your API key
knit = KnitLangGraph(api_key="YOUR_KNIT_API_KEY")

# First, discover available tools
discovered_tools = knit.find_tools(app_id="charliehr")

# Create a filter to get specific tools
tool_filter = ToolFilter(
    app_id="charliehr",
    tool_ids=[tool.tool_id for tool in discovered_tools[:3]]  # Get the first 3 tools
)

# Get the actual tool definitions
tool_definitions = knit.get_tools(tools=[tool_filter])

# These tool definitions can now be passed to your LLM agent
# For example:
# graph = create_react_agent(model, tools=tool_definitions)

Get Unified Tools for a Category

Parameters Overview

  • tools: A list of ToolFilter objects that define which tools you want to retrieve. Each filter can specify:
    • category_id: A specific category of tools
    • tool_ids: A list of specific tool IDs to retrieve

The function returns a list of tool definitions that can be directly used with LangGraph or LangChain models. These are fully functional tool objects that your LLM can use to interact with external applications.

Example Usage

from knit_langgraph import KnitLangGraph, ToolFilter

# Initialize the Knit SDK with your API key
knit = KnitLangGraph(api_key="YOUR_KNIT_API_KEY")

# First, discover available tools
discovered_tools = knit.find_tools(category_id="ticketing", include_unified_tools=True)

# Create a filter to get specific tools
tool_filter = ToolFilter(
    category_id="ticketing",
    tool_ids=[tool.tool_id for tool in discovered_tools[:3]]  # Get the first 3 tools
)

# Get the actual tool definitions
tool_definitions = knit.get_tools(tools=[tool_filter])

# These tool definitions can now be passed to your LLM agent
# For example:
graph = create_react_agent(model, tools=tool_definitions)

Advanced Usage

Multiple Filters

You can combine tools from different applications - including combining app and unified tools by passing multiple filters:

# Get tools from multiple applications
salesforce_filter = ToolFilter(app_id="salesforce", tool_ids=["list_accounts", "get_contact"])
hubspot_filter = ToolFilter(app_id="hubspot", tool_ids=["create_deal"])
crm_filter = ToolFilter(category_id="crm", tool_ids=["list_accounts", "get_contact"])
ticketing_filter = ToolFilter(app_id="ticketing", tool_ids=["create_deal"])

# Combine tools from both applications
combined_tools = knit.get_tools(tools=[salesforce_filter, hubspot_filter, crm_filter, ticketing_filter])