bugfix(MCP): ensure memory path exists on initialization and remove unused… (#4418)
* bugfix: ensure memory path exists on initialization and remove unused everything mcp server * refactor(factory): remove unused EverythingServer import and case * fix(CodeCacheService): update import statement for LRUCache to default import Error: src/renderer/src/services/CodeCacheService.ts(2,10): error TS2595: 'LRUCache' can only be imported by using a default import.
This commit is contained in:
parent
ae6097a29e
commit
1085c11240
File diff suppressed because one or more lines are too long
@ -2,7 +2,6 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js'
|
|||||||
import Logger from 'electron-log'
|
import Logger from 'electron-log'
|
||||||
|
|
||||||
import BraveSearchServer from './brave-search'
|
import BraveSearchServer from './brave-search'
|
||||||
import EverythingServer from './everything'
|
|
||||||
import FetchServer from './fetch'
|
import FetchServer from './fetch'
|
||||||
import FileSystemServer from './filesystem'
|
import FileSystemServer from './filesystem'
|
||||||
import MemoryServer from './memory'
|
import MemoryServer from './memory'
|
||||||
@ -21,9 +20,6 @@ export function createInMemoryMCPServer(name: string, args: string[] = [], envs:
|
|||||||
case '@cherry/brave-search': {
|
case '@cherry/brave-search': {
|
||||||
return new BraveSearchServer(envs.BRAVE_API_KEY).server
|
return new BraveSearchServer(envs.BRAVE_API_KEY).server
|
||||||
}
|
}
|
||||||
case '@cherry/everything': {
|
|
||||||
return new EverythingServer().server
|
|
||||||
}
|
|
||||||
case '@cherry/fetch': {
|
case '@cherry/fetch': {
|
||||||
return new FetchServer().server
|
return new FetchServer().server
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,6 +33,25 @@ class KnowledgeGraphManager {
|
|||||||
|
|
||||||
constructor(memoryPath: string) {
|
constructor(memoryPath: string) {
|
||||||
this.memoryPath = memoryPath
|
this.memoryPath = memoryPath
|
||||||
|
this.ensureMemoryPathExists()
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ensureMemoryPathExists(): Promise<void> {
|
||||||
|
try {
|
||||||
|
// Ensure the directory exists
|
||||||
|
const directory = path.dirname(this.memoryPath)
|
||||||
|
await fs.mkdir(directory, { recursive: true })
|
||||||
|
|
||||||
|
// Check if the file exists, if not create an empty one
|
||||||
|
try {
|
||||||
|
await fs.access(this.memoryPath)
|
||||||
|
} catch (error) {
|
||||||
|
// File doesn't exist, create an empty file
|
||||||
|
await fs.writeFile(this.memoryPath, '')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Failed to create memory path:', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async loadGraph(): Promise<KnowledgeGraph> {
|
private async loadGraph(): Promise<KnowledgeGraph> {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import store from '@renderer/store'
|
import store from '@renderer/store'
|
||||||
import { LRUCache } from 'lru-cache'
|
import LRUCache from 'lru-cache'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FNV-1a哈希函数,用于计算字符串哈希值
|
* FNV-1a哈希函数,用于计算字符串哈希值
|
||||||
|
|||||||
@ -84,14 +84,6 @@ export const builtinMCPServers: MCPServer[] = [
|
|||||||
'An MCP server implementation that integrates the Brave Search API, providing both web and local search capabilities.',
|
'An MCP server implementation that integrates the Brave Search API, providing both web and local search capabilities.',
|
||||||
isActive: false
|
isActive: false
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: nanoid(),
|
|
||||||
name: '@cherry/everything',
|
|
||||||
type: 'inMemory',
|
|
||||||
description:
|
|
||||||
'This MCP server attempts to exercise all the features of the MCP protocol. It is not intended to be a useful server, but rather a test server for builders of MCP clients. It implements prompts, tools, resources, sampling, and more to showcase MCP capabilities.',
|
|
||||||
isActive: true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
name: '@cherry/fetch',
|
name: '@cherry/fetch',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user