mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 02:19:28 +00:00
feat: move MCP to /mcp and add teammate operations (#500)
* feat(operations): move MCP to /mcp and add search, comment, metadata, version, and upload operations - Serve the MCP server at /mcp instead of /api/mcp - Add search_assets, copy_assets, get_folder_instructions, list_comments, create_comment, resolve_comment, list_metadata_fields, update_asset_metadata, create_version_stack, list_versions, and remove_version on the agent, MCP, and CLI - Add create_file and create_version (agent, MCP) with Creation Context metadata, and complete_upload (MCP) for presigned two-step uploads - Replace the native agent create_file/create_version tools with Operation-backed ones - Route the comment-complete, metadata, copy, version stack, and AGENTS.md read REST endpoints through their Operations * docs(readme): add built-in MCP server and CLI to features list
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
import { listMembersQuerySchema, AuditAction } from '@shumai/dtos'
|
||||
import type { Prisma } from '@shumai/db'
|
||||
import { auditLogService } from '@shumai/core/src/auditLog/auditLog'
|
||||
import { moveAssetsOp, runOperation } from '@shumai/core/src/operations'
|
||||
import { copyAssetsOp, moveAssetsOp, runOperation } from '@shumai/core/src/operations'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -303,46 +303,13 @@ const route = new Hono<{ Variables: { user: User } }>()
|
||||
},
|
||||
)
|
||||
.post('/projects/:projectId/copy', zValidator('json', copyAssetsRequestSchema), async (c) => {
|
||||
const projectId = c.req.param('projectId')
|
||||
const user = c.get('user')
|
||||
const req = c.req.valid('json')
|
||||
|
||||
// Check Edit permission on target folder/project
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Edit,
|
||||
type: ResourceType.Asset,
|
||||
id: req.newParentId,
|
||||
})
|
||||
|
||||
// Check Read permission on all source assets
|
||||
for (const assetId of req.assetIds) {
|
||||
await authzService.hasPermission({
|
||||
user,
|
||||
permission: Permission.Read,
|
||||
type: ResourceType.Asset,
|
||||
id: assetId,
|
||||
})
|
||||
}
|
||||
|
||||
await assetService.copyAssets({
|
||||
...req,
|
||||
creatorId: user.id,
|
||||
})
|
||||
|
||||
const teamId = await projectService.getProjectTeam(projectId).catch(() => null)
|
||||
if (teamId) {
|
||||
for (const assetId of req.assetIds) {
|
||||
await auditLogService.logAction({
|
||||
action: AuditAction.asset_copy,
|
||||
teamId,
|
||||
userId: user.id,
|
||||
projectId,
|
||||
itemId: assetId,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Team/project for authorization and audit come from the assets themselves, not the path.
|
||||
await runOperation(
|
||||
copyAssetsOp,
|
||||
{ userId: c.get('user').id, via: 'api' },
|
||||
{ assetIds: req.assetIds, newParentId: req.newParentId, withComments: req.withComments },
|
||||
)
|
||||
return c.body(null, 204)
|
||||
})
|
||||
.patch(
|
||||
|
||||
Reference in New Issue
Block a user