键值存储服务器

基于unjs/unstorage的多协议键值存储服务器,支持内存、文件系统、Redis、HTTP和MongoDB等多种驱动和传输协议。

  • by ctxinf
  • TypeScript
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 slow-groovin/unstorage-mcp

使用说明

取消存储MCP服务器

中文 README

基于单片机的键值存储MCP服务器 unjs/未存储.

支持驱动程序:

  1. 记忆
  2. 文件系统
  3. 瑞迪斯
  4. 取消存储http服务器
  5. MongoDB

支持运输:

  • [x] stdio
  • [x] 流式HTTP
  • [x] SSE

工具:

  • showMounts()
  • getItem(key)
  • getItems(items)
  • getItemRaw(key)
  • getMeta(key, nativeOnly)
  • getKeys(base, maxDepth)
  • setItem(key, value)
  • setItems(items)
  • setItemRaw(key, value)
  • setMeta(key, meta)
  • removeItem(key, removeMeta)
  • removeMeta(key)



使用stdio运行

最小配置

{
  "mcpServers": {
    "unstorage": {
      "command": "npx",
      "args": ["-y", "@slow-groovin/unstorage-mcp"]
    }
  }
}

最大配置

{
  "mcpServers": {
    "unstorage": {
      "command": "npx",
      "env": {
        "REDIS_URL": "redis://default:123456@localhost:6379",
        "REDIS_BASE": "visits:date:api:",
        "REDIS_MOUNT_POINT": "redis_storage",
        "FS_BASE": "D:/tmp",
        "FS_MOUNT_POINT": "fs_storage",
        "HTTP_BASE": "http://localhost:3001",
        "HTTP_MOUNT_POINT": "http_storage",
        "HTTP_HEADERS": "Authorization=Bear 123;A=3;B=4;C=5",
        "MONGODB_URL": "mongodb://root:123456@localhost:27017/",
        "MONGODB_DB_NAME": "test",
        "MONGODB_COLLECTION_NAME": "unstorage",
        "MONGODB_MOUNT_POINT": "mongo_storage"
      },
      "args": ["-y", "@slow-groovin/unstorage-mcp", "--disable-modify"]
    }
  }
}

对于Cline+Windows:

{
  "mcpServers": {
    "unstorage": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@slow-groovin/unstorage-mcp"]
    }
  }
}

如果你在Windows上安装有问题,可以参考以下内容 文章

使用HTTP(SSE+流式传输)运行

npx @slow-groovin/unstorage-mcp --http

相关论点

arg 默认值
--http 启用http传输而不是stdio false
-p,--端口 监听端口 3000
-h,--host 监听主机 localhost

示例 提示 供使用

The process has produced a key-value result: "fs_base:recommend_site"="www.api2o.com", store it.

参数

--disable-modify

默认值:false

禁用具有修改功能的工具,如setItem、setItems。..

环境变量

有关底座和安装点的概念,请参阅 未储存文件

在终端或 .env 文件

瑞迪斯

如果 REDIS_URL 设置后,将安装redis存储

语法 描述 默认值 可选
REDIS_URL redis连接网址,例如: redis://default:123456@localhost:6379
REDIS_BASE redisDriver的基础 ✅
REDIS_MOUNT_POINT 此存储的装载点 “/” ✅

MongoDB

如果 MONGODB_URL 设置后,将挂载mongodb存储

语法 描述 默认值 可选
MONGODB_URL mongodb连接网址,例如: mongodb://user:pass@host:port
MONGODB_DB_NAME mongodb数据库名称,例如: test
MONGODB_COLLECTION_NAME mongodb集合名称,例如: mycollection
MONGODB_MOUNT_POINT 此存储的装载点 “/” ✅

文件系统

如果 FS_BASE 设置后,将安装redis存储

语法 描述 默认值 可选
FS_BASE fsDriver的基础,文件系统的路径
FS_MOUNT_POINT 此存储的装载点 “/” ✅

HTTP服务器

如果 HTTP_BASE 设置后,将挂载http存储

语法 描述 默认值 可选
HTTP_BASE httpDriver的基础,http服务器的端点
HTTP_MOUNT_POINT 此存储的装载点 “/” ✅
HTTP_HEADERS http请求的标头,例如: Authorization=Bear 123;A=1;B=2 ✅

记忆

如果根目录上没有装载(“/”),则内存驱动程序将自动装载到“/”上(与卸载行为相同)。

扩展指南

  1. 克隆此仓库
  2. 将src/storage/redis.ts复制到一个新文件中,并将其修改为所需的驱动程序(unjs/unstorage 非常容易学习)
  3. 测试并验证其有效性
  4. (可选)拉取合并请求

如果您不是打字脚本开发人员,请提交问题以请求其他驱动程序支持。

光标/斜线辅助编程提示

@/src/storage/mongodb.ts , please implement this file:
1. you need to fetch information using the storage type's corresponding Doc URL (https://unstorage.unjs.io/drivers/<storage type>).
2. you can refer to examples in @/src/adapter/redis.ts and @/src/storage/http.ts.
3. You are only responsible for generating the code and do not need to perform testing.

如果您尚未安装fetch MCP服务器,请删除第一句话

调试方法

mcp检查员

 mcp-inspector -e HTTP_BASE=http://localhost:3001 -e HTTP_MOUNT_POINT=http_storage -e FS_BASE=D:/temp -e FS_MOUNT_POINT=fs_storage -e HTTP_HEADERS="Authorization=Bear 123;" tsx ./src/index.ts

本地开发的tsx mcpServer配置

{
  "mcpServers": {
    "command": "cmd",
    "env": {
      "REDIS_URL": "redis://default:123456@localhost:6379",
      "REDIS_BASE": "my:mcp:values:",
      "REDIS_MOUNT_POINT": "redis_storage"
    },
    "args": ["/c", "tsx", "D:/xxx/projects/unstorage-mcp/src/index.ts"]
  }
}

需要重新启动服务器才能使更改生效