add-tool

A command for adding a tool function to an existing LangGraph agent, a program that connects language-model steps into a workflow. It finds the agent file, inserts the function, and registers it with the agent.

In plain words
What is it for?
Use it to add a new callable operation to a LangGraph agent, such as a function that reads data, performs a task, or calls another service.
Why use it?
It avoids manually locating the right file and updating the separate tool-registration code that makes the new function available.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/codeblockz/langchain-community-plugin/add-tool
Clone the repo
git clone --depth 1 https://github.com/Codeblockz/langchain-community-plugin
Per session 13 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 721 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00013 $0.00721
Opus 5 $0.00006 $0.00360
Sonnet 5 $0.00003 $0.00144
Haiku 4.5 $0.00001 $0.00072

Measured yesterday against content hash 4a8e0b2c8209, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

add-tool scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/add-tool.md · 124 lines

How it starts

The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Add Tool Command

Add a new tool function to an existing LangGraph agent file.

Workflow

  1. Parse arguments:

    • First argument: tool name (required)
    • Second argument: file path (optional, will search for agent files)
  2. If no file specified, search for likely agent files:

    • agent.py, graph.py, main.py
    • Files containing StateGraph or create_agent
  3. Read the target file to understand its structure

  4. Ask user what the tool should do (unless obvious from name)

  5. Generate tool code following this pattern:

@tool
def tool_name(param1: str, param2: int = 10) -> str:
    """Brief description of what the tool does.

    Args:
        param1: Description of param1
        param2: Description of param2 (default: 10)
    """
    # Implementation
    return result
  1. Insert the tool in the appropriate location:

    • After existing tool definitions
    • Before the model/graph setup
  2. Update tool registration:

    • For create_agent: Add to tools=[...] list
    • For StateGraph: Add to tools = [...] and tools_by_name = {...}

Tool Template

@tool
def {tool_name}({parameters}) -> {return_type}:
    """{description}

    Args:
        {arg_docs}
    """
    {implementation}
    return {result}

Best Practices to Apply

  1. Always include docstring with Args section - LLMs use this
  2. Use type hints for all parameters and return value
  3. Keep tools focused - one clear purpose
  4. Return strings for simple tools (easier for LLM to process)
  5. Handle errors gracefully - return error messages, don't raise

Example Additions

API Tool

@tool
def fetch_weather(city: str) -> str:
    """Get current weather for a city.

    Args:
        city: City name (e.g., "San Francisco")
    """
    # TODO: Call weather API
    return f"Weather in {city}: Sunny, 72°F"

Database Tool

@tool
def query_database(sql: str) -> str:
    """Execute a read-only SQL query.

    Args:
        sql: SQL SELECT query to execute
    """
    # TODO: Implement with proper connection handling
    return "Query results..."

Read the full file on GitHub · 124 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 124 lines · 13 tokens per session scan A 4a8e0b2c8209

Subscribe to this mod's changes

add-tool is a command published in the GitHub repository Codeblockz/langchain-community-plugin (3 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 13 tokens to every session and 721 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.