Skip to content

Add incremental graph mutation via MCP (add_node, add_edge) #10

Description

@jeremiepas

Problem

The MCP server can only read the graph and add conversations. There's no way to add nodes or edges at runtime. Agents can't learn new connections from analysis.

Solution

Add MCP tools for graph mutation:

add_node

{
  "name": "add_node",
  "inputSchema": {
    "label": "Human-readable label",
    "kind": "Function, Class, Module, Concept, etc.",
    "source_file": "Source file path",
    "signature": "Type signature"
  }
}

add_edge

{
  "name": "add_edge",
  "inputSchema": {
    "source": "Source node ID",
    "target": "Target node ID",
    "relation": "calls, references, contains, etc.",
    "confidence": "EXTRACTED, INFERRED, or AMBIGUOUS"
  }
}

Community assignment:

When a new node is added, assign it to the community of its most-connected neighbor. If no neighbors, assign to community 0.

Re-clustering trigger:

After N mutations (configurable, default: 50), trigger full Leiden re-cluster.

Acceptance Criteria

  • add_node creates node visible in get_node immediately
  • add_edge creates edge between existing nodes
  • New nodes assigned to community of most-connected neighbor
  • Periodic re-clustering after N mutations
  • Error handling: missing node IDs, duplicate edges
  • Graph mutations persist in snapshots (depends on Make MCP server graph state mutable (TVar) #5)

Files to Modify

  • src/Graphos/Domain/Graph/Core.hs — add insertNode, insertEdge, removeNode
  • src/Graphos/Domain/Community.hs — add assignNodeToCommunity
  • src/Graphos/Infrastructure/Server/MCP.hs — add add_node, add_edge tools

Effort: 2-3 days

Priority: Medium

See: docs/proposals/memory-agent/05-technical-specifications.md (Spec 6, 7)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestmemory-agentMemory agent capabilitiesphase-4Phase 4: Incremental Mutation + MCP Tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions