mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-31 00:10:22 +08:00
* Revert "feat: optimize minapp cache with LRU (#8160)"
This reverts commit f0043b4be5.
* feat: integrate logger service and enhance logging throughout the application
- Added a new LoggerService to standardize logging across the application.
- Replaced console.error and console.warn calls with logger methods for improved consistency and error tracking.
- Introduced a new IPC channel for logging messages to the main process.
- Updated various components and services to utilize the new logging system, enhancing error handling and debugging capabilities.
* refactor: enhance logging and error handling across various components
- Integrated the LoggerService for consistent logging throughout the application.
- Updated multiple components and services to utilize the new logging system, improving error tracking and debugging capabilities.
- Refactored file handling and error management in several services to enhance reliability and clarity.
- Improved the structure and readability of the codebase by removing redundant checks and simplifying logic.
* chore: update TypeScript configuration and enhance test setup
- Added test mock paths to tsconfig.web.json for improved test coverage.
- Configured Vitest to include a setup file for main tests, ensuring consistent test environment.
- Updated IPC logger context for better clarity in logging.
- Enhanced LoggerService to handle undefined values gracefully.
- Mocked LoggerService globally in renderer tests to streamline testing process.
* refactor: standardize logging across ProxyManager and ReduxService
- Replaced instances of Logger with logger for consistent logging implementation.
- Improved logging clarity in ProxyManager's configureProxy method and ReduxService's state handling.
- Enhanced error logging in ReduxService to align with the new logging system.
* refactor: reorganize LoggerService for improved clarity and consistency
- Moved the definition of SYSTEM_INFO, APP_VERSION, and DEFAULT_LEVEL to enhance code organization.
- Simplified the getIsDev function in the renderer LoggerService for better readability.
- Updated logging conditions to ensure messages are logged correctly based on context.
* docs: add usage instructions for LoggerService and clean up logging code
- Included important usage instructions for LoggerService in both English and Chinese.
- Commented out the console transport in LoggerService to streamline logging.
- Improved logging message formatting in MCPService for clarity.
- Removed redundant logging statements in SelectionService to enhance code cleanliness.
* refactor: update LoggerService documentation paths and enhance logging implementation
- Changed the documentation paths for LoggerService usage instructions to `docs/technical/how-to-use-logger-en.md` and `docs/technical/how-to-use-logger-zh.md`.
- Replaced console logging with the loggerService in various components, including `MCPSettings`, `BlockManager`, and multiple callback files, to ensure consistent logging practices across the application.
- Improved the clarity and context of log messages for better debugging and monitoring.
* docs: emphasize logger usage guidelines in documentation
- Added a note in both English and Chinese documentation to discourage the use of `console.xxx` for logging unless necessary, promoting consistent logging practices across the application.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { loggerService } from '@logger'
|
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js'
|
|
|
|
import BraveSearchServer from './brave-search'
|
|
import DifyKnowledgeServer from './dify-knowledge'
|
|
import FetchServer from './fetch'
|
|
import FileSystemServer from './filesystem'
|
|
import MemoryServer from './memory'
|
|
import PythonServer from './python'
|
|
import ThinkingServer from './sequentialthinking'
|
|
|
|
const logger = loggerService.withContext('MCPFactory')
|
|
|
|
export function createInMemoryMCPServer(name: string, args: string[] = [], envs: Record<string, string> = {}): Server {
|
|
logger.debug(`[MCP] Creating in-memory MCP server: ${name} with args: ${args} and envs: ${JSON.stringify(envs)}`)
|
|
switch (name) {
|
|
case '@cherry/memory': {
|
|
const envPath = envs.MEMORY_FILE_PATH
|
|
return new MemoryServer(envPath).server
|
|
}
|
|
case '@cherry/sequentialthinking': {
|
|
return new ThinkingServer().server
|
|
}
|
|
case '@cherry/brave-search': {
|
|
return new BraveSearchServer(envs.BRAVE_API_KEY).server
|
|
}
|
|
case '@cherry/fetch': {
|
|
return new FetchServer().server
|
|
}
|
|
case '@cherry/filesystem': {
|
|
return new FileSystemServer(args).server
|
|
}
|
|
case '@cherry/dify-knowledge': {
|
|
const difyKey = envs.DIFY_KEY
|
|
return new DifyKnowledgeServer(difyKey, args).server
|
|
}
|
|
case '@cherry/python': {
|
|
return new PythonServer().server
|
|
}
|
|
default:
|
|
throw new Error(`Unknown in-memory MCP server: ${name}`)
|
|
}
|
|
}
|