A powerful Model Context Protocol (MCP) server that acts as a context engine for AI assistants, enabling them to maintain persistent task tracking across complex, multi-step workflows. Built with FastMCP, this server provides comprehensive tools for creating, managing, and organizing tasks, epics, and issues with support for dependencies, labels, comments, and hierarchical structures.
When AI assistants handle complex tasks, they face a critical challenge: maintaining context across multiple tool calls and message exchanges. As conversations grow longer and involve numerous tool invocations, AI models can:
- Lose track of which tasks are complete vs pending
- Forget dependencies between different steps
- Miss critical subtasks in multi-step workflows
- Struggle to resume work after context switches or conversation breaks
This MCP server solves these problems by providing AI assistants with a persistent, external memory system for task tracking. Instead of relying solely on conversation history, the AI can:
- Externalize Task State: Store tasks, their status, dependencies, and relationships in a structured database
- Track Progress Persistently: Query what's done, what's in progress, and what's blocked—even across conversation boundaries
- Manage Complexity: Break down complex workflows into hierarchical structures (epics → tasks → subtasks)
- Maintain Context: Use labels, comments, and events to preserve decision-making context and rationale
- Navigate Dependencies: Understand what must be done before other tasks can proceed
Consider an AI helping you build a new authentication system:
Without Context Engine:
AI: I'll implement login, registration, and password reset.
[Makes several tool calls]
User: [30 minutes later] What's left to do?
AI: Let me check the conversation history... I think I did login but I'm not sure about the tests...
With Context Engine:
AI: I'll create an epic for authentication with child tasks.
[Creates epic #1 with children: #1.1 login, #1.2 registration, #1.3 password-reset, #1.4 tests]
[Marks #1.1 complete, #1.2 in_progress]
User: [30 minutes later] What's left to do?
AI: [Queries issues] You have #1.2 (registration) in progress, #1.3 and #1.4 pending.
The AI maintains perfect context through the database, not just memory.
When executing complex workflows with multiple tool calls:
- Before each step: AI queries pending tasks to know what to do next
- During execution: AI updates issue status and adds comments about decisions
- After completion: AI marks tasks complete and records outcomes
- On blockers: AI adds dependencies to track what's blocking what
- Across sessions: AI can resume exactly where it left off by querying issue state
This transforms the AI from a stateless responder into a stateful project manager that maintains perfect awareness of complex, multi-step workflows.
- Issue Management: Create, update, claim, and close issues with full lifecycle tracking
- Hierarchical Organization: Support for epics, parent-child relationships, and subtasks
- Dependencies: Manage complex relationships (blocks, parent-child, related, duplicates, supersedes)
- Labels & Tags: Flexible labeling system for categorization
- Comments & Events: Track discussions and custom event logs
- Priority System: P0-P4 priority levels for task organization
- Status Tracking: Monitor issue progress through various states
- Time Estimation: Track estimated and actual time for tasks
- Assignee Management: Assign issues to team members
- Dual Database Support: Choose between SQLite (development) or PostgreSQL (production)
- Python >= 3.13
- uv (Python package manager)
- Clone the repository:
git clone <repository-url>
cd context_mcp- Install dependencies using uv:
uv syncCopy the example environment file and configure it:
cp .env.example .env| Variable | Description | Default | Example |
|---|---|---|---|
CON_MCP_DB_TYPE |
Database type: sqlite or postgres |
sqlite |
sqlite |
CON_MCP_TRANSPORT |
MCP transport method: stdio or http |
stdio |
stdio |
| Variable | Description | Default | Example |
|---|---|---|---|
CON_MCP_SQLITE_PATH |
Path to SQLite database file | ./data.db |
./data.db |
| Variable | Description | Required | Example |
|---|---|---|---|
DB_HOST |
PostgreSQL host | Yes | localhost |
DB_USER |
PostgreSQL username | Yes | postgres |
DB_PASSWORD |
PostgreSQL password | Yes | your_password |
DB_NAME |
PostgreSQL database name | Yes | context_mcp |
DB_PORT |
PostgreSQL port | Yes | 5432 |
For SQLite (Development):
CON_MCP_DB_TYPE=sqlite
CON_MCP_SQLITE_PATH=./data.db
CON_MCP_TRANSPORT=stdioFor PostgreSQL (Production):
CON_MCP_DB_TYPE=postgres
DB_HOST=localhost
DB_USER=postgres
DB_PASSWORD=your_secure_password
DB_NAME=context_mcp
DB_PORT=5432
CON_MCP_TRANSPORT=stdioThe project includes a thread-safe singleton module for environment variable management. This module automatically finds and loads the .env file from the project root.
- Thread-safe singleton: Ensures only one instance exists across the application
- Auto-discovery: Automatically searches for
.envfile starting from the module's directory and traversing up to parent directories - One-time loading: Environment variables are loaded only once at initialization
- Snapshot isolation: Captures a copy of environment variables at initialization time
# Import the pre-instantiated singleton
from config_env import env_vars
# Get environment variables with optional default values
db_type = env_vars.get("CON_MCP_DB_TYPE", "sqlite")
db_host = env_vars.get("DB_HOST") # Returns None if not set
transport = env_vars.get("CON_MCP_TRANSPORT", "stdio")Instead of calling load_dotenv() in multiple places:
# Traditional approach (scattered across files)
from dotenv import load_dotenv
import os
load_dotenv()
db_type = os.getenv("CON_MCP_DB_TYPE")Use the centralized configuration module:
# Recommended approach (single source of truth)
from config_env import env_vars
db_type = env_vars.get("CON_MCP_DB_TYPE")Benefits:
- Single point of environment loading
- Consistent access pattern across the codebase
- Thread-safe for multi-threaded applications
- Automatic
.envfile discovery
The application uses SQLAlchemy with async support for database operations:
- SQLite: Uses
sqlite+aiosqlitedriver for async operations - PostgreSQL: Uses
postgresql+asyncpgdriver for async operations
The project uses Alembic for database migrations. Migrations must be run before starting the server.
uv run alembic upgrade headCON_MCP_DB_TYPE=postgres uv run alembic upgrade headOr set CON_MCP_DB_TYPE=postgres in your .env file and run:
uv run alembic upgrade headCreate a new migration:
uv run alembic revision --autogenerate -m "description of changes"Upgrade to latest migration:
uv run alembic upgrade headDowngrade one migration:
uv run alembic downgrade -1View migration history:
uv run alembic historyView current migration version:
uv run alembic currentStart the MCP server:
uv run python main.pyOr with specific database:
# SQLite
CON_MCP_DB_TYPE=sqlite uv run python main.py
# PostgreSQL
CON_MCP_DB_TYPE=postgres uv run python main.pyThe server provides the following tools for issue management:
con_mcp_create_issue: Create tasks, subtasks, or epics with priorities (P0-P4), status tracking, labels, dependencies, time estimates, and assigneescon_mcp_create_child_issue: Create a child issue under a parent for hierarchical task organization (auto-creates parent-child dependency)con_mcp_create_epic_with_children: Create an epic with multiple child tasks in one operation, automatically establishing parent-child relationshipscon_mcp_update_issue_fields: Update one or more fields of an existing issue (status, priority, title, assignee, description, notes, etc.)con_mcp_claim_issue: Claim an issue (assign to yourself and set to in_progress)con_mcp_close_issue: Close an issue with a reason
con_mcp_add_labels: Add labels/tags to an existing issuecon_mcp_remove_labels: Remove specific labels from an issuecon_mcp_set_labels: Replace all labels on an issue with a new set
con_mcp_add_dependency: Add dependency relationships between issues (blocks, parent-child, related, duplicates, supersedes)con_mcp_remove_dependency: Remove a dependency relationship between issues
con_mcp_add_comment: Add a comment/note to an issue for discussions and updatescon_mcp_add_event: Add a custom event log entry to track actions and changes
con_mcp_get_issue_details: Get comprehensive details about an issue including all fields, labels, comments, dependencies, dependents, and parent
- Create a new tool file in the
tools/directory - Import
mcpfrommcp_engine.py - Use the
@mcp.tool()decorator to define tools - Export the tool in
tools/__init__.py
SQLAlchemy models are located in database/models/. To add new models:
- Create the model in
database/models/ - Import it in
database/models/__init__.py - Create a migration:
uv run alembic revision --autogenerate -m "add new model" - Review and apply the migration:
uv run alembic upgrade head
The project uses a context-based session management system:
auto_session(): Automatically manages sessions (use in service functions)session_scope(): Manual session control with transaction managementget_session(): Get current session from context
Lint the project:
uv run ruff checkFormat the project:
uv run ruff formatWhen creating a new branch, follow this naming format:
Format: {initials}-{project-name}-{type}-{description}
Example:
git checkout -b ha-con_mcp-feature-init-fastmcp-serverComponents:
- initials: Your name initials (e.g.,
hafor Haba Andrei) - project-name: The project name (e.g.,
con_mcp) - type: The type of change:
feature- New functionalitybugfix- Bug fixeshotfix- Urgent production fixesrefactor- Code refactoringdocs- Documentation updates
- description: Brief summary of what you're building (e.g.,
new-ui,comprehensive-readme)
Examples:
# Feature branch
git checkout -b ha-con_mcp-feature-add-user-auth
# Bug fix branch
git checkout -b ha-con_mcp-bugfix-fix-dependency-loop
# Documentation branch
git checkout -b ha-con_mcp-docs-api-documentationThe database includes the following main tables:
- issues: Core issue/task data with status, priority, assignee, time tracking
- comments: Comments and notes on issues
- events: Custom event log entries
- labels: Tags and labels for categorization
- dependencies: Relationships between issues (blocks, parent-child, etc.)
- child_counters: Tracking child issue numbering for epics