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:
Yiling-J
2026-10-27 14:37:26 +08:00
committed by GitHub
parent 50fbd97953
commit b3cae4f2b0
81 changed files with 4111 additions and 1397 deletions
@@ -0,0 +1,19 @@
import { z } from 'zod'
import { defineOperation } from '../define'
import { assetSummarySchema } from '../schemas'
export const completeUpload = defineOperation({
name: 'complete_upload',
title: 'Complete Upload',
description:
'Finish an upload started with create_file or create_version, after the file bytes were ' +
'PUT to its uploadUrl. Creates the file (or the new version) and starts processing it ' +
'(previews, transcoding). Returns the new file. Calling it again for the same upload ' +
'returns the same file.',
input: z.object({
uploadId: z.string().min(1).describe('The uploadId returned by create_file or create_version.'),
}),
output: assetSummarySchema,
surfaces: ['mcp'],
annotations: { readOnly: false, destructive: false, idempotent: true },
})
@@ -0,0 +1,55 @@
import { z } from 'zod'
import { defineOperation } from '../define'
import { METADATA_VALUES_DESCRIPTION } from '../metadata/update-asset-metadata'
/** How long an upload started by create_file or create_version stays valid. */
export const UPLOAD_TTL_SECONDS = 60 * 60
/** Creation Context metadata, recorded by whoever creates a file. */
export const creationMetadataSchema = z
.record(z.string(), z.unknown())
.optional()
.describe(
"Values for the project's Creation Context fields (list_metadata_fields, creationContext: " +
'true), such as the prompt or model used to make the file. Only those fields are ' +
`accepted. ${METADATA_VALUES_DESCRIPTION}`,
)
export const startedUploadSchema = z.object({
uploadId: z.string().describe('Pass to complete_upload once the file is uploaded.'),
uploadUrl: z.string().describe('Upload the raw file bytes here with an HTTP PUT request.'),
method: z.literal('PUT'),
expiresAt: z.string().describe('When uploadUrl and uploadId stop working (about an hour).'),
/** Storage key; only returned to Shumai's built-in agent, which uploads from its sandbox. */
key: z.string().optional(),
})
export type StartedUploadOutput = z.infer<typeof startedUploadSchema>
const UPLOAD_STEPS =
'Uploading takes three steps: call this tool, PUT the raw file bytes to uploadUrl (e.g. ' +
'`curl -T <file> "<uploadUrl>"`), then call complete_upload with uploadId to create the ' +
`asset. The upload URL expires after about an hour.`
export const createFile = defineOperation({
name: 'create_file',
title: 'Create File',
description: `Start uploading a new file into a folder. ${UPLOAD_STEPS}`,
input: z.object({
parent: z.string().min(1).describe('The folder to create the file in.'),
name: z
.string()
.trim()
.min(1)
.max(255)
.describe('File name including its extension, e.g. "storyboard.pdf".'),
contentType: z
.string()
.min(1)
.optional()
.describe('MIME type, e.g. "image/png". Detected from the name when omitted.'),
metadata: creationMetadataSchema,
}),
output: startedUploadSchema,
surfaces: ['agent', 'mcp'],
annotations: { readOnly: false, destructive: false },
})
@@ -0,0 +1,31 @@
import { z } from 'zod'
import { defineOperation } from '../define'
import { creationMetadataSchema, startedUploadSchema } from './create-file'
export const createVersion = defineOperation({
name: 'create_version',
title: 'Create Version',
description:
'Start uploading a new version of an existing file. The new version becomes the current ' +
'one; a plain file becomes a version stack. Uploading takes three steps: call this tool, ' +
'PUT the raw file bytes to uploadUrl (e.g. `curl -T <file> "<uploadUrl>"`), then call ' +
'complete_upload with uploadId. The upload URL expires after about an hour.',
input: z.object({
parent: z.string().min(1).describe('The file or version stack to add a version to.'),
name: z
.string()
.trim()
.min(1)
.max(255)
.describe('File name of the new version including its extension, e.g. "cut_v3.mp4".'),
contentType: z
.string()
.min(1)
.optional()
.describe('MIME type, e.g. "video/mp4". Detected from the name when omitted.'),
metadata: creationMetadataSchema,
}),
output: startedUploadSchema,
surfaces: ['agent', 'mcp'],
annotations: { readOnly: false, destructive: false },
})