Creates a LangChain MCP agent.
Model, MCP servers, tools, and execution settings.
Observability callbacks and trace lifecycle manager.
Names of tools invoked during the current or most recent execution.
Clears stored history, retaining the system message when memory is enabled.
Flushes observability, closes owned MCP resources, and resets the executor.
Flush observability traces to the configured observability platform. Important for serverless environments where traces need to be sent before function termination.
A shallow copy of the stored LangChain message history.
The configured MCP tool denylist.
Get current metadata
A copy of the current metadata object
The current LangChain system message, or null before creation.
Get current tags
A copy of the current tags array
Yields with pretty-printed output for code mode with options object.
Yields with pretty-printed output for code mode with options object and structured output.
Yields with pretty-printed output for code mode. This method formats and displays tool executions in a user-friendly way with syntax highlighting.
OptionalmaxSteps: numberOptionalmanageConnector: booleanOptionalexternalHistory: BaseMessage[]OptionaloutputSchema: ZodType<T, unknown, $ZodTypeInternals<T, unknown>>Runs the agent with options object and returns a promise for the final result.
Runs the agent with options object and structured output, returns a promise for the typed result.
Runs the agent and returns a promise for the final result.
OptionalmaxSteps: numberOptionalmanageConnector: booleanOptionalexternalHistory: BaseMessage[]OptionaloutputSchema: undefinedOptionalsignal: AbortSignalRuns the agent with structured output and returns a promise for the typed result.
OptionalmaxSteps: numberOptionalmanageConnector: booleanOptionalexternalHistory: BaseMessage[]OptionaloutputSchema: ZodType<T, unknown, $ZodTypeInternals<T, unknown>>Optionalsignal: AbortSignalReplaces the tool denylist for the next initialization.
MCP tool names to omit.
Set metadata for observability traces
Key-value pairs to add to metadata. Keys should be strings, values should be serializable.
Replaces the system instruction and rebuilds an initialized executor.
New system instruction.
Set tags for observability traces
Array of tag strings to add. Duplicates will be automatically removed.
Streams the agent execution with options object and returns string result.
Streams the agent execution with options object and structured output.
Streams the agent execution and yields agent steps.
OptionalmaxSteps: numberOptionalmanageConnector: booleanOptionalexternalHistory: BaseMessage[]OptionaloutputSchema: ZodType<T, unknown, $ZodTypeInternals<T, unknown>>Optionalsignal: AbortSignalYields LangChain StreamEvent objects with options object.
Yields LangChain StreamEvent objects with options object and structured output.
Yields LangChain StreamEvent objects from the underlying streamEvents() method. This provides token-level streaming and fine-grained event updates.
OptionalmaxSteps: numberOptionalmanageConnector: booleanOptionalexternalHistory: BaseMessage[]OptionaloutputSchema: ZodType<T, unknown, $ZodTypeInternals<T, unknown>>Optionalsignal: AbortSignalStaticgetGet the mcp-use package version. Works in all environments (Node.js, browser, Cloudflare Workers, Deno, etc.)
Runs a LangChain tool-calling agent against MCP servers.