import type { ZodSchema } from "zod"; import { parseLLMStringToProviderConfig, providerConfigFromOptions } from "../llm/provider_config.js"; import type { LlmStreamEvent, ProviderConfig, ProviderMessage, ProviderName, TokenUsage } from "../llm/types.js"; import type { MCPAgentOptions } from "./agent_options.js"; import type { RunOptions } from "./run_options.js"; export type { ProviderName, ProviderConfig, ProviderMessage, LlmStreamEvent, TokenUsage, }; export type { MCPAgentOptions, McpConnectionLike, McpServersInput, } from "./agent_options.js"; export type { RunOptions } from "./run_options.js"; /** Tool invocation details in an {@link AgentStep}. */ export interface AgentAction { /** Tool name exposed to the model. */ tool: string; /** Arguments generated by the model. */ toolInput: Record; /** Model log associated with the action. */ log: string; } /** A completed MCP tool invocation yielded by {@link MCPAgent.stream}. */ export interface AgentStep { /** Tool invocation requested by the model. */ action: AgentAction; /** Serialized result returned by the tool. */ observation: string; } /** Runs provider-neutral LLM tool loops against one or more MCP servers. */ export declare class MCPAgent { /** @returns The installed `@mcp-use/agent` package version. */ static getPackageVersion(): string; private driver?; private client?; private connectors; private clientOwnedByAgent; private nativeAdapter; private providerTools; private callTool?; private maxSteps; private autoInitialize; private systemPrompt; private disallowedTools; private exposeResourcesAsTools; private exposePromptsAsTools; private initialized; private isRemote; private remoteAgent; private isSimplifiedMode; private llmString?; private llmConfig?; private mcpServersConfig?; private explicitProviderConfig?; private conversationMessages; private memoryEnabled; private boundConnections?; /** * Creates an MCP agent. * * Call {@link initialize} before the first local run unless * `autoInitialize` is enabled. Setting `agentId` creates a remote agent. * * @param options - Model, MCP connection, and execution settings. * @throws Error if local execution has no MCP servers, client, or connectors. */ constructor(options: MCPAgentOptions); private resolveMcpServers; private hasLiveConnections; /** * Resolves the model configuration, connects MCP servers, and loads tools. * * Calling this method more than once has no effect until {@link close}. * * @throws Error if the model configuration is incomplete or no driver can * be created. */ initialize(): Promise; private loadTools; private bindConnections; private buildMessages; /** * @returns A shallow copy of stored provider-neutral conversation history. */ getConversationHistory(): ProviderMessage[]; /** Removes all stored user and assistant messages. */ clearConversationHistory(): void; /** * Replaces the system instruction used by subsequent runs. * * @param message - New system instruction. */ setSystemMessage(message: string): void; private ensureReady; private nativeRunParams; /** * Runs the agent and resolves with the final assistant text. * * @param options - Input and per-run execution settings. * @returns Final assistant text. */ run(options: RunOptions): Promise; run(options: RunOptions): Promise; /** @deprecated Use `run({ prompt, maxSteps, ... })`. */ run(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: unknown, outputSchema?: undefined, signal?: AbortSignal): Promise; /** @deprecated Use `run({ prompt, schema, maxSteps, ... })`. */ run(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: unknown, outputSchema?: ZodSchema, signal?: AbortSignal): Promise; /** * Runs the agent, yielding each completed tool step. * * The generator's return value is the final assistant text. * * @param options - Input and per-run execution settings. * @returns An async generator of completed tool steps. */ stream(options: RunOptions): AsyncGenerator; stream(options: RunOptions): AsyncGenerator; /** @deprecated Use `stream({ prompt, maxSteps, ... })`. */ stream(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: unknown, outputSchema?: ZodSchema, signal?: AbortSignal): AsyncGenerator; /** * Runs the agent and yields provider-neutral token, tool, usage, and * lifecycle events. * * @param options - Input and per-run execution settings. * @returns An async generator of low-level stream events. * @throws Error for remote agents, which do not support event streaming. */ streamEvents(options: RunOptions): AsyncGenerator; streamEvents(options: RunOptions): AsyncGenerator; /** @deprecated Use `streamEvents({ prompt, maxSteps, ... })`. */ streamEvents(query: string, maxSteps?: number, manageConnector?: boolean, externalHistory?: unknown, outputSchema?: ZodSchema, signal?: AbortSignal): AsyncGenerator; /** * Runs a single model completion without MCP tools. * * @param options - Provider-neutral messages and optional cancellation * signal. * @returns Final assistant text. */ chat(options: { messages: ProviderMessage[]; signal?: AbortSignal; }): Promise; /** * Closes MCP sessions created by this agent and resets initialization state. * * Existing clients supplied by the caller remain open. */ close(): Promise; } /** Serializable model configuration used by inspector and configuration UIs. */ export interface LLMConfig { /** Provider implementation. */ provider: ProviderName; /** Provider-specific model identifier. */ model: string; /** Provider API key. */ apiKey: string; /** Sampling temperature. */ temperature?: number; /** Provider API base URL override. */ baseUrl?: string; } export { providerConfigFromOptions, parseLLMStringToProviderConfig }; export { convertMessagesToProvider } from "../llm/messageFormat.js"; //# sourceMappingURL=mcp_agent.d.ts.map