updateProject
Modify an existing DeepWriter project by updating fields such as title, author, prompts, AI model, and stylistic details using the provided project ID and API key.
Instructions
Update an existing project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | Yes | The DeepWriter API key for authentication. | |
| project_id | Yes | The ID of the project to update. | |
| updates | Yes | Object containing fields to update. |
Implementation Reference
- src/tools/updateProject.ts:29-69 (handler)Core handler for the 'updateProject' MCP tool: validates inputs (project_id, updates), retrieves API key from env, calls deepwriterClient.updateProject API, formats success/error into MCP content structure.export const updateProjectTool = { name: "updateProject", description: "Update an existing project", // TODO: Add input/output schema validation if needed async execute(args: UpdateProjectInputArgs): Promise<UpdateProjectMcpOutput> { console.error(`Executing updateProject 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.updates || Object.keys(args.updates).length === 0) { throw new Error("Missing required argument: updates (must be a non-empty object)"); } try { // Call the actual API client function // Note: The API client expects ProjectUpdates type, which matches ProjectUpdatesArgs here const apiResponse = await apiClient.updateProject(apiKey, args.project_id, args.updates); console.error(`API call successful for updateProject. Updated project ID: ${apiResponse.id}`); // Transform the API response into MCP format const mcpResponse: UpdateProjectMcpOutput = { content: [ { type: 'text', text: `Successfully updated project with ID: ${apiResponse.id}` } ] }; return mcpResponse; // Return the MCP-compliant structure } catch (error) { console.error(`Error executing updateProject tool: ${error}`); // Format error for MCP response const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to update project ID ${args.project_id}: ${errorMessage}`); } } };
- src/index.ts:256-290 (registration)MCP server registration of 'updateProject' tool: defines inline Zod input schema, provides wrapper async handler that logs invocation and delegates execution to updateProjectTool.execute, adds tool annotations.server.tool( updateProjectTool.name, updateProjectTool.description, { project_id: z.string().describe("The ID of the project to update."), updates: z.object({ author: z.string().optional().describe("Author of the work"), email: z.string().email().optional().describe("Email associated with the project"), model: z.string().optional().describe("AI model used"), outline_text: z.string().optional().describe("Outline text"), prompt: z.string().optional().describe("Main prompt for generation"), style_text: z.string().optional().describe("Stylistic guidance text"), supplemental_info: z.string().optional().describe("Supplemental information"), title: z.string().optional().describe("New title for the project"), work_description: z.string().optional().describe("Description of the work"), work_details: z.string().optional().describe("Detailed information about the work"), work_vision: z.string().optional().describe("Vision for the work") }).describe("Object containing fields to update.") }, async ({ project_id, updates }: UpdateProjectParams) => { console.error(`SDK invoking ${updateProjectTool.name}...`); const result = await updateProjectTool.execute({ project_id, updates }); return { content: result.content, annotations: { title: "Update Project", readOnlyHint: false, destructiveHint: false, // Modifies but doesn't destroy idempotentHint: true, // Same updates produce same result openWorldHint: false } }; } );
- src/index.ts:123-140 (schema)Zod schema definitions for updateProject tool inputs: projectUpdatesSchema for the nested 'updates' object and updateProjectInputSchema combining project_id with updates (note: defined but not directly used in registration).const projectUpdatesSchema = z.object({ author: z.string().optional().describe("Author of the work"), email: z.string().email().optional().describe("Email associated with the project"), model: z.string().optional().describe("AI model used"), outline_text: z.string().optional().describe("Outline text"), prompt: z.string().optional().describe("Main prompt for generation"), style_text: z.string().optional().describe("Stylistic guidance text"), supplemental_info: z.string().optional().describe("Supplemental information"), title: z.string().optional().describe("New title for the project"), work_description: z.string().optional().describe("Description of the work"), work_details: z.string().optional().describe("Detailed information about the work"), work_vision: z.string().optional().describe("Vision for the work") }).describe("Object containing fields to update."); const updateProjectInputSchema = z.object({ project_id: z.string().describe("The ID of the project to update."), updates: projectUpdatesSchema // Use the nested schema for updates });
- src/api/deepwriterClient.ts:175-193 (helper)Helper function in API client that performs the actual PATCH request to DeepWriter /api/updateProject endpoint, including input validation and using makeApiRequest utility.export async function updateProject( apiKey: string, projectId: string, updates: ProjectUpdates ): Promise<UpdateProjectResponse> { console.error(`Calling actual updateProject API for project ID: ${projectId}`); if (!apiKey) { throw new Error("API key is required for updateProject"); } if (!projectId) { throw new Error("Project ID is required for updateProject"); } if (!updates || Object.keys(updates).length === 0) { throw new Error("Updates object cannot be empty for updateProject"); } const endpoint = `/api/updateProject?projectId=${encodeURIComponent(projectId)}`; return makeApiRequest<UpdateProjectResponse>(endpoint, apiKey, 'PATCH', updates); }
- src/tools/updateProject.ts:5-22 (schema)TypeScript interfaces defining input args for updateProject tool handler (ProjectUpdatesArgs matching API, UpdateProjectInputArgs for execute function).interface ProjectUpdatesArgs { author?: string; email?: string; model?: string; outline_text?: string; prompt?: string; style_text?: string; supplemental_info?: string; title?: string; work_description?: string; work_details?: string; work_vision?: string; } interface UpdateProjectInputArgs { project_id: string; updates: ProjectUpdatesArgs; }