Skip to main content
Glama
bsmi021

MCP Task Manager Server

by bsmi021

exportProject

Export a project's complete data set, including metadata, tasks, and dependencies, as a JSON string using the project ID.

Instructions

Exports the complete data set for a specified project as a JSON string. This includes project metadata, all tasks (hierarchically structured), and their dependencies. Requires the project ID. The format is fixed to JSON for V1. Returns the JSON string representing the project data.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
formatNoOptional format for the export. Currently only 'json' is supported (default).json
project_idYesThe unique identifier (UUID) of the project to export.

Implementation Reference

  • Defines TOOL_NAME, TOOL_DESCRIPTION, TOOL_PARAMS Zod schema for input validation, and ExportProjectArgs type for the exportProject tool.
    import { z } from 'zod';
    
    export const TOOL_NAME = "exportProject";
    
    export const TOOL_DESCRIPTION = `
    Exports the complete data set for a specified project as a JSON string.
    This includes project metadata, all tasks (hierarchically structured), and their dependencies.
    Requires the project ID. The format is fixed to JSON for V1.
    Returns the JSON string representing the project data.
    `;
    
    // Zod schema for the parameters, matching FR-009 and exportProjectTool.md spec
    export const TOOL_PARAMS = z.object({
        project_id: z.string()
            .uuid("The project_id must be a valid UUID.")
            .describe("The unique identifier (UUID) of the project to export."), // Required, UUID format
    
        format: z.literal('json') // Only allow 'json' for V1
            .optional()
            .default('json')
            .describe("Optional format for the export. Currently only 'json' is supported (default)."), // Optional, enum (fixed), default
    });
    
    // Define the expected type for arguments based on the Zod schema
    export type ExportProjectArgs = z.infer<typeof TOOL_PARAMS>;
  • The handler function for the exportProject tool. Processes arguments, calls ProjectService.exportProject, handles errors, and returns the JSON string in MCP format.
    const processRequest = async (args: ExportProjectArgs) => {
        logger.info(`[${TOOL_NAME}] Received request with args:`, args);
        try {
            // Zod schema ensures format is 'json' if provided, or defaults to 'json'
            const jsonString = await projectService.exportProject(args.project_id);
    
            // Format the successful response
            logger.info(`[${TOOL_NAME}] Successfully exported project ${args.project_id}`);
            return {
                content: [{
                    type: "text" as const,
                    text: jsonString // Return the JSON string directly
                }]
            };
        } catch (error: unknown) {
            // Handle potential errors
            logger.error(`[${TOOL_NAME}] Error processing request:`, error);
    
            if (error instanceof NotFoundError) {
                // Project not found
                throw new McpError(ErrorCode.InvalidParams, error.message);
            } else {
                // Generic internal error
                const message = error instanceof Error ? error.message : 'An unknown error occurred while exporting the project.';
                throw new McpError(ErrorCode.InternalError, message);
            }
        }
    };
  • Registers the exportProject tool with the MCP server using server.tool(), providing name, description, params schema, and handler.
    export const exportProjectTool = (server: McpServer, projectService: ProjectService): void => {
    
        const processRequest = async (args: ExportProjectArgs) => {
            logger.info(`[${TOOL_NAME}] Received request with args:`, args);
            try {
                // Zod schema ensures format is 'json' if provided, or defaults to 'json'
                const jsonString = await projectService.exportProject(args.project_id);
    
                // Format the successful response
                logger.info(`[${TOOL_NAME}] Successfully exported project ${args.project_id}`);
                return {
                    content: [{
                        type: "text" as const,
                        text: jsonString // Return the JSON string directly
                    }]
                };
            } catch (error: unknown) {
                // Handle potential errors
                logger.error(`[${TOOL_NAME}] Error processing request:`, error);
    
                if (error instanceof NotFoundError) {
                    // Project not found
                    throw new McpError(ErrorCode.InvalidParams, error.message);
                } else {
                    // Generic internal error
                    const message = error instanceof Error ? error.message : 'An unknown error occurred while exporting the project.';
                    throw new McpError(ErrorCode.InternalError, message);
                }
            }
        };
    
        // Register the tool with the server
        server.tool(TOOL_NAME, TOOL_DESCRIPTION, TOOL_PARAMS.shape, processRequest);
    
        logger.info(`[${TOOL_NAME}] Tool registered successfully.`);
    };
  • Core logic for exporting project data: fetches project metadata, tasks, dependencies, builds hierarchical structure with subtasks and deps, returns formatted JSON string.
    public async exportProject(projectId: string): Promise<string> {
        logger.info(`[ProjectService] Attempting to export project: ${projectId}`);
        const projectMetadata = this.projectRepository.findById(projectId);
        if (!projectMetadata) {
            logger.warn(`[ProjectService] Project not found for export: ${projectId}`);
            throw new NotFoundError(`Project with ID ${projectId} not found.`);
        }
    
        try {
            const allTasks = this.taskRepository.findAllTasksForProject(projectId);
            const allDependencies = this.taskRepository.findAllDependenciesForProject(projectId);
    
            const taskMap: Map<string, ExportTask> = new Map();
            const rootTasks: ExportTask[] = [];
            const dependencyMap: Map<string, string[]> = new Map();
    
            for (const dep of allDependencies) {
                if (!dependencyMap.has(dep.task_id)) {
                    dependencyMap.set(dep.task_id, []);
                }
                dependencyMap.get(dep.task_id)!.push(dep.depends_on_task_id);
            }
    
            for (const task of allTasks) {
                taskMap.set(task.task_id, {
                    ...task,
                    dependencies: dependencyMap.get(task.task_id) || [],
                    subtasks: [],
                });
            }
    
            for (const task of allTasks) {
                const exportTask = taskMap.get(task.task_id)!;
                if (task.parent_task_id && taskMap.has(task.parent_task_id)) {
                    const parent = taskMap.get(task.parent_task_id)!;
                    if (!parent.subtasks) parent.subtasks = [];
                    parent.subtasks.push(exportTask);
                } else if (!task.parent_task_id) {
                    rootTasks.push(exportTask);
                }
            }
    
            const exportData: ExportData = {
                project_metadata: projectMetadata,
                tasks: rootTasks,
            };
    
            const jsonString = JSON.stringify(exportData, null, 2);
            logger.info(`[ProjectService] Successfully prepared export data for project ${projectId}`);
            return jsonString;
    
        } catch (error) {
            logger.error(`[ProjectService] Error exporting project ${projectId}:`, error);
            throw error;
        }
    }
  • Calls exportProjectTool to register the exportProject tool during overall tools registration.
    exportProjectTool(server, projectService);
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the export includes 'complete data set' with metadata, tasks, and dependencies, and that the format is fixed to JSON. However, it lacks details on permissions, rate limits, or side effects (e.g., if this is a read-only operation or generates files).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose in the first sentence, followed by specific inclusions and constraints. Each sentence adds essential information without redundancy, making it efficient and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description covers the basic purpose and output format but lacks details on behavioral aspects like error handling or the structure of the returned JSON string. It is adequate for a simple export tool but could be more complete for a tool with potential complexity in data retrieval.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters fully. The description adds minimal value by mentioning 'Requires the project ID' and 'format is fixed to JSON', which aligns with but does not significantly expand beyond the schema's details for 'project_id' and 'format'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Exports'), the resource ('complete data set for a specified project'), and the output format ('as a JSON string'). It distinguishes from siblings like 'importProject' (which imports) and 'listTasks' (which lists only tasks).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage by stating 'Requires the project ID' and 'The format is fixed to JSON for V1', but it does not explicitly say when to use this tool versus alternatives like 'showTask' or 'listTasks' for partial data, nor does it mention prerequisites beyond the ID.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/bsmi021/mcp-task-manager-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server