*   [](/v0.2/)
*   [How-to guides](/v0.2/docs/how_to/)
*   How to use LangChain tools

On this page

How to use LangChain tools
==========================

Tools are interfaces that an agent, chain, or LLM can use to interact with the world. They combine a few things:

1.  The name of the tool
2.  A description of what the tool is
3.  JSON schema of what the inputs to the tool are
4.  The function to call
5.  Whether the result of a tool should be returned directly to the user

It is useful to have all this information because this information can be used to build action-taking systems! The name, description, and schema can be used to prompt the LLM so it knows how to specify what action to take, and then the function to call is equivalent to taking that action.

The simpler the input to a tool is, the easier it is for an LLM to be able to use it. Many agents will only work with tools that have a single string input. For a list of agent types and which ones work with more complicated inputs, please see [this documentation](https://js.langchain.com/v0.1/docs/modules/agents/agent_types/)

Importantly, the name, description, and schema (if used) are all used in the prompt. Therefore, it is vitally important that they are clear and describe exactly how the tool should be used.

Default Tools[​](#default-tools "Direct link to Default Tools")
---------------------------------------------------------------

Let’s take a look at how to work with tools. To do this, we’ll work with a built in tool.

    import { WikipediaQueryRun } from "@langchain/community/tools/wikipedia_query_run";const tool = new WikipediaQueryRun({  topKResults: 1,  maxDocContentLength: 100,});

This is the default name:

    tool.name;

    "wikipedia-api"

This is the default description:

    tool.description;

    "A tool for interacting with and fetching data from the Wikipedia API."

This is the default schema of the inputs. This is a [Zod](https://zod.dev) schema on the tool class. We convert it to JSON schema for display purposes:

    import { zodToJsonSchema } from "zod-to-json-schema";zodToJsonSchema(tool.schema);

    {  type: "object",  properties: { input: { type: "string" } },  additionalProperties: false,  "$schema": "http://json-schema.org/draft-07/schema#"}

We can see if the tool should return directly to the user

    tool.returnDirect;

    false

We can invoke this tool with an object input:

    await tool.invoke({ input: "langchain" });

    "Page: LangChain\n" +  "Summary: LangChain is a framework designed to simplify the creation of applications "

We can also invoke this tool with a single string input. We can do this because this tool expects only a single input. If it required multiple inputs, we would not be able to do that.

    await tool.invoke("langchain");

    "Page: LangChain\n" +  "Summary: LangChain is a framework designed to simplify the creation of applications "

How to use built-in toolkits[​](#how-to-use-built-in-toolkits "Direct link to How to use built-in toolkits")
------------------------------------------------------------------------------------------------------------

Toolkits are collections of tools that are designed to be used together for specific tasks. They have convenient loading methods.

For a complete list of available ready-made toolkits, visit [Integrations](/v0.2/docs/integrations/toolkits/).

All Toolkits expose a `getTools()` method which returns a list of tools.

You’re usually meant to use them this way:

    // Initialize a toolkitconst toolkit = new ExampleTookit(...);// Get list of toolsconst tools = toolkit.getTools();

More Topics[​](#more-topics "Direct link to More Topics")
---------------------------------------------------------

This was a quick introduction to tools in LangChain, but there is a lot more to learn

**[Built-In Tools](/v0.2/docs/integrations/tools/)**: For a list of all built-in tools, see [this page](/v0.2/docs/integrations/tools/)

**[Custom Tools](/v0.2/docs/how_to/custom_tools)**: Although built-in tools are useful, it’s highly likely that you’ll have to define your own tools. See [this guide](/v0.2/docs/how_to/custom_tools) for instructions on how to do so.

* * *

#### Was this page helpful?

  

#### You can also leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

How to pass run time values to a tool

](/v0.2/docs/how_to/tool_runtime)[

Next

How to trim messages

](/v0.2/docs/how_to/trim_messages)

*   [Default Tools](#default-tools)
*   [How to use built-in toolkits](#how-to-use-built-in-toolkits)
*   [More Topics](#more-topics)