UNPKG

mcp-use

Version:

A utility library for integrating Model Context Protocol (MCP) with LangChain, Zod, and related tools. Provides helpers for schema conversion, event streaming, and SDK usage.

36 lines (35 loc) 1.37 kB
import * as fs from 'node:fs'; import * as path from 'node:path'; export function getPackageVersion() { try { const packagePath = path.join(__dirname, '../../package.json'); const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf-8')); return packageJson.version || 'unknown'; } catch { return 'unknown'; } } export function getModelProvider(llm) { // Use LangChain's standard _llm_type property for identification return llm._llm_type || llm.constructor.name.toLowerCase(); } export function getModelName(llm) { // First try _identifying_params which may contain model info if ('_identifyingParams' in llm) { const identifyingParams = llm._identifyingParams; if (typeof identifyingParams === 'object' && identifyingParams !== null) { // Common keys that contain model names for (const key of ['model', 'modelName', 'model_name', 'modelId', 'model_id', 'deploymentName', 'deployment_name']) { if (key in identifyingParams) { return String(identifyingParams[key]); } } } } // Fallback to direct model attributes return llm.model || llm.modelName || llm.constructor.name; } export function extractModelInfo(llm) { return [getModelProvider(llm), getModelName(llm)]; }