UNPKG

mcp-use

Version:

Opinionated MCP Framework for TypeScript (@modelcontextprotocol/sdk compatible) - Build MCP Agents, Clients and Servers with support for ChatGPT Apps, Code Mode, OAuth, Notifications, Sampling, Observability and more.

79 lines 2.79 kB
import type { BaseCallbackHandler } from "@langchain/core/callbacks/base"; import type { StructuredToolInterface } from "@langchain/core/tools"; import type { AIMessage, HumanMessage, ToolMessage, SystemMessage } from "langchain"; import type { LangChainAdapter } from "../adapters/langchain_adapter.js"; import type { MCPClient } from "../client.js"; import type { BaseConnector } from "../connectors/base.js"; import type { ServerManager } from "../managers/server_manager.js"; import type { LLMConfig } from "./utils/llm_provider.js"; export type BaseMessage = AIMessage | HumanMessage | ToolMessage | SystemMessage; /** * Language model type that accepts any LangChain chat model. * Any is used to avoid TypeScript structural typing issues with protected properties until langchain fixes the issue. */ export type LanguageModel = any; /** * Configuration for MCP servers in simplified mode */ export interface MCPServerConfig { command?: string; args?: string[]; env?: Record<string, string>; url?: string; headers?: Record<string, string>; auth_token?: string; authToken?: string; transport?: "http" | "sse"; preferSse?: boolean; } /** * Common options shared between both explicit and simplified modes */ interface CommonAgentOptions { maxSteps?: number; autoInitialize?: boolean; memoryEnabled?: boolean; systemPrompt?: string | null; systemPromptTemplate?: string | null; additionalInstructions?: string | null; disallowedTools?: string[]; additionalTools?: StructuredToolInterface[]; toolsUsedNames?: string[]; useServerManager?: boolean; verbose?: boolean; observe?: boolean; adapter?: LangChainAdapter; serverManagerFactory?: (client: MCPClient) => ServerManager; callbacks?: BaseCallbackHandler[]; agentId?: string; apiKey?: string; baseUrl?: string; } /** * Explicit mode: User provides pre-instantiated LLM and client/connectors * This is the traditional initialization pattern with full control */ export interface ExplicitModeOptions extends CommonAgentOptions { llm: LanguageModel; client?: MCPClient; connectors?: BaseConnector[]; mcpServers?: never; llmConfig?: never; } /** * Simplified mode: User provides LLM string and mcpServers config * The agent handles client creation and LLM instantiation internally */ export interface SimplifiedModeOptions extends CommonAgentOptions { llm: string; llmConfig?: LLMConfig; mcpServers: Record<string, MCPServerConfig>; client?: never; connectors?: never; } /** * MCPAgent constructor options - supports both explicit and simplified modes */ export type MCPAgentOptions = ExplicitModeOptions | SimplifiedModeOptions; export {}; //# sourceMappingURL=types.d.ts.map