
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
dfa-mcp-server
Advanced tools
A Model Context Protocol (MCP) server that provides a generic deterministic finite automata (DFA) based workflow management system for LLMs.
This server helps LLMs follow any structured workflow without losing context or randomly marking tasks as complete. It allows dynamic definition of custom workflows with states, transitions, and actions, ensuring agents follow predefined paths through complex multi-step processes.
npm install -g dfa-mcp-server
Or install locally in your project:
npm install dfa-mcp-server
git clone https://github.com/your-username/dfa-mcp-server.git
cd dfa-mcp-server
npm install
npm run build
Add to your Claude Desktop MCP configuration:
Basic Configuration:
{
"mcpServers": {
"dfa-workflow": {
"command": "npx",
"args": ["dfa-mcp-server"]
}
}
}
With OpenAI:
{
"mcpServers": {
"dfa-workflow": {
"command": "npx",
"args": ["dfa-mcp-server"],
"env": {
"LLM_BASE_URL": "https://api.openai.com",
"LLM_JUDGE_MODEL": "gpt-4",
"LLM_API_KEY": "sk-your-openai-key"
}
}
}
}
With Custom Endpoint (Gemini via Veronica):
{
"mcpServers": {
"dfa-workflow": {
"command": "npx",
"args": ["dfa-mcp-server"],
"env": {
"LLM_BASE_URL": "https://your-llm-api-endpoint.com",
"LLM_JUDGE_MODEL": "gemini-2.5-pro",
"LLM_API_KEY": "sk-your-api-key"
}
}
}
}
After installing globally:
dfa-mcp-server
const { McpServer } = require('dfa-mcp-server');
// Server will start automatically when imported
For development:
npm run dev
For production:
npm start
Define a new workflow type with custom states and transitions.
Input:
name: Unique workflow namedescription: Optional workflow descriptionstates: Object defining states and their transitionsinitialState: Starting state nameExample:
{
"name": "approval-process",
"description": "Document approval workflow",
"states": {
"draft": {
"transitions": { "submit": "review" }
},
"review": {
"transitions": {
"approve": "approved",
"reject": "draft"
}
},
"approved": { "final": true }
},
"initialState": "draft"
}
List all registered workflow types.
Output:
workflows: Array of registered workflows with names and descriptionscount: Total number of registered workflowsStart a new instance of a defined workflow.
Input:
type: Workflow type name (must be previously defined)context: Optional initial context data (any JSON object)Output:
id: Unique workflow instance IDstate: Current statenextActions: Available actions from current stateprogress: Current progress messageMove workflow to next state by performing an action.
Input:
id: Workflow instance IDaction: Action to perform (must be in nextActions)data: Optional data to merge into contextOutput:
state: New state after transitionnextActions: Available actions from new stateprogress: Updated progresscomplete: Whether workflow has reached a final stateGet current status of a workflow instance.
Input:
id: Workflow instance IDOutput:
state: Current statecontext: Full workflow context (all accumulated data)nextActions: Available actionsprogress: Current progresscomplete: Whether workflow is completeCreate a checkpoint to save current workflow state.
Input:
id: Workflow instance IDdescription: Optional checkpoint descriptionmetadata: Optional additional metadataOutput:
checkpointId: Unique checkpoint IDworkflowId: Associated workflow IDstate: State at checkpointtimestamp: When checkpoint was createddescription: Checkpoint descriptionRollback workflow to a previous checkpoint.
Input:
id: Workflow instance IDcheckpointId: ID of checkpoint to rollback toOutput:
state: Restored statecontext: Restored contextnextActions: Available actions from restored stateprogress: Progress after rollbackmessage: Success messageList all checkpoints for a workflow.
Input:
id: Workflow instance IDOutput:
workflowId: Workflow IDcheckpoints: Array of checkpoints (sorted by most recent first)count: Total number of checkpointsValidate a transition without executing it. Useful for pre-checking if an action is valid.
Input:
id: Workflow instance IDaction: Action to validatedata: Optional data for the actionOutput:
approved: Whether the transition would be allowedconfidence: Confidence score (0-1)reasoning: Human-readable explanationviolations: List of validation failures (if any)suggestions: Helpful suggestions for fixing issuesConfigure judge settings for a workflow.
Input:
name: Workflow type nameenabled: Enable/disable judgestrictMode: Optional - reject low confidence transitionsminConfidence: Optional - minimum confidence threshold (0-1)Output:
success: Configuration update statusmessage: Confirmation messageconfig: Updated configurationGet the history of judge decisions for a workflow instance.
Input:
id: Workflow instance IDOutput:
workflowId: Workflow IDdecisions: Array of judge decisionscount: Total number of decisions{
"name": "document-review",
"description": "Document review with strict validation",
"states": {
"draft": {
"transitions": { "submit": "reviewing" }
},
"reviewing": {
"transitions": {
"approve": "approved",
"reject": "draft"
}
},
"approved": { "final": true }
},
"initialState": "draft",
"judgeConfig": {
"enabled": true,
"strictMode": true,
"minConfidence": 0.8
},
"stateValidators": {
"reviewing": {
"requiredFields": ["documentId", "reviewer"]
}
},
"transitionValidators": {
"approve": "(data, context) => ({ valid: data.comments?.length >= 20, confidence: 1.0, reason: 'Detailed comments required' })"
}
}
{
"name": "todo-tracker",
"description": "Track todo items through their lifecycle",
"states": {
"created": {
"transitions": {
"start": "in_progress",
"cancel": "cancelled"
}
},
"in_progress": {
"transitions": {
"complete": "done",
"pause": "paused",
"cancel": "cancelled"
}
},
"paused": {
"transitions": {
"resume": "in_progress",
"cancel": "cancelled"
}
},
"done": { "final": true },
"cancelled": { "final": true }
},
"initialState": "created"
}
{
"name": "deployment-pipeline",
"description": "Software deployment process",
"states": {
"ready": {
"transitions": { "deploy": "deploying" }
},
"deploying": {
"transitions": {
"success": "testing",
"failure": "failed"
}
},
"testing": {
"transitions": {
"pass": "live",
"fail": "rollback"
}
},
"rollback": {
"transitions": { "complete": "ready" }
},
"live": { "final": true },
"failed": { "final": true }
},
"initialState": "ready"
}
{
"name": "form-wizard",
"description": "Multi-step form submission",
"states": {
"step1": {
"transitions": {
"next": "step2",
"save": "draft"
}
},
"step2": {
"transitions": {
"next": "step3",
"back": "step1",
"save": "draft"
}
},
"step3": {
"transitions": {
"submit": "processing",
"back": "step2",
"save": "draft"
}
},
"draft": {
"transitions": { "resume": "step1" }
},
"processing": {
"transitions": {
"success": "complete",
"error": "step3"
}
},
"complete": { "final": true }
},
"initialState": "step1"
}
// 1. Define a custom workflow
await callTool('workflow.define', {
name: 'code-review',
description: 'Code review process',
states: {
submitted: {
transitions: { 'assign': 'in_review' }
},
in_review: {
transitions: {
'request_changes': 'changes_requested',
'approve': 'approved',
'reject': 'rejected'
}
},
changes_requested: {
transitions: { 'resubmit': 'in_review' }
},
approved: { final: true },
rejected: { final: true }
},
initialState: 'submitted'
});
// 2. Start a workflow instance
const result = await callTool('workflow.start', {
type: 'code-review',
context: {
pr_number: 123,
author: 'developer@example.com',
files_changed: 5
}
});
// Returns: { id: 'wf-123', state: 'submitted', nextActions: ['assign'] }
// 3. Assign reviewer
await callTool('workflow.advance', {
id: 'wf-123',
action: 'assign',
data: {
reviewer: 'senior@example.com',
assigned_at: new Date().toISOString()
}
});
// 4. Create checkpoint before making decision
const checkpoint = await callTool('workflow.checkpoint', {
id: 'wf-123',
description: 'Before review decision'
});
// 5. Request changes
await callTool('workflow.advance', {
id: 'wf-123',
action: 'request_changes',
data: {
comments: ['Please add tests', 'Update documentation']
}
});
// 6. If needed, rollback to checkpoint
await callTool('workflow.rollback', {
id: 'wf-123',
checkpointId: checkpoint.checkpointId
});
// 7. Approve instead
await callTool('workflow.advance', {
id: 'wf-123',
action: 'approve',
data: {
approved_at: new Date().toISOString(),
merge_strategy: 'squash'
}
});
Workflows are persisted in the .workflows directory:
definitions/: Saved workflow definitionswf-{id}.json: Current state and contextwf-{id}.log: Transition history (append-only log)checkpoints/: Saved checkpointsThis generic approach solves the common problem where LLMs:
By allowing dynamic workflow definition, any process can be modeled:
Enable AI-powered validation by setting environment variables in your MCP configuration:
"env": {
"LLM_BASE_URL": "https://api.openai.com", // Or any OpenAI-compatible endpoint
"LLM_JUDGE_MODEL": "gpt-4", // Model to use
"LLM_API_KEY": "sk-your-api-key", // Your API key
"LLM_JUDGE_THINKING_MODE": "high" // Thinking depth (optional)
}
Works with any OpenAI-compatible API:
{
"judgeConfig": {
"enabled": true,
"useLLM": true, // Enable LLM validation
"strictMode": true,
"minConfidence": 0.8
}
}
The intelligent judge system improves workflow accuracy by:
Structural Judge:
LLM attempts: workflow.advance(id: "wf-123", action: "approve", data: {})
Judge rejects: "Missing required approval comments (min 20 chars)"
LLM Judge (with same attempt):
LLM attempts: workflow.advance(id: "wf-123", action: "approve", data: {})
Judge rejects: "Approval without comments lacks accountability. In document
review workflows, approvals should include: 1) What was reviewed,
2) Key findings, 3) Any conditions. This creates an audit trail."
Suggestions: ["Add detailed approval comments", "Include review findings",
"Mention any follow-up requirements"]
The LLM judge provides richer, context-aware feedback!
FAQs
DFA-based workflow MCP server for guiding LLM task completion
We found that dfa-mcp-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.

Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.

Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.