getProjectDetails
Retrieve comprehensive project details using an API key and project ID to access specific information through the DeepWriter MCP Server interface.
Instructions
Get detailed information about a specific 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 retrieve details for. |
Implementation Reference
- src/tools/getProjectDetails.ts:13-59 (handler)The main handler for the 'getProjectDetails' MCP tool. It validates inputs, calls the DeepWriter API client, transforms the response into MCP content format, and handles errors.export const getProjectDetailsTool = { name: "getProjectDetails", description: "Get detailed information about a specific project", // TODO: Add input/output schema validation if needed async execute(args: GetProjectDetailsInput): Promise<GetProjectDetailsMcpOutput> { console.error(`Executing getProjectDetails 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"); } try { // Call the actual API client function const apiResponse = await apiClient.getProjectDetails(apiKey, args.project_id); console.error(`API call successful for getProjectDetails.`); // Transform the API response into MCP format const mcpResponse: GetProjectDetailsMcpOutput = { content: [ { type: 'text', text: `Project ID: ${apiResponse.project.id}` }, { type: 'text', text: `Title: ${apiResponse.project.title}` }, { type: 'text', text: `Created At: ${apiResponse.project.created_at}` }, { type: 'text', text: `Updated At: ${apiResponse.project.updated_at}` }, // Include optional fields if they exist ...(apiResponse.project.author ? [{ type: 'text' as const, text: `Author: ${apiResponse.project.author}` }] : []), ...(apiResponse.project.model ? [{ type: 'text' as const, text: `Model: ${apiResponse.project.model}` }] : []), // Display prompt (might be large/complex) { type: 'text', text: `Prompt: ${JSON.stringify(apiResponse.project.prompt ?? 'N/A', null, 2)}` }, // Add other relevant fields as needed ...(apiResponse.project.work_description ? [{ type: 'text' as const, text: `Work Description: ${apiResponse.project.work_description}` }] : []), ] }; return mcpResponse; // Return the MCP-compliant structure } catch (error) { console.error(`Error executing getProjectDetails tool: ${error}`); // Format error for MCP response const errorMessage = error instanceof Error ? error.message : String(error); throw new Error(`Failed to get project details for ID ${args.project_id}: ${errorMessage}`); } } };
- src/tools/getProjectDetails.ts:3-11 (schema)TypeScript interfaces defining the input parameters and MCP-compliant output structure for the getProjectDetails tool.// Define input/output types based on schema (API key from environment) interface GetProjectDetailsInput { project_id: string; } // Define the MCP-compliant output structure interface GetProjectDetailsMcpOutput { content: { type: 'text'; text: string }[]; }
- src/index.ts:211-231 (registration)Registration of the getProjectDetails tool with the MCP server using server.tool(), including inline Zod input schema and annotations.server.tool( getProjectDetailsTool.name, getProjectDetailsTool.description, { project_id: z.string().describe("The ID of the project to retrieve details for.") }, async ({ project_id }: GetProjectDetailsParams) => { console.error(`SDK invoking ${getProjectDetailsTool.name}...`); const result = await getProjectDetailsTool.execute({ project_id }); return { content: result.content, annotations: { title: "Get Project Details", readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false } }; } );
- src/api/deepwriterClient.ts:116-126 (helper)Helper function in the API client that performs the actual HTTP GET request to retrieve project details from the DeepWriter API.export async function getProjectDetails(apiKey: string, projectId: string): Promise<GetProjectDetailsResponse> { console.error(`Calling actual getProjectDetails API for project ID: ${projectId}`); if (!apiKey) { throw new Error("API key is required for getProjectDetails"); } if (!projectId) { throw new Error("Project ID is required for getProjectDetails"); } const endpoint = `/api/getProjectDetails?projectId=${encodeURIComponent(projectId)}`; return makeApiRequest<GetProjectDetailsResponse>(endpoint, apiKey, 'GET'); }