LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangChain
  • Browser
  • Universal
  • Hub
  • Node
  • Load
  • Serializable
  • Encoder Backed
  • File System
  • In Memory
LangChain Core
  • Agents
  • Caches
  • Base
  • Dispatch
  • Web
  • Manager
  • Promises
  • Chat History
  • Context
  • Base
  • Langsmith
  • Documents
  • Embeddings
  • Errors
  • Example Selectors
  • Indexing
  • Base
  • Chat Models
  • Llms
  • Profile
  • Structured Output
  • Load
  • Serializable
  • Memory
  • Messages
  • Tool
  • Output Parsers
  • Openai Functions
  • Openai Tools
  • Outputs
  • Prompt Values
  • Prompts
  • Retrievers
  • Document Compressors
  • Runnables
  • Graph
  • Singletons
  • Stores
  • Structured Query
  • Testing
  • Tools
  • Base
  • Console
  • Log Stream
  • Run Collector
  • Tracer Langchain
  • Stream
  • Async Caller
  • Chunk Array
  • Context
  • Env
  • Event Source Parse
  • Format
  • Function Calling
  • Hash
  • Json Patch
  • Json Schema
  • Math
  • Ssrf
  • Standard Schema
  • Stream
  • Testing
  • Tiktoken
  • Types
  • Vectorstores
Text Splitters
MCP Adapters
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangChain
BrowserUniversalHubNodeLoadSerializableEncoder BackedFile SystemIn Memory
LangChain Core
AgentsCachesBaseDispatchWebManagerPromisesChat HistoryContextBaseLangsmithDocumentsEmbeddingsErrorsExample SelectorsIndexingBaseChat ModelsLlmsProfileStructured OutputLoadSerializableMemoryMessagesToolOutput ParsersOpenai FunctionsOpenai ToolsOutputsPrompt ValuesPromptsRetrieversDocument CompressorsRunnablesGraphSingletonsStoresStructured QueryTestingToolsBaseConsoleLog StreamRun CollectorTracer LangchainStreamAsync CallerChunk ArrayContextEnvEvent Source ParseFormatFunction CallingHashJson PatchJson SchemaMathSsrfStandard SchemaStreamTestingTiktokenTypesVectorstores
Text Splitters
MCP Adapters
Language
Theme
JavaScript@langchain/coretools
Module●Since v0.3

tools

Copy
import { ... } from "@langchain/core/tools";

Used in Docs

  • Anthropic integration
  • OpenAI integration

Functions

Classes

Interfaces

Type Aliases

View source on GitHub
function
isLangChainTool→ tool is StructuredToolParams
function
isRunnableToolLike→ tool is RunnableToolLike<InteropZodType, unknown>
function
isStructuredTool→ tool is StructuredToolInterface<ToolSchemaBase, any, any>
function
isStructuredToolParams→ tool is StructuredToolParams
function
tool→ DynamicTool<InferToolOutputFromFunc<FuncT>, InferToolEventFromFunc<FuncT>>
class
BaseToolkit
class
DynamicStructuredTool
class
DynamicTool
class
StructuredTool
class
Tool
class
ToolInputParsingException
interface
BaseDynamicToolInput
interface
DynamicStructuredToolInput
interface
DynamicToolInput
interface
StructuredToolInterface
interface
StructuredToolParams
interface
ToolInterface
interface
ToolParams
typeAlias
ClientTool: StructuredToolInterface | DynamicTool | RunnableToolLike
typeAlias
ContentAndArtifact: [MessageContent, any]
typeAlias
ResponseFormat: "content" | "content_and_artifact" | string
typeAlias
ServerTool: Record<string, unknown>
typeAlias
StructuredToolCallInput: ToolInputSchemaOutputType<SchemaT> extends string ? string : never | SchemaInputT | ToolCall
typeAlias
ToolReturnType: TOutput extends DirectToolOutput ? TOutput : TConfig extends __type ? ToolMessage : TConfig extends __type ? TOutput : TConfig extends __type ? TOutput | ToolMessage : TInput extends ToolCall ? ToolMessage : TOutput
typeAlias
ToolRunnableConfig: RunnableConfig<ConfigurableFieldType> & __type
typeAlias
ToolRuntime: RunnableConfig & __type
typeAlias
ToolSchemaBase: ZodV3Like<any, any> | JsonSchema7Type

Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams. It returns is StructuredToolParams since that is the most minimal interface of the three, while still containing the necessary properties to be passed to a LLM for tool calling.

Confirm whether the inputted tool is an instance of RunnableToolLike.

Confirm whether the inputted tool is an instance of StructuredToolInterface.

Confirm whether or not the tool contains the necessary properties to be considered a StructuredToolParams.

Creates a new StructuredTool instance with the provided function, name, description, and schema.

Schema can be provided as Zod or JSON schema, and both will be validated.

Abstract base class for toolkits in LangChain. Toolkits are collections of tools that agents can use. Subclasses must implement the tools property to provide the specific tools for the toolkit.

A tool that can be created dynamically from a function, name, and description, designed to work with structured data. It extends the StructuredTool class and overrides the _call method to execute the provided function when the tool is called.

Schema can be passed as Zod or JSON schema. The tool will not validate input if JSON schema is passed.

A tool that can be created dynamically from a function, name, and description.

Base class for Tools that accept input of any shape defined by a Zod schema.

Base class for Tools that accept input as a string.

Custom error class used to handle exceptions related to tool input parsing. It extends the built-in Error class and adds an optional output property that can hold the output that caused the exception.

Base interface for the input parameters of the DynamicTool and DynamicStructuredTool classes.

Interface for the input parameters of the DynamicStructuredTool class.

Interface for the input parameters of the DynamicTool class.

Interface that defines the shape of a LangChain structured tool.

A structured tool is a tool that uses a schema to define the structure of the arguments that the LLM generates as part of its ToolCall.

Schema for defining tools.

A special interface for tools that accept a string input, usually defined with the Tool class.

Parameters for the Tool classes.

Defines the type that will be passed into a tool handler function as a result of a tool call.

Conditional type that determines the return type of the StructuredTool.invoke method.

  • If the input is a ToolCall, it returns a ToolMessage
  • If the config is a runnable config and contains a toolCall property, it returns a ToolMessage
  • Otherwise, it returns the original output type

Runtime context automatically injected into tools.

When a tool function has a parameter named tool_runtime with type hint ToolRuntime, the tool execution system will automatically inject an instance containing:

  • state: The current graph state
  • toolCallId: The ID of the current tool call
  • config: RunnableConfig for the current execution
  • context: Runtime context
  • store: BaseStore instance for persistent storage
  • writer: Stream writer for streaming output

No Annotated wrapper is needed - just use runtime: ToolRuntime as a parameter.

Base type that establishes the types of input schemas that can be used for LangChain tool definitions.