eyaltoledano/claude-task-master · error
DIRECT_FUNCTION_ERROR
DIRECT_FUNCTION_ERROR
Error message
${error.message} What it means
DIRECT_FUNCTION_ERROR is a generic catch-all error returned by the models_direct MCP direct function when an unexpected exception escapes the main try block. It wraps the underlying error message and stack trace in the standard MCP response shape. It indicates a bug, bad environment, or an unexpected failure inside the models logic rather than a validation rejection.
Source
Thrown at mcp-server/src/core/direct-functions/models.js:123
if (modelSetResult) {
return modelSetResult;
}
// Default action: get current configuration
return await getModelConfiguration({
session,
mcpLog,
projectRoot
});
} finally {
disableSilentMode();
}
} catch (error) {
log.error(`Error in models_direct: ${error.message}`);
return {
success: false,
error: {
code: 'DIRECT_FUNCTION_ERROR',
message: error.message,
details: error.stack
}
};
}
}
View on GitHub (pinned to c0c98d367c)
Solutions
- Read the `details` field (error.stack) in the response to find the underlying exception and its origin.
- Verify the project's .taskmaster directory and tasks.json exist and contain valid JSON.
- Check file permissions on .taskmaster files so the MCP server process can read them.
- Reproduce the underlying error by running the equivalent `task-master models` CLI command and fix the root cause (or report a bug if the core logic itself is throwing).
Example fix
// before: response hides root cause
{ success: false, error: { code: 'DIRECT_FUNCTION_ERROR', message: err.message } }
// after: inspect details.stack in the response to locate the real failing call
const resp = await modelsDirect(args, log);
if (!resp.success) {
console.error(resp.error.details); // stack trace of the real cause
} Defensive patterns
Strategy: try-catch
Validate before calling
import fs from 'fs';
if (!fs.existsSync('.taskmaster/tasks/tasks.json')) {
throw new Error('.taskmaster/tasks/tasks.json not found');
}
JSON.parse(fs.readFileSync('.taskmaster/tasks/tasks.json', 'utf8')); Type guard
function isDirectFunctionError(resp) {
return resp && resp.success === false && resp.error?.code === 'DIRECT_FUNCTION_ERROR';
} Try / catch
const resp = await modelsDirect(args, log);
if (!resp.success) {
if (resp.error.code === 'DIRECT_FUNCTION_ERROR') {
console.error('Underlying cause:', resp.error.details);
}
throw new Error(resp.error.message);
} Prevention
- Always inspect the `details` (stack) field — the message alone hides the real cause.
- Keep .taskmaster/tasks.json valid JSON and committed/backed up.
- Run the equivalent CLI command (`task-master models`) locally to reproduce root causes.
- Pin and test the MCP server version against your task-master version.
When it happens
Trigger: Any uncaught exception thrown inside modelsDirect (e.g. reading task files fails, a utility throws, log/summary computation crashes) is caught at mcp-server/src/core/direct-functions/models.js:123 and converted to this error with the exception's message and stack as details.
Common situations: Corrupt or missing .taskmaster/tasks directory, unreadable tasks.json (bad JSON), permission problems on the project files, or an internal bug in a refactored helper used by models_direct.
Related errors
- projectRoot is required in args to resolve project paths
- MCP provider requires session object
- The MCP model function cannot be called with the new keyword
- MCP session must have client sampling capabilities
- Schema is required for object generation
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/156c9d34dfd57ff3.
Report an issue: GitHub.