> ## Documentation Index
> Fetch the complete documentation index at: https://docs.seekr.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Tools

> Create and manage tools in the tool library.

Tools extend what agents can do. While models provide reasoning capabilities, tools allow agents to take actions—accessing external systems, querying knowledge stores, executing code, or performing web searches to accomplish tasks.

The tool library lets you create and manage tools independently of agents, then link them to any agent by tool ID.

## Tool types

| Type                                            | SDK class            | Description                                                                                                                        |
| ----------------------------------------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [File search](/flow/sdk/agents/filesearch-tool) | `CreateFileSearch`   | Semantic search and retrieval across vector databases                                                                              |
| [Web search](/flow/sdk/agents/websearch-tool)   | `CreateWebSearch`    | Real-time information retrieval from web sources                                                                                   |
| [Custom tools](/flow/sdk/agents/custom-tools)   | `CreateRunPython`    | Python code execution for data analysis and computations, with optional developer-defined functions for specialized business logic |
| [Agent as tool](/flow/sdk/agents/agent-as-tool) | `CreateAgentAsTool`  | Delegate subtasks to another agent and return the result to the supervisor                                                         |
| [MCP connector](/flow/sdk/agents/mcp-connector) | `CreateMCPConnector` | Connect to external MCP providers through a secure gateway                                                                         |

See the sub-pages for type-specific configuration and parameters.

## Create a tool

Create a tool in the library using `client.tools.create()`:

<CodeGroup>
  ```python Python theme={null}
  from seekrai import SeekrFlow
  from seekrai.types import CreateWebSearch

  client = SeekrFlow()

  tool = client.tools.create(
      CreateWebSearch(
          name="my_web_search",
          description="Search the web for information relevant to the user's query."
      )
  )
  print(f"Tool created: {tool.id}")
  ```
</CodeGroup>

For tools that require configuration, include a config object:

<CodeGroup>
  ```python Python theme={null}
  from seekrai.types import CreateFileSearch, FileSearchConfig

  tool = client.tools.create(
      CreateFileSearch(
          name="my_file_search",
          description="Search the knowledge base for relevant information.",
          config=FileSearchConfig(
              file_search_index="<vector-store-id>",
              top_k=10,
              score_threshold=0.5
          )
      )
  )
  ```
</CodeGroup>

## Retrieve a tool

<CodeGroup>
  ```python Python theme={null}
  tool = client.tools.retrieve("<tool-id>")
  print(tool.name, tool.type)
  ```
</CodeGroup>

## List tools

<CodeGroup>
  ```python Python theme={null}
  tools = client.tools.list()
  for tool in tools.data:
      print(f"{tool.name} ({tool.type}): {tool.id}")
  ```
</CodeGroup>

## Update a tool

Use `client.tools.update()` to make partial changes to a tool. Provide only the fields you want to change. Omitted fields remain unchanged.

**Endpoint:** `PATCH /v1/flow/tools/{tool_id}` [Update tool](/flow/reference/patch_tool_v1_flow_tools__tool_id__patch)

<CodeGroup>
  ```python Python theme={null}
  from seekrai.types import UpdateWebSearch

  updated_tool = client.tools.update(
      tool_id="<id-of-tool-to-update>",
      request=UpdateWebSearch(
          description="Updated description for web search."
      )
  )
  ```
</CodeGroup>

<Warning>
  Tool updates propagate immediately to all agents using the tool.
</Warning>

## Preview a tool update

Use `client.tools.update_diff()` to simulate an update without applying it. The response shows exactly what would change.

**Endpoint:** `PATCH /v1/flow/tools/{tool_id}/diff` [Preview tool update](/flow/reference/diff_tool_changes_v1_flow_tools__tool_id__diff_patch)

<CodeGroup>
  ```python Python theme={null}
  from seekrai.types import UpdateWebSearch

  diff = client.tools.update_diff(
      tool_id="<id-of-tool-to-update>",
      request=UpdateWebSearch(
          name="my_web_search_v2",
          description="Updated description for web search."
      )
  )
  print(diff)
  ```
</CodeGroup>

The response includes the complete before and after tool state, and a `diff` object identifying each changed field:

<CodeGroup>
  ```python Python theme={null}
  ToolDiffResponse(
      before=...,
      after=...,
      diff={
          "name": {
              "before": "my_web_search",
              "after": "my_web_search_v2"
          },
          "description": {
              "before": "Search the web for information.",
              "after": "Updated description for web search."
          }
      }
  )
  ```
</CodeGroup>

## Duplicate a tool

<CodeGroup>
  ```python Python theme={null}
  duplicate = client.tools.duplicate("<tool-id>", "my_duplicate_tool")
  ```
</CodeGroup>

## Delete a tool

<CodeGroup>
  ```python Python theme={null}
  result = client.tools.delete("<tool-id>")
  print(result.message)
  ```
</CodeGroup>

<Warning>
  You cannot delete a tool that is linked to an active agent. Demote or delete the agent first.
</Warning>

## List linked agents

Check which agents use a specific tool before updating or deleting it:

<CodeGroup>
  ```python Python theme={null}
  agents = client.tools.list_agents("<tool-id>")
  for agent in agents:
      print(f"{agent.name} ({agent.status}): {agent.id}")
  ```
</CodeGroup>

## Link tools to an agent

When creating or updating an agent, specify tool IDs in the `tool_ids` parameter:

<CodeGroup>
  ```python Python theme={null}
  from seekrai.types import CreateAgentRequest

  agent = client.agents.create(
      CreateAgentRequest(
          name="my_agent",
          instructions="You are a helpful assistant.",
          model_id="meta-llama/Llama-3.3-70B-Instruct",
          tool_ids=["<tool-id-1>", "<tool-id-2>"]
      )
  )
  ```
</CodeGroup>

For more on agent creation and management, see [Create and manage agents](/flow/sdk/agents/create-agents).
