-
Notifications
You must be signed in to change notification settings - Fork 126
fix: MCP 工具缺失:NoSQL 数据库回档时间查询能力 #670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -900,6 +900,80 @@ deleteCollection: 删除集合`), | |
| throw new Error(`不支持的操作类型: ${action}`); | ||
| }, | ||
| ); | ||
|
|
||
| // queryNoSqlDatabaseBackupTime - 查询 NoSQL 数据库可回档时间范围 | ||
| server.registerTool?.( | ||
| "queryNoSqlDatabaseBackupTime", | ||
| { | ||
| title: "查询 NoSQL 数据库可回档时间范围", | ||
| description: | ||
| "查询 NoSQL 数据库(文档型数据库)的可回档时间范围,返回最早可回档时间和最晚可回档时间。适用于需要了解数据库备份恢复时间范围的场景。", | ||
| inputSchema: { | ||
| collectionName: z | ||
| .string() | ||
| .optional() | ||
| .describe("集合名称(可选),如需查询特定集合的回档时间范围可传入"), | ||
| instanceId: z | ||
| .string() | ||
| .optional() | ||
| .describe("可选:显式指定数据库实例ID;未传时会自动解析并缓存"), | ||
| }, | ||
| annotations: { | ||
| readOnlyHint: true, | ||
| openWorldHint: true, | ||
| category: CATEGORY, | ||
| }, | ||
| }, | ||
| async ({ collectionName, instanceId }) => { | ||
| const cloudbase = await getManager(); | ||
|
|
||
| const resolvedInstance = await resolveNoSqlInstanceId({ | ||
| toolName: "queryNoSqlDatabaseBackupTime", | ||
| cloudbase, | ||
| cloudBaseOptions, | ||
| instanceIdOverride: instanceId, | ||
| collectionName: collectionName || "default", | ||
| }); | ||
|
|
||
| const result = await cloudbase | ||
| .commonService("tcb", "2018-06-08") | ||
| .call({ | ||
| Action: "DescribeBackupTime", | ||
| Param: { | ||
| EnvId: cloudBaseOptions?.envId, | ||
| TableName: collectionName, | ||
| Tag: resolvedInstance.instanceId, | ||
| }, | ||
| }); | ||
|
|
||
| logCloudBaseResult(server.logger, result); | ||
|
|
||
| return { | ||
| content: [ | ||
| { | ||
| type: "text", | ||
| text: JSON.stringify( | ||
| { | ||
| success: true, | ||
| requestId: result?.RequestId, | ||
| backupTimeRange: { | ||
| earliestTime: result?.EarliestTime, | ||
| latestTime: result?.LatestTime, | ||
| startTime: result?.StartTime, | ||
| endTime: result?.EndTime, | ||
| }, | ||
|
Comment on lines
+959
to
+964
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The response formatter reads Useful? React with 👍 / 👎. |
||
| instanceId: resolvedInstance.instanceId, | ||
| collectionName: collectionName || null, | ||
| message: "获取 NoSQL 数据库可回档时间范围成功", | ||
| }, | ||
| null, | ||
| 2, | ||
| ), | ||
| }, | ||
| ], | ||
| }; | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| async function insertDocuments({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new tool calls
commonService("tcb", "2018-06-08")withAction: "DescribeBackupTime"and paramsTableName/Tag, but the repository’s CloudBase manager docs for “查询可回档时间” specifycommonService('flexdb').callwithAction: 'DescribeRestoreTime'andParam.InstanceId. In environments that follow the documented contract, this request shape can fail outright or hit a different backend action, so users asking for restoreable timestamps may not get a valid response.Useful? React with 👍 / 👎.