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
  • Tools
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 MemoryTools
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/coretoolstool
Functionā—Since v0.3

tool

Copy
tool<
  SchemaT extends ZodStringV3,
  ToolOutputT = any,
  FuncT extends RunnableFunc<InferInteropZodOutput

Used in Docs

  • Agent Client Protocol (ACP)
  • Agents
  • Build a custom SQL agent
  • Build a multi-source knowledge base with routing
  • Build a personal assistant with subagents
(35 more not shown)
View source on GitHub
<
SchemaT
>
,
ToolOutputT
,
ToolRunnableConfig
>
=
RunnableFunc
<
InferInteropZodOutput
<
SchemaT
>
,
ToolOutputT
,
ToolRunnableConfig
>
>
(
func
:
FuncT
,
fields
:
ToolWrapperParams
<
SchemaT
>
)
:
DynamicTool
<
InferToolOutputFromFunc
<
FuncT
>
,
InferToolEventFromFunc
<
FuncT
>
>

Parameters

NameTypeDescription
func*FuncT
fields*ToolWrapperParams<SchemaT>

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.

The function to invoke when the tool is called.

An object containing the following properties: