Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

fix: remove cache from list-tasks and next-task mcp calls (#527)

Ralph Khreisha8dabf448567
diff --git a/.changeset/six-cloths-happen.md b/.changeset/six-cloths-happen.md
new file mode 100644
index 00000000..28e27856
--- /dev/null
+++ b/.changeset/six-cloths-happen.md
@@ -0,0 +1,7 @@
+---
+'task-master-ai': patch
+---
+
+Remove caching layer from MCP direct functions for task listing, next task, and complexity report
+
+- Fixes issues users where having where they were getting stale data
diff --git a/mcp-server/src/core/direct-functions/complexity-report.js b/mcp-server/src/core/direct-functions/complexity-report.js
index ec95a172..5b34f678 100644
--- a/mcp-server/src/core/direct-functions/complexity-report.js
+++ b/mcp-server/src/core/direct-functions/complexity-report.js
@@ -8,7 +8,6 @@ import {
enableSilentMode,
disableSilentMode
} from '../../../../scripts/modules/utils.js';
-import { getCachedOrExecute } from '../../tools/utils.js';
/**
* Direct function wrapper for displaying the complexity report with error handling and caching.
@@ -86,30 +85,20 @@ export async function complexityReportDirect(args, log) {
// Use the caching utility
try {
- const result = await getCachedOrExecute({
- cacheKey,
- actionFn: coreActionFn,
- log
- });
- log.info(
- `complexityReportDirect completed. From cache: ${result.fromCache}`
- );
- return result; // Returns { success, data/error, fromCache }
+ const result = await coreActionFn();
+ log.info('complexityReportDirect completed');
+ return result;
} catch (error) {
- // Catch unexpected errors from getCachedOrExecute itself
// Ensure silent mode is disabled
disableSilentMode();
- log.error(
- `Unexpected error during getCachedOrExecute for complexityReport: ${error.message}`
- );
+ log.error(`Unexpected error during complexityReport: ${error.message}`);
return {
success: false,
error: {
code: 'UNEXPECTED_ERROR',
message: error.message
- },
- fromCache: false
+ }
};
}
} catch (error) {
diff --git a/mcp-server/src/core/direct-functions/list-tasks.js b/mcp-server/src/core/direct-functions/list-tasks.js
index 179096d1..5ef7487f 100644
--- a/mcp-server/src/core/direct-functions/list-tasks.js
+++ b/mcp-server/src/core/direct-functions/list-tasks.js
@@ -4,7 +4,6 @@
*/
import { listTasks } from '../../../../scripts/modules/task-manager.js';
-import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
@@ -36,7 +35,6 @@ export async function listTasksDirect(args, log) {
// Use the explicit tasksJsonPath for cache key
const statusFilter = status || 'all';
const withSubtasksFilter = withSubtasks || false;
- const cacheKey = `listTasks:${tasksJsonPath}:${statusFilter}:${withSubtasksFilter}`;
// Define the action function to be executed on cache miss
const coreListTasksAction = async () => {
@@ -88,25 +86,19 @@ export async function listTasksDirect(args, log) {
}
};
- // Use the caching utility
try {
- const result = await getCachedOrExecute({
- cacheKey,
- actionFn: coreListTasksAction,
- log
- });
- log.info(`listTasksDirect completed. From cache: ${result.fromCache}`);
- return result; // Returns { success, data/error, fromCache }
+ const result = await coreListTasksAction();
+ log.info('listTasksDirect completed');
+ return result;
} catch (error) {
- // Catch unexpected errors from getCachedOrExecute itself (though unlikely)
- log.error(
- `Unexpected error during getCachedOrExecute for listTasks: ${error.message}`
- );
+ log.error(`Unexpected error during listTasks: ${error.message}`);
console.error(error.stack);
return {
success: false,
- error: { code: 'CACHE_UTIL_ERROR', message: error.message },
- fromCache: false
+ error: {
+ code: 'UNEXPECTED_ERROR',
+ message: error.message
+ }
};
}
}
diff --git a/mcp-server/src/core/direct-functions/next-task.js b/mcp-server/src/core/direct-functions/next-task.js
index 939d85e8..b1993942 100644
--- a/mcp-server/src/core/direct-functions/next-task.js
+++ b/mcp-server/src/core/direct-functions/next-task.js
@@ -5,7 +5,6 @@
import { findNextTask } from '../../../../scripts/modules/task-manager.js';
import { readJSON } from '../../../../scripts/modules/utils.js';
-import { getCachedOrExecute } from '../../tools/utils.js';
import {
enableSilentMode,
disableSilentMode
@@ -35,9 +34,6 @@ export async function nextTaskDirect(args, log) {
};
}
- // Generate cache key using the provided task path
- const cacheKey = `nextTask:${tasksJsonPath}`;
-
// Define the action function to be executed on cache miss
const coreNextTaskAction = async () => {
try {
@@ -118,18 +114,11 @@ export async function nextTaskDirect(args, log) {
// Use the caching utility
try {
- const result = await getCachedOrExecute({
- cacheKey,
- actionFn: coreNextTaskAction,
- log
- });
- log.info(`nextTaskDirect completed. From cache: ${result.fromCache}`);
- return result; // Returns { success, data/error, fromCache }
+ const result = await coreNextTaskAction();
+ log.info(`nextTaskDirect completed.`);
+ return result;
} catch (error) {
- // Catch unexpected errors from getCachedOrExecute itself
- log.error(
- `Unexpected error during getCachedOrExecute for nextTask: ${error.message}`
- );
+ log.error(`Unexpected error during nextTask: ${error.message}`);
return {
success: false,
error: {
diff --git a/mcp-server/src/core/direct-functions/show-task.js b/mcp-server/src/core/direct-functions/show-task.js
index 13b298e8..1bee0636 100644
--- a/mcp-server/src/core/direct-functions/show-task.js
+++ b/mcp-server/src/core/direct-functions/show-task.js
@@ -4,11 +4,6 @@
*/
import { findTaskById, readJSON } from '../../../../scripts/modules/utils.js';
-import { getCachedOrExecute } from '../../tools/utils.js';
-import {
- enableSilentMode,
- disableSilentMode
-} from '../../../../scripts/modules/utils.js';
import { findTasksJsonPath } from '../utils/path-utils.js';
/**