mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-23 18:17:57 +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:
@@ -36,6 +36,8 @@ type FieldKind =
|
||||
| { type: 'boolean' }
|
||||
| { type: 'enum'; values: string[] }
|
||||
| { type: 'array' }
|
||||
/** A key/value object (`z.record`), passed as a JSON object. */
|
||||
| { type: 'json' }
|
||||
|
||||
interface FieldInfo {
|
||||
name: string
|
||||
@@ -73,6 +75,7 @@ function describeSchema(
|
||||
else if (base instanceof z.ZodEnum) kind = { type: 'enum', values: base.options.map(String) }
|
||||
else if (base instanceof z.ZodArray) kind = { type: 'array' }
|
||||
else if (base instanceof z.ZodString) kind = { type: 'string' }
|
||||
else if (base instanceof z.ZodRecord) kind = { type: 'json' }
|
||||
else {
|
||||
throw new Error(`${definition.name}.${name}: unsupported input type for the CLI`)
|
||||
}
|
||||
@@ -114,6 +117,19 @@ function parseNumber(value: string): number {
|
||||
return parsed
|
||||
}
|
||||
|
||||
function parseJsonObject(value: string): Record<string, unknown> {
|
||||
let parsed: unknown
|
||||
try {
|
||||
parsed = JSON.parse(value)
|
||||
} catch {
|
||||
throw new InvalidArgumentError('Not valid JSON.')
|
||||
}
|
||||
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
||||
throw new InvalidArgumentError('Expected a JSON object, e.g. \'{"key": "value"}\'.')
|
||||
}
|
||||
return parsed as Record<string, unknown>
|
||||
}
|
||||
|
||||
function kebab(name: string): string {
|
||||
return name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)
|
||||
}
|
||||
@@ -166,9 +182,12 @@ export function registerOperationCommands(
|
||||
? ''
|
||||
: field.kind.type === 'array'
|
||||
? ` <${field.name}...>`
|
||||
: ` <${field.name}>`
|
||||
: field.kind.type === 'json'
|
||||
? ` <json>`
|
||||
: ` <${field.name}>`
|
||||
const option = new Option(`${spellings.join(', ')}${valueHint}`, field.description)
|
||||
if (field.kind.type === 'number') option.argParser(parseNumber)
|
||||
if (field.kind.type === 'json') option.argParser(parseJsonObject)
|
||||
if (field.kind.type === 'enum') option.choices(field.kind.values)
|
||||
if (field.required) option.makeOptionMandatory()
|
||||
cmd.addOption(option)
|
||||
|
||||
Reference in New Issue
Block a user