tasks_setup
Initialize a source file from a specified path using the tasks_setup tool on MCP Tasks. Automatically creates the file if it doesn’t exist and returns a source ID for task management workflows.
Instructions
Initializes an source file from a path
Always call once per conversation when asked to use these tools
Ask the user to clarify the file path if not given, before calling this tool
Creates the file if it does not exist
Returns the source ID for further use
Use mcp-tasks tools when the user mentions new or updated tasks
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_path | Yes | ||
| workspace | No | Workspace/project directory path (provided by the IDE or use $PWD) |
Implementation Reference
- src/tools.ts:28-33 (handler)Handler function for the 'setup' tool, which implements the core logic of 'tasks_setup': parses the source file, registers the source using sources.register, and returns a summary via getSummary.handler: (args) => { storage.getParser(args.source_path) // Register the source and get ID const source = sources.register(args.source_path, args.workspace) return getSummary(source.id) },
- src/tools.ts:15-18 (schema)Input schema for the 'tasks_setup' tool (defined as 'setup' internally), including optional workspace and required source_path.schema: z.object({ workspace: z.string().optional().describe('Workspace/project directory path (provided by the IDE or use $PWD)'), source_path: schemas.sourcePath, }),
- src/server.ts:15-42 (registration)Registration loop that adds all enabled tools from tools.ts to the FastMCP server, including 'tasks_setup' via server.addTool using the prefixed tool.name.// Register all tools & resources for (const tool of Object.values(tools)) { if (!tool.isEnabled) { continue } if (tool.isResource) { // Register as resource server.addResource({ uri: `resource://${tool.name}`, name: tool.description, mimeType: 'text/plain', load: () => cli.runTool(tool, []).then(text => ({ text })), }) } else { // Register as tool with enhanced logging server.addTool({ annotations: { openWorldHint: false, // This tool doesn't interact with external systems readOnlyHint: tool.isReadOnly, title: tool.name, }, name: tool.name, description: tool.description, parameters: tool.schema, execute: (args) => cli.runTool(tool, args), }) } }
- src/tools.ts:197-214 (helper)defineTool utility that wraps tool definitions, crucially prefixing the name to 'tasks_setup' if env.PREFIX_TOOLS is true.function defineTool<S extends ZodSchema>(name: string, tool: { schema: S description: string isResource?: boolean isReadOnly?: boolean isEnabled?: boolean handler: (args: z.infer<S>, context?: any) => any fromArgs: (args: string[]) => z.infer<S> }) { const toolName = env.PREFIX_TOOLS ? `tasks_${name}` : name return { ...tool, name: toolName, isResource: tool.isResource ?? false, isReadOnly: tool.isReadOnly ?? false, isEnabled: tool.isEnabled ?? true, } }
- src/tools.ts:183-195 (helper)getSummary helper called by the tasks_setup handler to generate and return the JSON summary of the source's task groups and counts.function getSummary(sourceId?: string, extra?: object) { const meta = metadata.load(sourceId) const counts = _.mapValues(meta.groups, tasks => tasks.length) const total = Object.values(counts).reduce((sum, count) => sum + count, 0) const wip = _.camelCase(env.STATUS_WIP) return JSON.stringify({ source: _.omit(meta.source, ['workspace']), ...counts, total, ...extra, instructions: env.INSTRUCTIONS || undefined, reminders: env.STATUS_REMINDERS ? meta.groups[env.STATUS_REMINDERS] : undefined, [wip]: meta.groups[env.STATUS_WIP], }) }