mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 09:40:11 +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:
@@ -0,0 +1,40 @@
|
||||
import { z } from 'zod'
|
||||
import { defineOperation } from '../define'
|
||||
|
||||
export const createComment = defineOperation({
|
||||
name: 'create_comment',
|
||||
title: 'Create Comment',
|
||||
description:
|
||||
'Post a review comment on a file, or reply to an existing comment thread. The comment is ' +
|
||||
'posted as you, and the people involved are notified. For a video or audio file, set ' +
|
||||
'"second" to pin the comment to a timecode. For a version stack, the comment goes on its ' +
|
||||
'latest version.',
|
||||
input: z.object({
|
||||
assetId: z.string().min(1).describe('The file or version stack to comment on.'),
|
||||
message: z.string().trim().min(1).max(10_000).describe('The comment text.'),
|
||||
replyToId: z
|
||||
.string()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe('ID of the comment to reply to (from list_comments). Omit for a new thread.'),
|
||||
second: z
|
||||
.number()
|
||||
.min(0)
|
||||
.optional()
|
||||
.describe('Timecode in seconds on a video or audio file. Omit for other files.'),
|
||||
}),
|
||||
output: z.object({
|
||||
id: z.string().describe('The new comment ID.'),
|
||||
assetId: z.string().describe('The file the comment is on (the latest version for a stack).'),
|
||||
replyToId: z.string().nullable().describe('The thread it replies to, if any.'),
|
||||
}),
|
||||
surfaces: ['agent', 'mcp', 'cli'],
|
||||
annotations: { readOnly: false, destructive: false },
|
||||
cli: {
|
||||
command: ['comment', 'add'],
|
||||
description: 'Comment on a file, or reply to a comment with --reply-to.',
|
||||
positional: ['assetId', 'message'],
|
||||
flags: { replyToId: ['--reply-to'], second: ['-t', '--at'] },
|
||||
format: (output) => `Posted comment ${output.id}`,
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,79 @@
|
||||
import { z } from 'zod'
|
||||
import { defineOperation } from '../define'
|
||||
import { MAX_PAGE_SIZE, pageInfoSchema } from '../schemas'
|
||||
|
||||
const commentAuthorSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
})
|
||||
|
||||
const commentFields = {
|
||||
id: z.string(),
|
||||
message: z.string(),
|
||||
author: commentAuthorSchema,
|
||||
/** Timecode in seconds on a video or audio file (the viewing angle for 3D models). */
|
||||
second: z.number().nullable(),
|
||||
/** Whether markup was drawn on the frame or page. */
|
||||
hasMarkup: z.boolean(),
|
||||
attachmentCount: z.number(),
|
||||
createdAt: z.string(),
|
||||
}
|
||||
|
||||
export const commentReplySchema = z.object(commentFields)
|
||||
|
||||
export const commentThreadSchema = z.object({
|
||||
...commentFields,
|
||||
resolved: z.boolean(),
|
||||
replies: z.array(commentReplySchema),
|
||||
})
|
||||
export type CommentThread = z.infer<typeof commentThreadSchema>
|
||||
|
||||
export const listComments = defineOperation({
|
||||
name: 'list_comments',
|
||||
title: 'List Comments',
|
||||
description:
|
||||
'List the review comments on a file, oldest first, each with its replies. For a version ' +
|
||||
'stack, lists the comments on its latest version. "second" is the timecode on a video or ' +
|
||||
'audio file. Results are paginated: when pageInfo.hasNextPage is true, call again with ' +
|
||||
'after set to pageInfo.endCursor.',
|
||||
input: z.object({
|
||||
assetId: z.string().min(1).describe('The file or version stack ID.'),
|
||||
first: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(MAX_PAGE_SIZE)
|
||||
.optional()
|
||||
.describe(`Maximum number of comment threads to return (at most ${MAX_PAGE_SIZE}).`),
|
||||
after: z
|
||||
.string()
|
||||
.optional()
|
||||
.describe('Cursor from a previous response (pageInfo.endCursor) to fetch the next page.'),
|
||||
}),
|
||||
output: z.object({
|
||||
data: z.array(commentThreadSchema),
|
||||
pageInfo: pageInfoSchema,
|
||||
total: z.number(),
|
||||
}),
|
||||
surfaces: ['agent', 'mcp', 'cli'],
|
||||
annotations: { readOnly: true, destructive: false, idempotent: true },
|
||||
cli: {
|
||||
command: ['comment', 'ls'],
|
||||
description: 'List the comments on a file, with their replies.',
|
||||
positional: ['assetId'],
|
||||
defaults: { first: MAX_PAGE_SIZE },
|
||||
format: (output) => {
|
||||
if (output.data.length === 0) return 'No comments.'
|
||||
const lines: string[] = []
|
||||
for (const thread of output.data) {
|
||||
const at = thread.second !== null ? ` @${thread.second}s` : ''
|
||||
const status = thread.resolved ? ' [resolved]' : ''
|
||||
lines.push(`${thread.id}${at}${status} ${thread.author.name}: ${thread.message}`)
|
||||
for (const reply of thread.replies) {
|
||||
lines.push(` ↳ ${reply.id} ${reply.author.name}: ${reply.message}`)
|
||||
}
|
||||
}
|
||||
return lines.join('\n')
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,30 @@
|
||||
import { z } from 'zod'
|
||||
import { defineOperation } from '../define'
|
||||
|
||||
export const resolveComment = defineOperation({
|
||||
name: 'resolve_comment',
|
||||
title: 'Resolve Comment',
|
||||
description:
|
||||
'Mark a comment thread as resolved (done), e.g. after addressing the feedback in a new ' +
|
||||
'version. Set reopen to true to mark it as unresolved again.',
|
||||
input: z.object({
|
||||
commentId: z.string().min(1).describe('The comment ID (from list_comments).'),
|
||||
reopen: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe('Mark the comment as unresolved again instead (default false).'),
|
||||
}),
|
||||
output: z.object({
|
||||
commentId: z.string(),
|
||||
resolved: z.boolean(),
|
||||
}),
|
||||
surfaces: ['agent', 'mcp', 'cli'],
|
||||
annotations: { readOnly: false, destructive: false, idempotent: true },
|
||||
cli: {
|
||||
command: ['comment', 'resolve'],
|
||||
description: 'Mark a comment as resolved, or unresolved again with --reopen.',
|
||||
positional: ['commentId'],
|
||||
format: (output) =>
|
||||
`Comment ${output.commentId} is ${output.resolved ? 'resolved' : 'unresolved'}`,
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user