DPR MCP Server

DPR MCP Server

Enables safe, human-in-the-loop AI document collaboration by letting agents create isolated workspaces, edit tracked files, open reviewable Change Requests, and get human approval before merging, with Git-backed conflict detection and resolution.

Category
访问服务器

README

DPR MCP AI Document Collaboration Platform

This project is a local, Git-backed document collaboration platform where humans and AI agents can work on shared documents safely.

It combines:

  • Model Context Protocol server
  • real MCP stdio client
  • React dashboard
  • LangGraph-based agents
  • Git-backed versioning
  • isolated workspaces
  • Change Requests
  • human review and merge
  • conflict detection
  • conflict-resolution proposals
  • provenance tracking

The core idea:

AI agents can write and review documents, but they cannot silently overwrite main.
Every edit becomes a versioned, reviewable, traceable Change Request.

Why This Project Exists

Normal AI document editing is risky because an agent may directly overwrite a file, lose history, mix multiple users' edits, or make it unclear who changed what and why.

This project solves that by placing AI agents behind a controlled collaboration protocol:

Agent -> MCP Client -> MCP Server -> Controlled Tools -> Git + SQLite

The agent does not directly mutate the canonical document repository. It creates an isolated workspace, edits files there, opens a Change Request, and waits for human review.

Architecture

Full project architecture:

Project architecture

Phase 2 agent architecture:

Phase 2 agent architecture

High-level flow:

React Dashboard / External MCP Client
        |
        v
Dashboard API
        |
        v
LangGraph Agents
        |
        v
DPRMCPClient
        |
        v
MCP stdio
        |
        v
DPR MCP Server
        |
        v
MCP Tools
        |
        v
DPR Services
        |
        v
Git Repositories + Isolated Workspaces + SQLite Metadata

Main Components

MCP Server

The MCP server is the controlled backend interface. It exposes safe tools for document collaboration.

Entry point:

src/dpr_mcp/server.py

Important tools:

  • create_project
  • create_workspace
  • read_project_file
  • read_change_file
  • create_file
  • edit_file
  • create_change
  • review_change
  • approve_change
  • merge_change
  • get_diff
  • get_file_patch
  • get_conflicts
  • propose_conflict_resolution
  • apply_conflict_resolution
  • rollback_change
  • get_provenance

Run directly:

python -m dpr_mcp.server

The server speaks MCP over stdio. Usually a client communicates with it; you do not manually type into the process.

Real MCP Client

The reusable MCP client lives here:

src/dpr_mcp/mcp/client.py

It starts/connects to the DPR MCP server over stdio and calls tools by name. This is the same idea used by external MCP clients such as Claude Code.

Run the real client demo:

python examples\real_mcp_client.py

Expected output:

Connected to DPR MCP server. 35 tools available.
Project: client-demo
Workspace: ws-...
Change request: CR-...
Open changes: 1

React Dashboard

The dashboard is the human-facing UI.

It lets a user:

  • choose the local DPR root folder
  • create projects
  • view documents
  • run agents
  • inspect Change Requests
  • review diffs
  • merge approved changes
  • inspect conflicts
  • view history and provenance

Backend:

src/dpr_mcp/dashboard.py

Frontend:

frontend/

LangGraph Agents

The agent workflow layer lives here:

src/dpr_mcp/agents/workflows.py

The live dashboard agent actions create a real DPRMCPClient, connect to the MCP server over stdio, and call MCP tools. So the agent path is now:

Dashboard -> LangGraph Agent -> DPRMCPClient -> MCP Server -> MCP Tools

Current agents:

  • Draft Agent
  • Reviewer Agent
  • Compliance Agent
  • Conflict Resolver Agent

LLM integration lives here:

src/dpr_mcp/agents/llm.py

Supported modes:

  • Groq
  • OpenAI
  • fallback mode if no key is configured

Agent Workflow

Draft Agent

The Draft Agent creates or improves a document.

Example prompt:

Write a detailed report about smart waste segregation for a college campus.

Internal flow:

Dashboard
-> LangGraph Draft Agent
-> DPRMCPClient
-> MCP server
-> list_files
-> read_project_file if the file exists
-> create_workspace
-> create_file or edit_file
-> create_change

Result:

A new Change Request is created.
The file is not directly merged into main.

Reviewer Agent

The Reviewer Agent checks:

  • clarity
  • structure
  • completeness
  • technical usefulness
  • whether the change matches the user's intent

Internal flow:

Reviewer Agent
-> DPRMCPClient
-> get_change
-> get_diff
-> get_file_patch
-> review_change

Result:

A review comment is added to the Change Request.

The Reviewer Agent does not replace human approval. It provides feedback before a human decides whether to merge.

Compliance Agent

The Compliance Agent checks whether a change is safe and policy-friendly.

It looks for:

  • unsupported file types
  • secrets or credentials
  • placeholder text
  • invented evidence
  • unsafe claims
  • missing report sections

Internal flow:

Compliance Agent
-> DPRMCPClient
-> get_change
-> get_diff
-> get_file_patch
-> review_change

Result:

The Change Request receives a compliance review.
If there is a blocking issue, the review requests changes.

Conflict Resolver Agent

The Conflict Resolver Agent is used when Git detects a real merge conflict.

Internal flow:

Resolver Agent
-> DPRMCPClient
-> get_change
-> get_conflicts
-> create_workspace
-> read_project_file
-> read_change_file
-> edit_file
-> propose_conflict_resolution

Result:

A new resolution Change Request is created.
The human still reviews and merges the resolution.

The resolver does not bypass review. It only proposes a fix.

How a Real Conflict Happens

A conflict happens when two changes edit the same part of the same file from the same old base.

Example:

main has report.md

Then:

Agent A creates CR-1 editing report.md
Agent B creates CR-2 editing the same paragraph in report.md
Human merges CR-1 first
Human tries to merge CR-2
Git detects that CR-2 was based on old main and touched the same lines
CR-2 becomes conflicted

Then:

Conflict Resolver Agent reads current main and incoming CR-2
Resolver writes a combined version in a new workspace
Resolver opens a resolution CR
Human reviews and merges the resolution CR

This is a real Git conflict flow, not a fake UI-only conflict.

Where Files Are Created

The dashboard asks for a root folder.

If the root is:

C:\Users\janan\dpr-mcp\data

then the system uses:

data\projects      -> canonical Git repositories
data\workspaces    -> isolated Git worktrees
data\dpr_mcp.db    -> SQLite metadata database

Important:

Documents are local files inside Git-backed project repositories.
Workspaces are temporary isolated edit areas.
SQLite stores metadata such as workspaces, changes, reviews, conflicts, and roles.

Why Git Is Used

Git handles:

  • commits
  • branches
  • worktrees
  • diffs
  • mergeability checks
  • merge conflicts
  • merge history
  • rollback through forward commits

The project does not reinvent version control. It uses Git as the source of truth and adds collaboration workflow above it.

Why SQLite Is Used

Git is good for file history, but it does not naturally store collaboration metadata such as:

  • Change Request status
  • reviewer comments
  • approvals
  • conflict-resolution records
  • workspace ownership
  • role bindings
  • event logs

That metadata is stored in SQLite.

Human Governance

The system is intentionally human-in-the-loop.

Agents can:

  • draft documents
  • review changes
  • check compliance
  • propose conflict resolutions

Humans control:

  • final approval
  • merge
  • rollback
  • project access/root selection

This is important because the project is about safe AI-assisted collaboration, not uncontrolled autonomous editing.

Security Model

File operations are restricted to the configured repository and workspace roots.

The file security layer rejects:

  • absolute paths
  • path traversal
  • symlink escapes
  • null bytes
  • control characters
  • sensitive filenames such as .env, private keys, and credentials

Relevant files:

src/dpr_mcp/files/security.py
src/dpr_mcp/files/service.py
tests/security/

Setup

From CMD on Windows:

cd /d C:\Users\janan\dpr-mcp
python -m venv .venv
.venv\Scripts\activate
pip install -e ".[dev]"
cd frontend
npm install
cd ..

If the environment already exists:

cd /d C:\Users\janan\dpr-mcp
.venv\Scripts\activate

Environment Variables

Create a .env file in the project root if using real LLMs.

For Groq:

DPR_LLM_PROVIDER=groq
GROQ_API_KEY=your_key_here
DPR_LLM_MODEL=llama-3.3-70b-versatile

For OpenAI:

DPR_LLM_PROVIDER=openai
OPENAI_API_KEY=your_key_here
DPR_LLM_MODEL=gpt-5

If no key is configured, the agents still run in fallback mode, but the content will be basic.

Run the Dashboard

Backend:

cd /d C:\Users\janan\dpr-mcp
.venv\Scripts\activate
python -m dotenv run -- python -m dpr_mcp.dashboard --host 127.0.0.1 --port 8787 --root data

Frontend:

cd /d C:\Users\janan\dpr-mcp\frontend
npm run dev

Open the Vite URL shown in the terminal, usually:

http://127.0.0.1:5173

The dashboard backend API runs at:

http://127.0.0.1:8787

Run the MCP Server Directly

cd /d C:\Users\janan\dpr-mcp
.venv\Scripts\activate
python -m dpr_mcp.server

This starts the MCP server over stdio.

Run the Real MCP Client Demo

cd /d C:\Users\janan\dpr-mcp
.venv\Scripts\activate
python examples\real_mcp_client.py

This proves:

Python client
-> MCP stdio server
-> MCP tools
-> project/workspace/file/change created

Repository Map

src/dpr_mcp/server.py              MCP server entry point
src/dpr_mcp/dashboard.py           local dashboard HTTP API
src/dpr_mcp/mcp/tools.py           MCP tool definitions
src/dpr_mcp/mcp/client.py          real MCP stdio client
src/dpr_mcp/mcp/gateway.py         in-process MCP-shaped gateway
src/dpr_mcp/agents/workflows.py    LangGraph agent workflows
src/dpr_mcp/agents/llm.py          Groq/OpenAI/fallback generation
src/dpr_mcp/projects/              project repository management
src/dpr_mcp/workspace/             isolated worktree management
src/dpr_mcp/collaboration/         changes, reviews, approvals, conflicts
src/dpr_mcp/files/                 safe local file access
src/dpr_mcp/git/                   Git CLI wrapper
src/dpr_mcp/persistence/           SQLite models and repositories
src/dpr_mcp/provenance/            provenance reconstruction
frontend/                          React dashboard
examples/                          runnable MCP and conflict demos
tests/                             unit, integration, security, MCP tests
docs/                              architecture and technical docs

Current Status

Implemented:

  • MCP server
  • real MCP stdio client
  • React dashboard
  • LangGraph agents
  • LLM integration
  • local Git project repositories
  • isolated workspaces
  • Change Requests
  • reviews
  • compliance checks
  • merge flow
  • conflict detection
  • conflict-resolution proposals
  • rollback
  • provenance
  • architecture diagrams
  • tests

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选