src.marcus_mcp.tools.context module#

Context Tools for Marcus MCP.

This module contains tools for context management: - log_decision: Log architectural decisions - get_task_context: Get context for a specific task

async src.marcus_mcp.tools.context.log_decision(agent_id, task_id, decision, state)[source]#

Log an architectural decision made during task implementation.

Agents use this to document important technical choices that might affect other tasks. Decisions are automatically cross-referenced to dependent tasks.

Parameters:
  • agent_id (str) – The agent making the decision

  • task_id (str) – Current task ID

  • decision (str) – Natural language description of the decision

  • state (Any) – Marcus server state instance

Returns:

Dict with success status and decision details

Return type:

Dict[str, Any]

async src.marcus_mcp.tools.context.get_task_context(task_id, state)[source]#

Get the full context for a specific task.

This is useful for agents who want to understand the broader context of their work or review decisions made on dependencies.

For subtasks, includes parent task context and shared conventions.

Parameters:
  • task_id (str) – The task to get context for (can be regular task or subtask ID)

  • state (Any) – Marcus server state instance

Returns:

Dict with task context including implementations, dependencies, and decisions. For subtasks, includes parent_task, shared_conventions, and dependency_artifacts.

Return type:

Dict[str, Any]

async src.marcus_mcp.tools.context.assemble_task_context(task_id, task, state)[source]#

Assemble the full delivered context for a freshly assigned task.

Issue #605: context must be delivered with the task in the request_next_task response, not left to the optional get_task_context call. This helper builds the three-tier context bundle so request_next_task() can attach it directly.

The three tiers, each scope-labelled:

  1. project_contract β€” the project-global foundation contract (_collect_foundation_contract()). Reaches every task.

  2. dependency_artifacts β€” direct-dependency artifacts, filtered to architectural types, carrying the in_scope / reference_only annotation set by _collect_task_artifacts().

  3. transitive_context β€” transitive ancestor artifacts and all upstream decisions (_collect_transitive_context()), every entry reference_only.

Parameters:
  • task_id (str) – The assigned task’s ID.

  • task (Any) – The assigned task object.

  • state (Any) – Marcus server state.

Returns:

{"project_contract": {...}, "dependency_artifacts": [...], "transitive_context": {...}}. Each field degrades to an empty value rather than raising when a subsystem is unavailable.

Return type:

Dict[str, Any]