We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/naki0227/auto-cm-director'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
#!/usr/bin/env node
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
CallToolRequestSchema,
ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod";
import { exec } from "child_process";
import path from "path";
import util from "util";
import fs from "fs";
const execAsync = util.promisify(exec);
const server = new Server(
{
name: "auto-director-mcp",
version: "1.0.0",
},
{
capabilities: {
tools: {},
},
}
);
/**
* Tool Definitions
*/
server.setRequestHandler(ListToolsRequestSchema, async () => {
return {
tools: [
{
name: "generate_commercial",
description: "Generates a promotional video for a software project using Auto Director.",
inputSchema: {
type: "object",
properties: {
projectParams: {
type: "object",
properties: {
name: { type: "string", description: "Name of the project" },
theme: {
type: "string",
enum: ["cyberpunk", "minimal", "playful"],
description: "Visual theme for the video"
},
hook: { type: "string", description: "Opening hook text (short)" },
features: {
type: "array",
items: {
type: "object",
properties: {
title: { type: "string" },
subtitle: { type: "string" }
}
}
}
},
required: ["name", "theme"]
},
outputDir: {
type: "string",
description: "Absolute path to output directory"
}
},
required: ["projectParams", "outputDir"]
},
},
],
};
});
/**
* Tool Execution
*/
server.setRequestHandler(CallToolRequestSchema, async (request) => {
if (request.params.name === "generate_commercial") {
const { projectParams, outputDir } = request.params.arguments as any;
try {
// 1. Validate Output Dir
if (!fs.existsSync(outputDir)) {
fs.mkdirSync(outputDir, { recursive: true });
}
// 2. Generate director.json
const config = {
projectInfo: {
name: projectParams.name,
description: "Generated by MCP Agent"
},
style: {
theme: projectParams.theme,
primaryColor: "#ffffff",
accentColor: "#0070f3",
fontFamily: "Inter"
},
script: {
hook: projectParams.hook || "Hello World",
solution: "AI Generated Video",
features: projectParams.features || [],
cta: "Learn More"
},
durationInFrames: 900,
fps: 60
};
const configPath = path.join(outputDir, "director.json");
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
// 3. Render Video (Mocking the call for now as we don't assume full env in MCP context)
// In a real scenario, we would run `remotion render` here using the `auto-director` package
// For this MVP, we return the plan and config path.
return {
content: [
{
type: "text",
text: `Commercial configuration generated at ${configPath}.\nTo render, run: \`npx auto-director render --config ${configPath}\` (Feature coming soon)`,
},
],
};
} catch (error: any) {
return {
content: [
{
type: "text",
text: `Error generating commercial: ${error.message}`,
},
],
isError: true,
};
}
}
throw new Error("Tool not found");
});
// Export for Smithery capability scanning
export function createSandboxServer() {
return server;
}
/**
* Start Server
*/
async function runServer() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Auto Director MCP Server running on stdio");
}
// Only run if this file is the main entry point
// We check for various extensions to support local dev (ts-node), built (js), and bundled (cjs)
const entryFile = process.argv[1];
if (entryFile.includes("index.ts") || entryFile.includes("index.js") || entryFile.includes("index.cjs")) {
runServer().catch((error) => {
console.error("Fatal error in MCP server:", error);
process.exit(1);
});
}