未存储服务器提供了灵活的存储配置和扩展能力,可根据不同需求进行定制化部署,支持多种存储类型和环境变量配置。
要使用未存储服务器,你需要进行相应的配置和安装,以下是详细步骤。
{
"unstorage": {
"adapter": "default"
}
}
{
"unstorage": {
"adapter": "default",
"options": {
"host": "localhost",
"port": 3001,
"prefix": "/api/v1/storage"
}
}
}
UNSTORAGE_REDIS_URL=redis://default:password@localhost:6379
UNSTORAGE_REDIS_BASE=my:mcp:values:
UNSTORAGE_REDIS_MOUNTPOINT=/my/redis/mountpoint
UNSTORAGE_HTTP_BASE=http://localhost:3001
UNSTORAGE_HTTP_MOUNTPOINT=/http/mountpoint
UNSTORAGE_HTTP_HEADERS="Authorization=Bear 123;A=1;B=2"
UNSTORAGE_FS_BASE=/path/to/base/directory
UNSTORAGE_FS_MOUNTPOINT=/fs/mountpoint
src/storage/redis.ts 到一个新的文件并根据需求修改它(unjs/unstorage 的学习曲线非常友好)。如果你不是 TypeScript 开发者,请提交一个问题以请求其他驱动支持。
@/src/storage/mongodb.ts ,请实现这个文件:
1. 你需要使用存储类型的相应文档 URL(https://unstorage.unjs.io/drivers/<存储类型>)获取信息。
2. 可以参考 @/src/adapter/redis.ts 和 @/src/storage/http.ts 中的例子。
3. 你只需要生成代码,而不需要执行测试。
> 如果你没有安装 fetch 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
{
"mcpServers": {
"command": "cmd",
"env": {
"REDIS_URL": "redis://default:password@localhost:6379",
"REDIS_BASE": "my:mcp:values:",
"REDIS_MOUNT_POINT": "/my/redis/mountpoint"
},
"args": ["/c", "tsx", "D:/xxx/projects/unstorage-mcp/src/index.ts"]
}
}
⚠️ 重要提示
重启服务器以使更改生效。