generateWork
Generate project-specific content using the DeepWriter MCP Server by providing an API key and project ID. Customize output by adjusting default settings.
Instructions
Generate content for a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | The DeepWriter API key for authentication. | |
| is_default | No | Whether to use default settings (optional, defaults to true). | |
| project_id | Yes | The ID of the project to generate work for. |
Implementation Reference
- src/tools/generateWork.ts:26-87 (handler)The primary handler for the generateWizardWork tool (note: tool name is generateWizardWork, implemented in generateWork.ts file). It handles input validation, calls the DeepWriter API client, and returns MCP-formatted response.export const generateWizardWorkTool = { name: "generateWizardWork", description: "Generate content using the enhanced wizard workflow with comprehensive parameter support", async execute(args: GenerateWizardWorkInputArgs): Promise<GenerateWizardWorkMcpOutput> { console.error(`Executing generateWizardWork tool for project ID: ${args.project_id}...`); // Get API key from environment const apiKey = process.env.DEEPWRITER_API_KEY; if (!apiKey) { throw new Error("DEEPWRITER_API_KEY environment variable is required"); } if (!args.project_id) { throw new Error("Missing required argument: project_id"); } if (!args.prompt) { throw new Error("Missing required argument: prompt"); } if (!args.author) { throw new Error("Missing required argument: author"); } if (!args.email) { throw new Error("Missing required argument: email"); } try { // Prepare the parameters for the API client (API expects projectId not project_id) const wizardParams = { projectId: args.project_id, // Convert project_id to projectId for API prompt: args.prompt, author: args.author, email: args.email, outline_text: args.outline_text, has_technical_diagrams: args.has_technical_diagrams, has_tableofcontents: args.has_tableofcontents, use_web_research: args.use_web_research, page_length: args.page_length, questions_and_answers: args.questions_and_answers, mode: args.mode, isDefault: args.isDefault, max_pages: args.max_pages, free_trial_mode: args.free_trial_mode }; // Call the actual API client function const apiResponse = await apiClient.generateWizardWork(apiKey, wizardParams); console.error(`API call successful for generateWizardWork. Job ID: ${apiResponse.jobId}`); // Transform the API response into MCP format const mcpResponse: GenerateWizardWorkMcpOutput = { content: [ { type: 'text', text: `Successfully started wizard work generation for project ID ${args.project_id}. Job ID: ${apiResponse.jobId}. Message: ${apiResponse.message}` } ] }; return mcpResponse; } catch (error) { console.error(`Error executing generateWizardWork tool: ${error}`); const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to generate wizard work for project ID ${args.project_id}: ${errorMessage}`); } } };
- src/api/deepwriterClient.ts:247-275 (helper)API client helper function that makes the HTTP POST request to the external DeepWriter API endpoint /api/generateWizardWork.export async function generateWizardWork( apiKey: string, params: GenerateWizardWorkInputBody ): Promise<GenerateWizardWorkResponse> { console.error(`Calling actual generateWizardWork API for project ID: ${params.projectId}`); if (!apiKey) { throw new Error("API key is required for generateWizardWork"); } if (!params.projectId) { throw new Error("Project ID is required for generateWizardWork"); } if (!params.prompt) { throw new Error("Prompt is required for generateWizardWork"); } if (!params.author) { throw new Error("Author is required for generateWizardWork"); } if (!params.email) { throw new Error("Email is required for generateWizardWork"); } // Add isDefault: true as required by the API (from demo script) const requestBody = { ...params, isDefault: true }; return makeApiRequest<GenerateWizardWorkResponse>('/api/generateWizardWork', apiKey, 'POST', requestBody); }
- src/index.ts:313-346 (registration)Registration of the generateWizardWork tool in the MCP server, including inline Zod input schema and execution wrapper.server.tool( generateWizardWorkTool.name, generateWizardWorkTool.description, { project_id: z.string().describe("The ID of the project to generate work for."), prompt: z.string().describe("Main generation prompt describing the content to create."), author: z.string().describe("Author name for the document."), email: z.string().email().describe("Author email address."), outline_text: z.string().optional().describe("Additional outline instructions or structure guidance."), has_technical_diagrams: z.enum(['auto', 'on', 'off']).optional().describe("Whether to include technical diagrams."), has_tableofcontents: z.enum(['auto', 'on', 'off']).optional().describe("Whether to include table of contents."), use_web_research: z.enum(['auto', 'on', 'off']).optional().describe("Whether to use web research."), page_length: z.string().optional().describe("Desired document length specification."), questions_and_answers: z.string().optional().describe("JSON string of follow-up questions and answers."), mode: z.enum(['deepwriter', 'benchmark', 'romance', 'homework', 'deepseek', 'skunkworks']).optional().describe("Content generation mode."), isDefault: z.boolean().optional().describe("Whether to use default system API key."), max_pages: z.number().min(1).max(350).optional().describe("Maximum pages allowed for generation."), free_trial_mode: z.enum(['true', 'false']).optional().describe("Whether user is on free trial.") }, async (params: GenerateWizardWorkParams) => { console.error(`SDK invoking ${generateWizardWorkTool.name}...`); const result = await generateWizardWorkTool.execute(params); return { content: result.content, annotations: { title: "Generate Wizard Work", readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: true } }; } );
- src/index.ts:146-161 (schema)Zod input schema definition for the generateWizardWork tool (defined but not directly used in registration; inline schema used instead).const generateWizardWorkInputSchema = z.object({ project_id: z.string().describe("The ID of the project to generate work for."), prompt: z.string().describe("Main generation prompt describing the content to create."), author: z.string().describe("Author name for the document."), email: z.string().email().describe("Author email address."), outline_text: z.string().optional().describe("Additional outline instructions or structure guidance."), has_technical_diagrams: z.enum(['auto', 'on', 'off']).optional().describe("Whether to include technical diagrams."), has_tableofcontents: z.enum(['auto', 'on', 'off']).optional().describe("Whether to include table of contents."), use_web_research: z.enum(['auto', 'on', 'off']).optional().describe("Whether to use web research."), page_length: z.string().optional().describe("Desired document length specification."), questions_and_answers: z.string().optional().describe("JSON string of follow-up questions and answers."), mode: z.enum(['deepwriter', 'benchmark', 'romance', 'homework', 'deepseek', 'skunkworks']).optional().describe("Content generation mode."), isDefault: z.boolean().optional().describe("Whether to use default system API key."), max_pages: z.number().min(1).max(350).optional().describe("Maximum pages allowed for generation."), free_trial_mode: z.enum(['true', 'false']).optional().describe("Whether user is on free trial.") });
- src/tools/generateWork.ts:4-19 (schema)TypeScript input interface for the generateWizardWork tool handler.interface GenerateWizardWorkInputArgs { project_id: string; prompt: string; author: string; email: string; outline_text?: string; has_technical_diagrams?: 'auto' | 'on' | 'off'; has_tableofcontents?: 'auto' | 'on' | 'off'; use_web_research?: 'auto' | 'on' | 'off'; page_length?: string; questions_and_answers?: string; // JSON string mode?: 'deepwriter' | 'benchmark' | 'romance' | 'homework' | 'deepseek' | 'skunkworks'; isDefault?: boolean; max_pages?: number; free_trial_mode?: 'true' | 'false'; }