@wevi/mcp 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/chunk-IDFFE3P7.js +981 -0
- package/dist/chunk-IDFFE3P7.js.map +1 -0
- package/dist/http.d.ts +2 -0
- package/dist/http.js +171 -0
- package/dist/http.js.map +1 -0
- package/dist/index.js +14 -777
- package/dist/index.js.map +1 -1
- package/package.json +8 -4
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/client/wevi-api-client.ts","../src/tools/templates.tools.ts","../src/types/index.ts","../src/tools/projects.tools.ts","../src/tools/renders.tools.ts","../src/tools/ai.tools.ts","../src/capabilities.ts","../src/tools/browse.tools.ts","../src/tools/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport dotenv from \"dotenv\";\nimport { WeviApiClient } from \"./client/wevi-api-client.js\";\nimport { registerAllTools } from \"./tools/index.js\";\nimport { buildServerInstructions } from \"./capabilities.js\";\n\ndotenv.config();\n\nconst apiKey = process.env.WEVI_API_KEY;\nconst apiUrl = process.env.WEVI_API_URL || \"https://api-v2.wevi.ai/api/v2\";\n\nif (!apiKey) {\n process.stderr.write(\n \"[Wevi MCP Warning] WEVI_API_KEY is not set. MCP tools will fail until an API key is provided in your MCP configuration.\\nGet your key at: https://app.wevi.ai/app/profile?id=api-keys\\n\",\n );\n}\n\nconst client = new WeviApiClient({\n apiKey: apiKey || \"\",\n apiUrl,\n});\n\nif (client.isSandbox) {\n process.stderr.write(\n \"[Wevi MCP] Sandbox key detected (wevi_test_): renders are watermarked, capped at 720p and do not use credits.\\n\",\n );\n}\n\nconst server = new McpServer(\n {\n name: \"wevi\",\n version: \"0.2.1\",\n },\n {\n // Sent to the client on connect; assistants that honour MCP instructions\n // learn what Wevi can and cannot make before the first tool call.\n instructions: buildServerInstructions(),\n },\n);\n\n// Register all video automation tools\nregisterAllTools(server, client);\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n process.stderr.write(`[Wevi MCP Server] Started successfully connected to ${apiUrl}\\n`);\n}\n\nmain().catch((error) => {\n process.stderr.write(`[Wevi MCP Server Fatal Error]: ${error}\\n`);\n process.exit(1);\n});\n","import {\n WeviConfig,\n WeviCreditBalance,\n WeviEditableLayer,\n WeviExportStatus,\n WeviProject,\n WeviPublishStatus,\n WeviSceneInput,\n WeviTemplateSummary,\n} from \"../types/index.js\";\n\nconst USER_AGENT = \"Wevi-MCP-Server/0.2.1\";\n\nfunction toObject(value: unknown): Record<string, unknown> {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return {};\n return value as Record<string, unknown>;\n}\n\nexport class WeviApiClient {\n private readonly apiKey: string;\n private readonly baseUrl: string;\n\n constructor(config: WeviConfig) {\n this.apiKey = config.apiKey.trim();\n this.baseUrl = config.apiUrl.replace(/\\/+$/, \"\");\n }\n\n /** True when the configured key is a `wevi_test_` sandbox key. */\n get isSandbox() {\n return this.apiKey.startsWith(\"wevi_test_\");\n }\n\n private get headers(): Record<string, string> {\n return {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": this.apiKey,\n Authorization: `Bearer ${this.apiKey}`,\n \"User-Agent\": USER_AGENT,\n };\n }\n\n private async request<T>(endpoint: string, options: RequestInit = {}): Promise<T> {\n const url = `${this.baseUrl}${endpoint.startsWith(\"/\") ? \"\" : \"/\"}${endpoint}`;\n\n let response: Response;\n try {\n response = await fetch(url, {\n ...options,\n headers: { ...this.headers, ...(options.headers || {}) },\n });\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n throw new Error(`Failed to connect to Wevi API at ${this.baseUrl}: ${msg}`);\n }\n\n if (!response.ok) {\n let errorBody: Record<string, unknown> = {};\n try {\n errorBody = (await response.json()) as Record<string, unknown>;\n } catch {\n // non-JSON error\n }\n\n const errObj = errorBody.error;\n const rawMessage =\n (typeof errorBody.message === \"string\" && errorBody.message) ||\n (Array.isArray(errorBody.message) && errorBody.message.join(\"; \")) ||\n (typeof errObj === \"string\" && errObj) ||\n (typeof errObj === \"object\" &&\n errObj !== null &&\n typeof (errObj as { message?: unknown }).message === \"string\" &&\n (errObj as { message: string }).message) ||\n `Wevi API error (${response.status} ${response.statusText})`;\n const message = String(rawMessage);\n\n if (response.status === 402) {\n const topUpUrl =\n typeof errorBody.topUpUrl === \"string\"\n ? errorBody.topUpUrl\n : \"https://app.wevi.ai/app/profile?id=api-keys&topup=1\";\n const required = errorBody.creditsRequired;\n const available = errorBody.creditsAvailable;\n const detail =\n typeof required === \"number\" && typeof available === \"number\"\n ? ` Needs ${required} credit${required === 1 ? \"\" : \"s\"}, ${available} available.`\n : \"\";\n throw new Error(\n `[402 Payment Required] Not enough API credits.${detail} Buy a credit pack or upgrade at ${topUpUrl}. Call wevi_get_credits to see the balance.\\nDetails: ${message}`,\n );\n }\n if (response.status === 401) {\n throw new Error(\n `[401 Unauthorized] Invalid or revoked Wevi API key. Check WEVI_API_KEY at https://app.wevi.ai/app/profile?id=api-keys.`,\n );\n }\n if (response.status === 429) {\n throw new Error(`[429 Too Many Requests] Slow down: ${message}`);\n }\n throw new Error(`[Wevi API Error ${response.status}] ${message}`);\n }\n\n if (response.status === 204) {\n return {} as T;\n }\n return (await response.json()) as T;\n }\n\n /**\n * Lists published, active templates. The API already restricts API-key\n * callers to published templates; we also send `status=PUBLISHED` so the\n * intent is explicit in logs.\n */\n async listTemplates(params?: {\n category?: string;\n aspectRatio?: string;\n search?: string;\n limit?: number;\n page?: number;\n }): Promise<{ items: WeviTemplateSummary[]; total: number; categories: string[] }> {\n const query = new URLSearchParams();\n query.set(\"status\", \"PUBLISHED\");\n if (params?.category) query.set(\"category\", params.category);\n if (params?.aspectRatio) query.set(\"aspectRatio\", params.aspectRatio);\n if (params?.search) query.set(\"search\", params.search);\n if (params?.limit) query.set(\"limit\", String(params.limit));\n if (params?.page) query.set(\"page\", String(params.page));\n\n const result = await this.request<{ data?: unknown }>(`/templates?${query.toString()}`);\n const data = toObject(result?.data ?? result);\n const items = (Array.isArray(data.templates) ? data.templates : []) as WeviTemplateSummary[];\n const meta = toObject(data.meta);\n const total = typeof meta.total === \"number\" ? meta.total : items.length;\n const categories = Array.isArray(data.categories)\n ? (data.categories as unknown[]).filter((c): c is string => typeof c === \"string\")\n : [];\n return { items, total, categories };\n }\n\n async getTemplate(templateId: string): Promise<WeviTemplateSummary> {\n const res = await this.request<{ data?: WeviTemplateSummary }>(\n `/templates/${encodeURIComponent(templateId)}`,\n );\n return (res?.data ?? res) as WeviTemplateSummary;\n }\n\n /** Guidance an agent needs to place a template in the right scene role. */\n static extractGuidance(template: WeviTemplateSummary) {\n const meta = template.semanticMeta ?? null;\n const instructions = meta?.instructions ?? {};\n const guide = template.smartGuide ?? meta?.smartGuide ?? null;\n return {\n purpose: instructions.purpose ?? null,\n sceneIntent: instructions.designProtocol?.sceneIntent ?? [],\n avoid: instructions.designProtocol?.avoid ?? [],\n tone: instructions.scriptGuidelines?.tone ?? null,\n onScreenTextFormat: instructions.scriptGuidelines?.onScreenTextFormat ?? null,\n do: guide?.do ?? [],\n dont: guide?.dont ?? [],\n };\n }\n\n /**\n * Flattens the template's `layerMeta` into the editable parameters an agent\n * can set. Hidden and protected layers are omitted.\n */\n static extractEditableLayers(template: WeviTemplateSummary): WeviEditableLayer[] {\n const layerMeta = toObject(template.layerMeta);\n const rawLayers = Array.isArray(template.layers) ? template.layers : [];\n const orderedKeys: string[] = [];\n for (const raw of rawLayers) {\n const key = toObject(raw).key;\n if (typeof key === \"string\" && key && !orderedKeys.includes(key)) orderedKeys.push(key);\n }\n for (const key of Object.keys(layerMeta)) {\n if (!orderedKeys.includes(key)) orderedKeys.push(key);\n }\n\n const layers: WeviEditableLayer[] = [];\n for (const key of orderedKeys) {\n if (key.startsWith(\"__ui\")) continue;\n const meta = toObject(layerMeta[key]);\n if (meta.hidden === true || meta.isProtected === true) continue;\n const control = toObject(meta.control);\n const options = Array.isArray(control.options)\n ? (control.options as unknown[]).filter((o): o is string => typeof o === \"string\")\n : [];\n const validation = toObject(meta.validation);\n const rawLayer = toObject(rawLayers.find((raw) => toObject(raw).key === key));\n layers.push({\n key,\n label: String(meta.humanLabel || meta.label || rawLayer.label || key),\n type: String(meta.type || rawLayer.type || \"text\").toLowerCase(),\n role: typeof meta.role === \"string\" ? meta.role : undefined,\n description: typeof meta.description === \"string\" ? meta.description : undefined,\n aiHint: typeof meta.aiHint === \"string\" ? meta.aiHint : undefined,\n required: meta.required === true,\n defaultValue: meta.defaultValue ?? rawLayer.defaultValue ?? null,\n ...(options.length ? { options } : {}),\n ...(Object.keys(validation).length ? { validation } : {}),\n });\n }\n return layers;\n }\n\n /**\n * Creates a render-ready project. All scenes land in ONE project so the\n * publish step exports a single concatenated video.\n */\n async createProject(data: {\n title?: string;\n scenes: WeviSceneInput[];\n brandId?: string;\n }): Promise<WeviProject> {\n const res = await this.request<{ data?: WeviProject }>(\"/projects\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n return (res?.data ?? res) as WeviProject;\n }\n\n async getProject(projectId: string): Promise<Record<string, unknown>> {\n const res = await this.request<{ data?: unknown }>(`/projects/${encodeURIComponent(projectId)}`);\n const data = toObject(res?.data ?? res);\n return (toObject(data.project) as Record<string, unknown>) && Object.keys(toObject(data.project)).length\n ? toObject(data.project)\n : data;\n }\n\n /** Renders every scene and queues one concatenated export. */\n async publishProject(\n projectId: string,\n options?: {\n quality?: \"720p\" | \"1080p\" | \"4K\";\n includeMusic?: boolean;\n includeVoiceover?: boolean;\n includeSoundEffects?: boolean;\n },\n ): Promise<WeviPublishStatus> {\n const res = await this.request<{ data?: WeviPublishStatus }>(\n `/projects/${encodeURIComponent(projectId)}/publish`,\n { method: \"POST\", body: JSON.stringify(options ?? {}) },\n );\n return (res?.data ?? res) as WeviPublishStatus;\n }\n\n async getPublishStatus(projectId: string): Promise<WeviPublishStatus> {\n const res = await this.request<{ data?: WeviPublishStatus }>(\n `/projects/${encodeURIComponent(projectId)}/publish/status`,\n );\n return (res?.data ?? res) as WeviPublishStatus;\n }\n\n /**\n * Polls publish status until the video is ready, a failure is reported, or\n * the time budget is spent. Returns the last status either way.\n */\n async waitForPublish(\n projectId: string,\n waitSeconds: number,\n pollIntervalMs = 5000,\n ): Promise<WeviPublishStatus> {\n const deadline = Date.now() + waitSeconds * 1000;\n let status = await this.getPublishStatus(projectId);\n while (\n Date.now() < deadline &&\n (status.phase === \"rendering\" || status.phase === \"exporting\")\n ) {\n await new Promise((resolve) => setTimeout(resolve, pollIntervalMs));\n status = await this.getPublishStatus(projectId);\n }\n return status;\n }\n\n async getRenderStatus(exportId: string): Promise<WeviExportStatus> {\n const res = await this.request<{ data?: unknown }>(`/exports/${encodeURIComponent(exportId)}`);\n const data = toObject(res?.data ?? res);\n return (Object.keys(toObject(data.export)).length ? data.export : data) as WeviExportStatus;\n }\n\n /** Credit balance for live keys, plus the packs on sale and per-action costs. */\n async getCredits(): Promise<WeviCreditBalance> {\n const res = await this.request<{ data?: WeviCreditBalance }>(\"/billing/credits\");\n return (res?.data ?? res) as WeviCreditBalance;\n }\n\n async generateStoryboard(data: {\n prompt: string;\n brandName?: string;\n brandUrl?: string;\n brandVoice?: string;\n maxScenes?: number;\n }): Promise<Record<string, unknown>> {\n const res = await this.request<{ data?: unknown }>(\"/ai/storyboard/draft\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n const payload = toObject(res?.data ?? res);\n return Object.keys(toObject(payload.draft)).length ? toObject(payload.draft) : payload;\n }\n\n async captureWebUi(data: {\n url: string;\n selector?: string;\n viewport?: \"desktop\" | \"mobile\" | \"tablet\";\n }): Promise<Record<string, unknown>> {\n const res = await this.request<{ data?: unknown }>(\"/browse/capture\", {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n return toObject(res?.data ?? res);\n }\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\nimport { WEVI_ASPECT_RATIOS } from \"../types/index.js\";\n\nfunction errorResult(prefix: string, err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true as const,\n content: [{ type: \"text\" as const, text: `${prefix}: ${msg}` }],\n };\n}\n\nexport function registerTemplateTools(server: McpServer, client: WeviApiClient) {\n // 1. wevi_list_templates\n server.tool(\n \"wevi_list_templates\",\n [\n \"List PUBLISHED Wevi video templates (only published templates can be used in projects).\",\n \"Filter by aspect ratio, category or keyword. Every scene in one project must share the same aspectRatio,\",\n \"so pick all templates for a video from a single aspectRatio group.\",\n \"Templates with requiresUiCapture=true need an interactive screen capture in the Wevi app and cannot be rendered from MCP yet.\",\n ].join(\" \"),\n {\n category: z\n .string()\n .optional()\n .describe(\"Category filter (e.g. 'SaaS', 'CTA', 'Problem', 'Solution', 'Motion')\"),\n aspectRatio: z\n .enum(WEVI_ASPECT_RATIOS)\n .optional()\n .describe(\n \"'16:9' = widescreen 1920x1080 (default for most videos). '16:12' = 1920x1440 desktop-app focus frame.\",\n ),\n search: z\n .string()\n .optional()\n .describe(\"Keyword matched against template names, slugs and descriptions\"),\n limit: z\n .number()\n .min(1)\n .max(50)\n .optional()\n .default(20)\n .describe(\"Number of templates to return (default 20, max 50)\"),\n page: z.number().min(1).optional().describe(\"Page number for pagination (default 1)\"),\n },\n async (args) => {\n try {\n const result = await client.listTemplates(args);\n const usable = result.items.filter((t) => t.requiresUiCapture !== true);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(\n {\n totalPublishedTemplates: result.total,\n returned: result.items.length,\n usableFromMcp: usable.length,\n categories: result.categories,\n sandbox: client.isSandbox,\n templates: result.items.map((t) => {\n const guidance = WeviApiClient.extractGuidance(t);\n return {\n id: t.id,\n slug: t.slug,\n name: t.displayName || t.name,\n description: t.aiDescription || t.description || null,\n purpose: guidance.purpose,\n bestForScenes: guidance.sceneIntent,\n avoid: guidance.avoid,\n tone: guidance.tone,\n category: t.category ?? null,\n aspectRatio: t.aspectRatio,\n durationSeconds: t.durationSeconds ?? null,\n requiresUiCapture: t.requiresUiCapture === true,\n tags: t.tags ?? [],\n previewVideoUrl: t.previewUrl ?? null,\n thumbnailUrl: t.thumbnailUrl ?? null,\n };\n }),\n hint:\n \"Match bestForScenes to the video's structure (hook → feature/solution → proof → cta). Respect each template's avoid list. Keep every scene in one aspectRatio.\",\n },\n null,\n 2,\n ),\n },\n ],\n };\n } catch (err) {\n return errorResult(\"Error listing templates\", err);\n }\n },\n );\n\n // 2. wevi_get_template_schema\n server.tool(\n \"wevi_get_template_schema\",\n [\n \"Inspect the editable parameters (layer keys) of a published template: text, colors, sliders, toggles, dropdown options, media.\",\n \"Call this before wevi_create_project so the `parameters` you pass use exact layer keys and valid values.\",\n ].join(\" \"),\n {\n templateId: z.string().describe(\"Template ID or slug\"),\n },\n async (args) => {\n try {\n const template = await client.getTemplate(args.templateId);\n const editableLayers = WeviApiClient.extractEditableLayers(template);\n const guidance = WeviApiClient.extractGuidance(template);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(\n {\n id: template.id,\n slug: template.slug,\n name: template.displayName || template.name,\n description: template.aiDescription || template.description || null,\n category: template.category ?? null,\n aspectRatio: template.aspectRatio,\n durationSeconds: template.durationSeconds ?? null,\n requiresUiCapture: template.requiresUiCapture === true,\n usableFromMcp: template.requiresUiCapture !== true,\n guidance,\n editableLayers,\n usage:\n \"Pass values as { parameters: { [layerKey]: value } } inside a scene of wevi_create_project. Colors are hex strings, sliders are numbers within validation.min/max, toggles are booleans, dropdowns must use one of `options`.\",\n },\n null,\n 2,\n ),\n },\n ],\n };\n } catch (err) {\n return errorResult(\"Error fetching template schema\", err);\n }\n },\n );\n}\n","export interface WeviConfig {\n apiKey: string;\n apiUrl: string;\n}\n\n/** Aspect ratios Wevi templates are authored in. Mirrors the API constants. */\nexport const WEVI_ASPECT_RATIOS = [\"16:9\", \"16:12\"] as const;\nexport type WeviAspectRatio = (typeof WEVI_ASPECT_RATIOS)[number];\n\nexport interface WeviTemplateSummary {\n id: string;\n name: string;\n slug: string;\n displayName?: string;\n description?: string | null;\n aiDescription?: string | null;\n category?: string | null;\n aspectRatio: WeviAspectRatio;\n requiresUiCapture?: boolean;\n durationSeconds?: number | null;\n tags?: string[];\n previewUrl?: string | null;\n thumbnailUrl?: string | null;\n layers?: unknown;\n layerMeta?: Record<string, Record<string, unknown>>;\n semanticMeta?: {\n aiDescription?: string;\n tags?: string[];\n instructions?: {\n purpose?: string;\n designProtocol?: { sceneIntent?: string[]; avoid?: string[] };\n scriptGuidelines?: { tone?: string; onScreenTextFormat?: string };\n logicalConstraints?: { requiresUiCapture?: boolean };\n };\n smartGuide?: { do?: string[]; dont?: string[] };\n } | null;\n smartGuide?: { do?: string[]; dont?: string[] } | null;\n}\n\nexport interface WeviEditableLayer {\n key: string;\n label: string;\n type: string;\n role?: string;\n description?: string;\n aiHint?: string;\n required?: boolean;\n defaultValue?: unknown;\n options?: string[];\n validation?: Record<string, unknown>;\n}\n\nexport interface WeviSceneInput {\n templateId: string;\n title?: string;\n voiceoverText?: string;\n parameters?: Record<string, string | number | boolean | null>;\n}\n\nexport interface WeviProject {\n id: string;\n title: string;\n status: string;\n aspectRatio: WeviAspectRatio;\n sandbox?: boolean;\n sceneCount?: number;\n scenes?: Array<{\n id: string;\n position: number;\n title: string;\n templateId: string | null;\n templateSlug?: string | null;\n templateName?: string | null;\n parameters?: Record<string, unknown>;\n }>;\n nextStep?: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport type WeviPublishPhase =\n | \"idle\"\n | \"rendering\"\n | \"render_failed\"\n | \"exporting\"\n | \"completed\"\n | \"failed\";\n\nexport interface WeviPublishStatus {\n phase: WeviPublishPhase;\n message: string;\n sandbox: boolean;\n project: { id: string; title: string | null; status: string };\n render: {\n runId: string;\n state: string;\n sceneCount: number;\n doneScenes: number;\n failedScenes: number;\n inProgressScenes: number;\n progressPercent: number;\n failures: Array<{\n sceneId: string;\n position: number;\n title: string;\n error: string;\n }>;\n } | null;\n export: {\n id: string;\n status: string;\n progress: number;\n currentStep: string | null;\n quality: string;\n format: string;\n durationSeconds: number | null;\n errorMessage: string | null;\n completedAt: string | null;\n } | null;\n videoUrl: string | null;\n thumbnailUrl: string | null;\n}\n\nexport interface WeviExportStatus {\n id: string;\n projectId: string;\n status: \"QUEUED\" | \"DOWNLOADING\" | \"PROCESSING\" | \"UPLOADING\" | \"SUCCESS\" | \"FAILED\";\n progress?: number;\n currentStep?: string | null;\n outputUrl?: string | null;\n thumbnailUrl?: string | null;\n quality?: string;\n sandbox?: boolean;\n errorMessage?: string | null;\n createdAt: string;\n completedAt?: string | null;\n}\n\nexport interface WeviCreditBalance {\n plan: {\n slug: string;\n name: string;\n allowance: number | null;\n used: number;\n remaining: number | null;\n resetMode: \"lifetime\" | \"monthly\";\n periodStart: string | null;\n periodEnd: string | null;\n };\n purchased: { balance: number };\n totalAvailable: number | null;\n costs: Record<string, number>;\n packs: Array<{ id: string; name: string; credits: number; priceCents: number; description: string }>;\n topUpUrl: string;\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\n\nconst parameterValue = z.union([z.string(), z.number(), z.boolean(), z.null()]);\n\nconst sceneSchema = z.object({\n templateId: z.string().describe(\"Published template ID or slug for this scene\"),\n title: z.string().max(120).optional().describe(\"Optional scene title\"),\n voiceoverText: z\n .string()\n .max(600)\n .optional()\n .describe(\"Optional narration for this scene (voiceover is generated at export when enabled)\"),\n parameters: z\n .record(z.string(), parameterValue)\n .optional()\n .describe(\"Layer key → value map from wevi_get_template_schema (e.g. { TXTTYPINGVAR: 'Ship faster', CLRTEXTTYPINGVAR: '#F8FAFC' })\"),\n});\n\nexport function registerProjectTools(server: McpServer, client: WeviApiClient) {\n // 3. wevi_create_project\n server.tool(\n \"wevi_create_project\",\n [\n \"Create a Wevi video project from one or more published templates.\",\n \"Pass ALL scenes of the video in `scenes` (in order) — they are rendered and exported together as ONE concatenated video.\",\n \"Do not create one project per scene. All templates must share the same aspectRatio and must not require UI capture.\",\n \"The aspect ratio is taken from the templates automatically.\",\n ].join(\" \"),\n {\n title: z.string().max(160).optional().describe(\"Project title (e.g. 'Q3 Product Launch')\"),\n scenes: z\n .array(sceneSchema)\n .min(1)\n .max(12)\n .describe(\"Ordered scenes; each maps to one template with its parameters\"),\n brandId: z\n .string()\n .uuid()\n .optional()\n .describe(\"Optional Wevi brand ID. Defaults to your latest brand.\"),\n },\n async (args) => {\n try {\n const project = await client.createProject(args);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(\n {\n message: `Project created with ${project.sceneCount ?? project.scenes?.length ?? 0} scene(s).`,\n projectId: project.id,\n title: project.title,\n status: project.status,\n aspectRatio: project.aspectRatio,\n sandbox: project.sandbox === true,\n scenes: project.scenes ?? [],\n nextStep:\n project.nextStep ??\n \"Call wevi_trigger_render with this projectId to render and export one video.\",\n },\n null,\n 2,\n ),\n },\n ],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error creating project: ${msg}` }],\n };\n }\n },\n );\n\n // 4. wevi_get_project\n server.tool(\n \"wevi_get_project\",\n \"Inspect an existing Wevi project: scenes, layer values, lifecycle status and render state.\",\n {\n projectId: z.string().describe(\"Wevi project ID\"),\n },\n async (args) => {\n try {\n const project = await client.getProject(args.projectId);\n return {\n content: [{ type: \"text\", text: JSON.stringify(project, null, 2) }],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error fetching project: ${msg}` }],\n };\n }\n },\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\nimport { WeviPublishStatus } from \"../types/index.js\";\n\n/** Keep in-tool waits short: MCP clients often time out a single call at ~60s. */\nconst DEFAULT_WAIT_SECONDS = 45;\nconst MAX_WAIT_SECONDS = 55;\n\nfunction formatPublishStatus(status: WeviPublishStatus, projectId: string) {\n const base = {\n projectId,\n phase: status.phase,\n message: status.message,\n sandbox: status.sandbox,\n render: status.render\n ? {\n state: status.render.state,\n progressPercent: status.render.progressPercent,\n doneScenes: status.render.doneScenes,\n sceneCount: status.render.sceneCount,\n failedScenes: status.render.failedScenes,\n failures: status.render.failures,\n }\n : null,\n export: status.export\n ? {\n id: status.export.id,\n status: status.export.status,\n progress: status.export.progress,\n currentStep: status.export.currentStep,\n quality: status.export.quality,\n errorMessage: status.export.errorMessage,\n }\n : null,\n };\n\n if (status.phase === \"completed\") {\n return {\n ...base,\n videoUrl: status.videoUrl,\n thumbnailUrl: status.thumbnailUrl,\n durationSeconds: status.export?.durationSeconds ?? null,\n note: status.sandbox\n ? \"Sandbox (wevi_test_ key): this video is watermarked and capped at 720p. Use a wevi_live_ key for production output.\"\n : undefined,\n };\n }\n\n if (status.phase === \"rendering\" || status.phase === \"exporting\") {\n return {\n ...base,\n nextStep: `Still ${status.phase}. Call wevi_get_render_status with projectId \"${projectId}\" again in ~10 seconds.`,\n };\n }\n\n return base;\n}\n\nexport function registerRenderTools(server: McpServer, client: WeviApiClient) {\n // 5. wevi_trigger_render\n server.tool(\n \"wevi_trigger_render\",\n [\n \"Render every scene of a project and export them as ONE concatenated MP4 (music + voiceover mixed in).\",\n \"Waits up to `waitSeconds` for completion; if the video is not ready yet it returns the current phase and you should poll wevi_get_render_status.\",\n \"Sandbox keys (wevi_test_) produce watermarked 720p videos without using credits, capped at 20 scene renders and 5 exports per key per UTC day and 4 scenes per project.\",\n ].join(\" \"),\n {\n projectId: z.string().describe(\"Project ID from wevi_create_project\"),\n quality: z\n .enum([\"720p\", \"1080p\", \"4K\"])\n .optional()\n .default(\"1080p\")\n .describe(\"Export quality. Free plans and sandbox keys are capped at 720p.\"),\n includeMusic: z.boolean().optional().default(true).describe(\"Mix background music\"),\n includeVoiceover: z\n .boolean()\n .optional()\n .default(true)\n .describe(\"Generate and mix voiceover from each scene's voiceoverText\"),\n waitSeconds: z\n .number()\n .min(0)\n .max(MAX_WAIT_SECONDS)\n .optional()\n .default(DEFAULT_WAIT_SECONDS)\n .describe(`Seconds to wait in this call before returning progress (0-${MAX_WAIT_SECONDS}, default ${DEFAULT_WAIT_SECONDS})`),\n },\n async (args) => {\n try {\n let status = await client.publishProject(args.projectId, {\n quality: args.quality,\n includeMusic: args.includeMusic,\n includeVoiceover: args.includeVoiceover,\n });\n\n if (\n args.waitSeconds > 0 &&\n (status.phase === \"rendering\" || status.phase === \"exporting\")\n ) {\n status = await client.waitForPublish(args.projectId, args.waitSeconds);\n }\n\n const isFailure = status.phase === \"failed\" || status.phase === \"render_failed\";\n return {\n ...(isFailure ? { isError: true as const } : {}),\n content: [\n {\n type: \"text\",\n text: JSON.stringify(formatPublishStatus(status, args.projectId), null, 2),\n },\n ],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error triggering render: ${msg}` }],\n };\n }\n },\n );\n\n // 6. wevi_get_render_status\n server.tool(\n \"wevi_get_render_status\",\n [\n \"Check render + export progress for a project started with wevi_trigger_render and get the final video URL when ready.\",\n \"Optionally waits up to `waitSeconds` before returning. Pass `exportId` instead to look up a single export record.\",\n ].join(\" \"),\n {\n projectId: z.string().optional().describe(\"Project ID (preferred)\"),\n exportId: z.string().optional().describe(\"Export ID (legacy lookup of one export record)\"),\n waitSeconds: z\n .number()\n .min(0)\n .max(MAX_WAIT_SECONDS)\n .optional()\n .default(0)\n .describe(`Seconds to wait for completion before returning (0-${MAX_WAIT_SECONDS})`),\n },\n async (args) => {\n try {\n if (args.projectId) {\n const status =\n args.waitSeconds > 0\n ? await client.waitForPublish(args.projectId, args.waitSeconds)\n : await client.getPublishStatus(args.projectId);\n const isFailure = status.phase === \"failed\" || status.phase === \"render_failed\";\n return {\n ...(isFailure ? { isError: true as const } : {}),\n content: [\n {\n type: \"text\",\n text: JSON.stringify(formatPublishStatus(status, args.projectId), null, 2),\n },\n ],\n };\n }\n\n if (args.exportId) {\n const record = await client.getRenderStatus(args.exportId);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(\n {\n exportId: record.id,\n projectId: record.projectId,\n status: record.status,\n progress: record.progress ?? null,\n currentStep: record.currentStep ?? null,\n quality: record.quality ?? null,\n sandbox: record.sandbox === true,\n videoUrl: record.status === \"SUCCESS\" ? record.outputUrl ?? null : null,\n thumbnailUrl: record.thumbnailUrl ?? null,\n errorMessage: record.errorMessage ?? null,\n completedAt: record.completedAt ?? null,\n },\n null,\n 2,\n ),\n },\n ],\n };\n }\n\n return {\n isError: true,\n content: [{ type: \"text\", text: \"Provide projectId (preferred) or exportId.\" }],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error checking render status: ${msg}` }],\n };\n }\n },\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\nimport { WEVI_CAPABILITIES } from \"../capabilities.js\";\n\nexport function registerAiTools(server: McpServer, client: WeviApiClient) {\n // wevi_get_capabilities\n server.tool(\n \"wevi_get_capabilities\",\n [\n \"What Wevi can and cannot make, the questions to ask the user before building, supported aspect ratios, sandbox limits and credit costs.\",\n \"Call this first in a new conversation, and whenever a request sounds outside Wevi's scope (e.g. 'make a dance video', 'edit my footage', 'vertical video'). No API call is made.\",\n ].join(\" \"),\n {},\n async () => ({\n content: [{ type: \"text\", text: JSON.stringify({ ...WEVI_CAPABILITIES, sandboxKey: client.isSandbox }, null, 2) }],\n }),\n );\n\n // 0. wevi_get_credits\n server.tool(\n \"wevi_get_credits\",\n [\n \"Show the API credit balance for this key: plan allowance used/remaining, purchased credits, what each action costs, and the top-up link.\",\n \"Call it before a large batch, or when a tool fails with 402. Sandbox keys (wevi_test_) do not use credits.\",\n ].join(\" \"),\n {},\n async () => {\n try {\n const balance = await client.getCredits();\n const unlimited = balance.totalAvailable === null;\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(\n {\n sandboxKey: client.isSandbox,\n plan: balance.plan,\n purchasedCredits: balance.purchased.balance,\n totalAvailable: unlimited ? \"unlimited\" : balance.totalAvailable,\n costs: balance.costs,\n packs: balance.packs.map((pack) => ({\n id: pack.id,\n name: pack.name,\n credits: pack.credits,\n price: `$${(pack.priceCents / 100).toFixed(2)}`,\n })),\n topUpUrl: balance.topUpUrl,\n note: client.isSandbox\n ? \"This is a sandbox key: renders are free, watermarked and capped daily. Credits shown apply to your live keys.\"\n : \"A 3-scene 1080p video costs 5 credits (3 renders + 2 export).\",\n },\n null,\n 2,\n ),\n },\n ],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return { isError: true, content: [{ type: \"text\", text: `Error fetching credits: ${msg}` }] };\n }\n },\n );\n\n // 7. wevi_generate_storyboard\n server.tool(\n \"wevi_generate_storyboard\",\n [\n \"Draft a multi-scene storyboard (scene titles, purposes, on-screen text and voiceover) from a brief.\",\n \"Use the draft to choose templates with wevi_list_templates and fill their parameters in wevi_create_project.\",\n ].join(\" \"),\n {\n prompt: z\n .string()\n .describe(\"Marketing goal, product description, audience and tone (e.g. '30-second SaaS promo for an AI email writer')\"),\n brandName: z.string().optional().describe(\"Brand or product name\"),\n brandUrl: z.string().url().optional().describe(\"Website URL used for brand context\"),\n brandVoice: z.string().optional().describe(\"Tone of voice (e.g. 'confident, modern, energetic')\"),\n maxScenes: z\n .number()\n .int()\n .min(3)\n .max(12)\n .optional()\n .describe(\"Soft cap on scene count (3-12)\"),\n },\n async (args) => {\n try {\n const result = await client.generateStoryboard(args);\n return {\n content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error generating storyboard: ${msg}` }],\n };\n }\n },\n );\n}\n","/**\n * The capability statement is the agent's map of Wevi: what it makes, what it\n * cannot make, and what to ask before building. It is sent to clients as the\n * MCP server `instructions` on connect and is also returned by the\n * `wevi_get_capabilities` tool for clients that ignore instructions.\n */\nexport const WEVI_CAPABILITIES = {\n summary:\n \"Wevi turns published motion templates into short marketing videos for software products: launch videos, feature explainers, product showcases, social promos, and call-to-action outros. Each scene is a pre-designed motion template (roughly 3 to 15 seconds) whose text, colors, logos, sliders and image slots you fill in. Wevi renders every scene in the cloud and joins them into one MP4 with background music and an AI voiceover.\",\n canDo: [\n \"Multi-scene videos where every scene is a published Wevi template with your copy, brand colors and logo.\",\n \"16:9 (1920x1080) widescreen videos and 16:12 (1920x1440) desktop-app frame videos. All scenes in one video must share one ratio.\",\n \"AI voiceover generated from each scene's voiceoverText, mixed with a music track at export.\",\n \"Web screenshots (wevi_capture_web_ui) used as image layers in templates that accept an image.\",\n \"AI storyboard drafts (wevi_generate_storyboard) to plan scenes, copy and narration from a brief.\",\n \"Exports at 720p, 1080p or 4K, quality permitting by plan.\",\n ],\n cannotDo: [\n \"Generate free-form or generative video: no dance videos, people, characters, animals, scenery, or anything not built from a template.\",\n \"Upload or edit the user's own video footage, or stitch external clips.\",\n \"Change a template's animation, layout, duration or camera motion; only its exposed layers are editable.\",\n \"Render templates that need an interactive screen capture (requiresUiCapture = true) from the API. Those work only in the Wevi web app.\",\n \"Mix aspect ratios in one video, or output vertical 9:16 video.\",\n \"Clone a specific voice; voiceover uses Wevi's voice library.\",\n ],\n askBeforeBuilding: [\n \"What is the product or brand, and is there a website to pull colors and a logo from?\",\n \"What is the goal of the video: launch, feature explainer, social promo, or a call to action?\",\n \"Who is the audience and what tone fits (confident, playful, technical)?\",\n \"How long, or how many scenes? Typical videos are 3 to 6 scenes, 15 to 45 seconds.\",\n \"Key messages or on-screen text for each scene, if the user has them; otherwise draft with wevi_generate_storyboard and confirm.\",\n \"Should there be a voiceover, and any brand colors (hex) to apply?\",\n \"Which aspect ratio: 16:9 for general use, 16:12 for desktop-app focused frames.\",\n ],\n workflow: [\n \"1. wevi_list_templates to see what exists; group by aspect ratio and read purpose, sceneIntent and avoid to match scenes to roles (hook, feature, proof, CTA).\",\n \"2. wevi_get_template_schema for each chosen template to get exact layer keys and constraints.\",\n \"3. wevi_create_project with ALL scenes in one project. Never one project per scene.\",\n \"4. wevi_trigger_render, then wevi_get_render_status until phase is completed; share videoUrl.\",\n \"Before large batches, wevi_get_credits. Sandbox keys (wevi_test_) are free, watermarked, 720p, and capped daily.\",\n ],\n limits: {\n aspectRatios: [\"16:9\", \"16:12\"],\n maxScenesPerProject: 12,\n sandbox: { sceneRendersPerDay: 20, exportsPerDay: 5, maxScenesPerProject: 4 },\n credits: { sceneRender: 1, export720p: 1, export1080p: 2, export4K: 4, storyboardDraft: 1, webCapture: 1 },\n },\n} as const;\n\nexport function buildServerInstructions() {\n const c = WEVI_CAPABILITIES;\n return [\n c.summary,\n \"\",\n \"Wevi CAN: \" + c.canDo.map((line) => `- ${line}`).join(\"\\n\"),\n \"\",\n \"Wevi CANNOT: \" + c.cannotDo.map((line) => `- ${line}`).join(\"\\n\"),\n \"\",\n \"If a request is outside these capabilities (e.g. a dance video, editing the user's footage, vertical video), say so plainly and offer what Wevi can do instead. Do not attempt it.\",\n \"\",\n \"Before building, ask the user what is missing from: \" + c.askBeforeBuilding.map((q) => `- ${q}`).join(\"\\n\"),\n \"\",\n \"Workflow: \" + c.workflow.map((step) => `- ${step}`).join(\"\\n\"),\n ].join(\"\\n\");\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { z } from \"zod\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\n\nexport function registerBrowseTools(server: McpServer, client: WeviApiClient) {\n // 8. wevi_capture_web_ui\n server.tool(\n \"wevi_capture_web_ui\",\n \"Capture a clean, high-resolution web screenshot asset from a website URL to use as an image layer in video templates.\",\n {\n url: z\n .string()\n .url()\n .describe(\"The website URL to capture (e.g. 'https://stripe.com')\"),\n selector: z\n .string()\n .optional()\n .describe(\"Optional CSS selector to crop a specific component or hero element\"),\n viewport: z\n .enum([\"desktop\", \"mobile\", \"tablet\"])\n .optional()\n .default(\"desktop\")\n .describe(\"Target viewport size: 'desktop' (1440x900), 'tablet' (768x1024), or 'mobile' (375x812)\"),\n },\n async (args) => {\n try {\n const result = await client.captureWebUi(args);\n return {\n content: [\n {\n type: \"text\",\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n } catch (err: unknown) {\n const msg = err instanceof Error ? err.message : String(err);\n return {\n isError: true,\n content: [{ type: \"text\", text: `Error capturing web UI: ${msg}` }],\n };\n }\n },\n );\n}\n","import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { WeviApiClient } from \"../client/wevi-api-client.js\";\nimport { registerTemplateTools } from \"./templates.tools.js\";\nimport { registerProjectTools } from \"./projects.tools.js\";\nimport { registerRenderTools } from \"./renders.tools.js\";\nimport { registerAiTools } from \"./ai.tools.js\";\nimport { registerBrowseTools } from \"./browse.tools.js\";\n\nexport function registerAllTools(server: McpServer, client: WeviApiClient) {\n registerTemplateTools(server, client);\n registerProjectTools(server, client);\n registerRenderTools(server, client);\n registerAiTools(server, client);\n registerBrowseTools(server, client);\n}\n"],"mappings":";;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,OAAO,YAAY;;;ACSnB,IAAM,aAAa;AAEnB,SAAS,SAAS,OAAyC;AACzD,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO,CAAC;AACzE,SAAO;AACT;AAEO,IAAM,gBAAN,MAAoB;AAAA,EACR;AAAA,EACA;AAAA,EAEjB,YAAY,QAAoB;AAC9B,SAAK,SAAS,OAAO,OAAO,KAAK;AACj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E3C,IAAI,CAAC,QAAQ;AACX,UAAQ,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI,cAAc;AAAA,EAC/B,QAAQ,UAAU;AAAA,EAClB;AACF,CAAC;AAED,IAAI,OAAO,WAAW;AACpB,UAAQ,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,SAAS;AAAA,EACX;AAAA,EACA;AAAA;AAAA;AAAA,IAGE,cAAc,wBAAwB;AAAA,EACxC;AACF;AAGA,iBAAiB,QAAQ,MAAM;AAE/B,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC9B,UAAQ,OAAO,MAAM,uDAAuD,MAAM;AAAA,CAAI;AACxF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,OAAO,MAAM,kCAAkC,KAAK;AAAA,CAAI;AAChE,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["server","client","z","server","client","z","server","client","z","server","client","z","z","server","client","server","client"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/sdk/server/stdio.js\";\nimport dotenv from \"dotenv\";\nimport { WeviApiClient } from \"./client/wevi-api-client.js\";\nimport { registerAllTools } from \"./tools/index.js\";\nimport { buildServerInstructions } from \"./capabilities.js\";\nimport { BRAND_NAME, BRAND_WEBSITE, serverIcons } from \"./brand.js\";\n\ndotenv.config();\n\nconst apiKey = process.env.WEVI_API_KEY;\nconst apiUrl = process.env.WEVI_API_URL || \"https://api-v2.wevi.ai/api/v2\";\n\nif (!apiKey) {\n process.stderr.write(\n \"[Wevi MCP Warning] WEVI_API_KEY is not set. MCP tools will fail until an API key is provided in your MCP configuration.\\nGet your key at: https://app.wevi.ai/app/profile?id=api-keys\\n\",\n );\n}\n\nconst client = new WeviApiClient({\n apiKey: apiKey || \"\",\n apiUrl,\n});\n\nif (client.isSandbox) {\n process.stderr.write(\n \"[Wevi MCP] Sandbox key detected (wevi_test_): renders are watermarked, capped at 720p and do not use credits.\\n\",\n );\n}\n\nconst server = new McpServer(\n {\n name: \"Wevi\",\n title: BRAND_NAME,\n version: \"0.2.1\",\n websiteUrl: BRAND_WEBSITE,\n // Local stdio server has no origin of its own; point at the hosted assets.\n icons: serverIcons(\"https://mcp.wevi.ai\"),\n },\n {\n // Sent to the client on connect; assistants that honour MCP instructions\n // learn what Wevi can and cannot make before the first tool call.\n instructions: buildServerInstructions(),\n },\n);\n\n// Register all video automation tools\nregisterAllTools(server, client);\n\nasync function main() {\n const transport = new StdioServerTransport();\n await server.connect(transport);\n process.stderr.write(`[Wevi MCP Server] Started successfully connected to ${apiUrl}\\n`);\n}\n\nmain().catch((error) => {\n process.stderr.write(`[Wevi MCP Server Fatal Error]: ${error}\\n`);\n process.exit(1);\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,OAAO,YAAY;AAMnB,OAAO,OAAO;AAEd,IAAM,SAAS,QAAQ,IAAI;AAC3B,IAAM,SAAS,QAAQ,IAAI,gBAAgB;AAE3C,IAAI,CAAC,QAAQ;AACX,UAAQ,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI,cAAc;AAAA,EAC/B,QAAQ,UAAU;AAAA,EAClB;AACF,CAAC;AAED,IAAI,OAAO,WAAW;AACpB,UAAQ,OAAO;AAAA,IACb;AAAA,EACF;AACF;AAEA,IAAM,SAAS,IAAI;AAAA,EACjB;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,YAAY;AAAA;AAAA,IAEZ,OAAO,YAAY,qBAAqB;AAAA,EAC1C;AAAA,EACA;AAAA;AAAA;AAAA,IAGE,cAAc,wBAAwB;AAAA,EACxC;AACF;AAGA,iBAAiB,QAAQ,MAAM;AAE/B,eAAe,OAAO;AACpB,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAC9B,UAAQ,OAAO,MAAM,uDAAuD,MAAM;AAAA,CAAI;AACxF;AAEA,KAAK,EAAE,MAAM,CAAC,UAAU;AACtB,UAAQ,OAAO,MAAM,kCAAkC,KAAK;AAAA,CAAI;AAChE,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wevi/mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Official Model Context Protocol (MCP) server for Wevi — AI Video Generation Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"wevi-mcp": "dist/index.js",
|
|
8
|
-
"mcp": "dist/index.js"
|
|
8
|
+
"mcp": "dist/index.js",
|
|
9
|
+
"wevi-mcp-http": "dist/http.js"
|
|
9
10
|
},
|
|
10
11
|
"main": "./dist/index.js",
|
|
11
12
|
"types": "./dist/index.d.ts",
|
|
12
13
|
"files": [
|
|
13
14
|
"dist",
|
|
14
|
-
"README.md"
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
15
17
|
],
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "tsup",
|
|
18
20
|
"prepublishOnly": "npm run build",
|
|
19
21
|
"dev": "tsup --watch",
|
|
20
|
-
"start": "node dist/index.js"
|
|
22
|
+
"start": "node dist/index.js",
|
|
23
|
+
"start:http": "node dist/http.js",
|
|
24
|
+
"dev:http": "tsup && node dist/http.js"
|
|
21
25
|
},
|
|
22
26
|
"repository": {
|
|
23
27
|
"type": "git",
|