🔬 A Guided & Exploratory Medical Paper Writing Tool
Powered by MCP + GitHub Copilot
🔬 引導式、探索式醫學論文寫作工具
由 MCP + GitHub Copilot 驅動
Traditional paper writing tools require you to know exactly what you want before you start. But research is rarely that linear.
Medical Paper Assistant is different:
- 🔍 Explore First, Decide Later - Browse literature freely, save interesting papers, then decide your research direction
- 💬 Conversational Workflow - Chat naturally with AI to refine your ideas, not fight with forms
- 🧭 Guided Process - Step-by-step prompts guide you from concept to publication-ready manuscript
- 🔗 Native MCP + Copilot Integration - Works directly inside VS Code, no context switching
| Traditional Tools | Medical Paper Assistant |
|---|---|
| Fixed templates, rigid workflow | Flexible, exploratory approach |
| Separate apps for search/write/cite | All-in-one integrated experience |
| Manual reference management | Auto-save with PDF & citation formats |
| Export then format | Direct Word export with journal styles |
| Learn complex UI | Natural language conversation |
Medical Paper Assistant is an AI-powered writing tool designed specifically for medical researchers. Built on the Model Context Protocol (MCP), it integrates seamlessly with VS Code through GitHub Copilot, providing a comprehensive workflow from literature search and data analysis to manuscript drafting and formatted export.
| Feature | Description |
|---|---|
| Literature Search & Management | Connect to PubMed API, search articles, download PDFs from PMC Open Access, and build a local reference library |
| Data Analysis | Automatically read CSV data, perform statistical tests (t-test, correlation, etc.), and generate publication-ready figures |
| Smart Draft Generation | Generate manuscript drafts based on your research concept and analysis results |
| Automatic Citations | Insert citation markers `[1]` and generate formatted reference lists (Vancouver, APA, Nature styles) |
| Interactive Refinement | Fine-tune specific sections through conversational dialogue |
| Word Export | Export Markdown drafts to `.docx` files conforming to journal templates |
Before you begin, ensure you have the following installed:
| Requirement | Version | How to Check | Installation Guide |
|---|---|---|---|
| Python | 3.10 or higher | `python3 --version` | python.org |
| Git | Any recent version | `git --version` | git-scm.com |
| VS Code | Latest | Open VS Code → Help → About | code.visualstudio.com |
| GitHub Copilot | Extension | VS Code Extensions panel | Search "GitHub Copilot" in Extensions |
Step 1: Clone the Repository
Open a terminal and run:
```bash
cd ~/projects # or any directory of your choice
git clone https://github.com/u9401066/med-paper-assistant.git
cd med-paper-assistant ```
Step 2: Run the Setup Script
Linux/macOS: ```bash
chmod +x scripts/setup.sh
./scripts/setup.sh ```
Windows (PowerShell - Recommended): ```powershell
.\scripts\setup.ps1 ```
Windows (Command Prompt): ```cmd
scripts\setup.bat ```
This script will:
- ✅ Create a Python virtual environment (`.venv/`)
- ✅ Install all required dependencies
- ✅ Create the `.vscode/mcp.json` configuration file (with correct paths for your OS)
- ✅ Verify the installation
Step 3: Reload VS Code
After setup completes:
- Open VS Code
- Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (Mac)
- Type `Developer: Reload Window` and press Enter
Step 4: Verify Installation
In VS Code's Copilot Chat panel:
- Type
/mcpand press Enter - You should see
mdpaper (50 tools)in the list (or withdrawio (15 tools)if you enabled Draw.io integration) - If you see this, the installation was successful! 🎉
For diagram generation (CONSORT/PRISMA flowcharts), run:
# Initialize submodules and setup Draw.io
./scripts/setup-integrations.shThis adds the drawio MCP server with tools for creating diagrams.
To use Draw.io:
- Start the web app:
./scripts/start-drawio.sh - Reload VS Code
- Use drawio tools in Copilot Chat
These extensions enhance your research workflow:
| Extension | Purpose | Install |
|---|---|---|
| Project Manager | Quick project switching, sidebar, tags | ext install alefragnani.project-manager |
| Foam | Wikilinks, backlinks, hover preview | ext install foam.foam-vscode |
Quick Install:
code --install-extension alefragnani.project-manager
code --install-extension foam.foam-vscodeMedical Paper Assistant integrates with Foam to provide a powerful reference linking and preview system.
Foam is a personal knowledge management system inspired by Roam Research. It turns your Markdown files into a connected knowledge graph with:
- Wikilinks
[[link]]- Link between notes - Hover Preview - See content without opening files
- Backlinks - See which notes reference the current note
- Graph Visualization - Visualize connections
Step 1: Install Foam Extension
In VS Code:
- Press
Ctrl+Shift+X(Extensions panel) - Search for
foam.foam-vscode - Click Install
- Reload VS Code (
Ctrl+Shift+P→Developer: Reload Window)
Step 2: Save References with Citation Keys
When you save a reference, the system automatically creates Foam-compatible files:
# Using MCP tool
save_reference(pmid="38049909")
# Creates:
references/
├── 38049909/
│ ├── content.md ← Main content with all citation formats
│ └── metadata.json ← Structured data
└── tang2023_38049909.md ← Foam alias for easy linking
Step 3: Use Wikilinks in Your Draft
# My Research Draft
According to [[tang2023_38049909]], remimazolam shows promising results
for ICU sedation compared to propofol.
The study by [[smith2024_41285088]] also supports this finding...Step 4: Hover to Preview
Move your mouse over any [[link]] to instantly see:
- 📄 Paper title and authors
- 📋 All citation formats (Vancouver, APA, Nature)
- 📝 Full abstract
- 🔗 Clickable DOI link
References are saved with a human-friendly + verifiable format:
[[author_year_pmid]]
│ │ │
│ │ └── PMID for verification
│ └── Publication year
└── First author's last name
Example: [[tang2023_38049909]]
→ Tang et al., 2023, PMID: 38049909
→ Verify: https://pubmed.ncbi.nlm.nih.gov/38049909/
When you hover over a reference, you'll see all citation formats. The project's preferred format is marked with ⭐:
## 📋 Citation Formats
**⭐ APA**: Tang, Y., Gao, X., ... (2023). Remimazolam besylate versus...
**Vancouver**: Tang Y, Gao X, et al. Remimazolam besylate versus...
**Nature**: Tang Y, et al. Remimazolam besylate versus... *Crit Care* **27**...
**In-text**: (Tang et al., 2023)To set your preferred citation style:
set_citation_style(style="apa") # Options: vancouver, apa, nature, harvard, ama
| Feature | How to Use | Benefit |
|---|---|---|
| Hover Preview | Mouse over [[link]] |
See abstract without opening file |
| Backlinks Panel | Open any reference file | See which drafts cite this paper |
| Graph View | Ctrl+Shift+P → Foam: Show Graph |
Visualize paper connections |
| Orphan References | Ctrl+Shift+P → Foam: Show Orphans |
Find saved but uncited papers |
code --install-extension foam.foam-vscode
#### Manual Installation (If Setup Script Fails)
<details>
<summary>Click to expand manual installation steps</summary>
**Step 1: Clone the Repository**
\`\`\`bash
git clone https://github.com/u9401066/med-paper-assistant.git
cd med-paper-assistant
\`\`\`
**Step 2: Create Virtual Environment**
\`\`\`bash
# Create a virtual environment named .venv
python3 -m venv .venv
# Activate the virtual environment
# On Linux/Mac:
source .venv/bin/activate
# On Windows (Command Prompt):
.venv\Scripts\activate.bat
# On Windows (PowerShell):
.venv\Scripts\Activate.ps1
\`\`\`
> 💡 **What is a virtual environment?**
> A virtual environment is an isolated Python environment that keeps this project's dependencies separate from your system Python. This prevents conflicts with other projects.
**Step 3: Install Dependencies**
\`\`\`bash
# Upgrade pip first (recommended)
pip install --upgrade pip
# Install the project in editable mode
pip install -e .
\`\`\`
**Step 4: Configure VS Code MCP**
Create the file \`.vscode/mcp.json\` in the project root:
\`\`\`bash
# Create .vscode directory if it doesn't exist
mkdir -p .vscode
# Create the mcp.json file
cat > .vscode/mcp.json << 'EOF'
{
"inputs": [],
"servers": {
"mdpaper": {
"type": "stdio",
"command": "${workspaceFolder}/.venv/bin/python",
"args": ["-m", "med_paper_assistant.interfaces.mcp"],
"env": {
"PYTHONPATH": "${workspaceFolder}/src"
}
}
}
}
EOF
\`\`\`
> ⚠️ **Windows Users**: Replace \`.venv/bin/python\` with \`.venv\\Scripts\\python.exe\`
**Step 5: Reload VS Code**
Press \`Ctrl+Shift+P\` → Type \`Developer: Reload Window\` → Press Enter
</details>
#### Troubleshooting
<details>
<summary>❌ "Command not found: python3"</summary>
**Problem**: Python is not installed or not in your PATH.
**Solution**:
1. Install Python from [python.org](https://www.python.org/downloads/)
2. During installation, check "Add Python to PATH"
3. Restart your terminal and try again
</details>
<details>
<summary>❌ MCP server not showing in Copilot</summary>
**Problem**: The MCP server is not being detected by VS Code.
**Solutions**:
1. Ensure \`.vscode/mcp.json\` exists and has correct paths
2. Check that the virtual environment was created: \`ls .venv/\`
3. Try reloading VS Code: \`Ctrl+Shift+P\` → \`Developer: Reload Window\`
4. Check VS Code Output panel: \`View\` → \`Output\` → Select "MCP" from dropdown
</details>
<details>
<summary>❌ "ModuleNotFoundError: med_paper_assistant"</summary>
**Problem**: The package is not installed or PYTHONPATH is incorrect.
**Solution**:
\`\`\`bash
# Activate virtual environment first
source .venv/bin/activate # Linux/Mac
# .venv\Scripts\activate # Windows
# Reinstall the package
pip install -e .
\`\`\`
</details>
---
### 📖 Usage Guide
This assistant integrates with GitHub Copilot through MCP. Use \`/mcp.mdpaper.*\` commands in Copilot Chat.
#### Workflow Overview
```mermaid
flowchart LR
A["📝 Concept<br/>/concept"] --> B["🔍 Search<br/>/strategy"]
B --> C["📊 Analysis<br/>/analysis"]
C --> D["✍️ Draft<br/>/draft"]
D --> E["🔄 Clarify<br/>/clarify"]
E --> F["📄 Export<br/>/format"]
Don't know what to research? Start by exploring literature first!
Command: /mcp.mdpaper.search
flowchart LR
A["🔍 Start Exploration"] --> B["📚 Search & Save Papers"]
B --> C{"Found Direction?"}
C -->|Not yet| B
C -->|Yes!| D["📁 Convert to Project"]
D --> E["✍️ Start Writing"]
How it works:
-
Start exploring - Automatically creates a temporary workspace
start_exploration() -
Search and save interesting papers - No project commitment required
search_literature(query="your interest topic") save_reference(pmid="12345678") # Save interesting ones -
When you find a direction - Convert to formal project with all references
convert_exploration_to_project( name="Your Research Title", paper_type="original-research" )
💡 Benefit: All references saved during exploration are automatically transferred to your new project!
Before starting, organize your files:
| Directory | Purpose |
|---|---|
data/ |
Place your CSV research data here |
templates/ |
(Optional) Journal Word templates |
Command: `/mcp.mdpaper.concept`
This guided workflow helps you develop a well-structured research concept with novelty protection:
flowchart LR
A["📚 Literature Search"] --> B["🔍 Gap Identification"]
B --> C{"❓ User Confirms Gap"}
C -->|Yes| D["✍️ Concept Writing"]
C -->|No| B
D --> E["✅ Validate Concept"]
Step-by-step process:
-
📚 Literature Search (Mandatory)
- Agent searches PubMed for 5-10 relevant studies
- Key papers are saved to your reference library
-
🔍 Gap Identification (Mandatory)
- Agent presents literature summary
- Identifies research gaps and limitations
- 🛑 Asks you to confirm which gap your research addresses
-
✍️ Concept Writing (After your confirmation)
- Creates structured concept with protected sections:
- 🔒 NOVELTY STATEMENT - What's new (protected)
- 🔒 KEY SELLING POINTS - Your 3-5 key differentiators (protected)
- 📝 Background, Methods, Expected Outcomes (editable)
- Creates structured concept with protected sections:
-
✅ Validation
- Use
validate_concepttool to verify completeness
- Use
The output is saved to `drafts/concept_*.md`.
💡 Why Protected Sections? The 🔒 markers ensure your key innovations are preserved when writing the full paper. The Agent must ask before modifying these sections.
Command: `/mcp.mdpaper.strategy`
Set up your literature search parameters:
- Keywords and MeSH terms
- Exclusion criteria
- Article types (Review, Clinical Trial, Meta-Analysis)
- Date range
- Minimum sample size
Command: `/mcp.mdpaper.analysis`
The assistant will:
- List available CSV files in `data/`
- Ask you to specify grouping and outcome variables
- Perform appropriate statistical tests
- Generate figures (saved to `results/figures/`)
- Create Table 1 (baseline characteristics)
Command: `/mcp.mdpaper.draft`
The assistant will:
- Read your `concept.md` and analysis results
- Ask which template to use
- Generate a Markdown draft with:
- Embedded figures
- Automatic citations
- Formatted tables
⚠️ Important: This command requires a concept file. Create one using `/mcp.mdpaper.concept` first.
Command: `/mcp.mdpaper.clarify`
Interactively improve specific sections:
- "Make the Introduction more conservative"
- "Expand the limitations section"
- "Simplify the statistical methods description"
Command: /mcp.mdpaper.format
This follows a 7-step workflow:
- Read template structure
- Read draft content
- Map sections
- Insert content
- Verify document
- Check word limits
- Save final document
Output: results/your_paper.docx
| Directory | Purpose |
|---|---|
projects/ |
Research projects (isolated workspaces) |
projects/{slug}/concept.md |
Research concept with protected sections |
projects/{slug}/drafts/ |
Markdown drafts |
projects/{slug}/references/{PMID}/ |
Local reference library |
projects/{slug}/data/ |
Raw data files (CSV) |
projects/{slug}/results/ |
Generated outputs (figures, tables, docx) |
└ metadata.json |
Citation info, formatted references |
└ content.md |
Abstract and notes |
└ fulltext.pdf |
PDF (if available from PMC) |
templates/ |
Journal Word templates (.docx for export) |
src/med_paper_assistant/core/ |
Core logic modules |
src/med_paper_assistant/mcp_server/ |
MCP server implementation |
└ templates/ |
Internal templates for Agent guidance (.md) |
tests/ |
Test suite |
.memory/ |
Project context files |
└ .agent_constitution.md |
Agent behavior rules (dynamically loaded) |
The MCP server dynamically loads the Agent Constitution from .memory/.agent_constitution.md. This file defines the core behavior rules that Copilot must follow.
Constitution Structure:
| Part | Content |
|---|---|
| Part 1: System Development | Language rules, Memory Bank maintenance, Code quality, Privacy |
| Part 2: Research Operations | Concept workflow, Protected content rules, Draft writing rules |
Key Rules for Protected Content (🔒):
## 2.2 🔒 Protected Content Rules
| Section | Description | Rule |
|---------|-------------|------|
| 🔒 NOVELTY STATEMENT | Innovation declaration | Must ask before modifying |
| 🔒 KEY SELLING POINTS | Core differentiators (3-5) | Must ask before modifying |
| 🔒 Author Notes | Private notes | Do not modify |
Modification Rules:
✅ Can refine wording
✅ Can improve academic expression
⛔ MUST ask user before substantial changes
⛔ NEVER delete protected content
⛔ NEVER weaken selling pointsTo customize: Edit .memory/.agent_constitution.md and reload VS Code. The new rules will be automatically applied.
The system includes an intelligent Novelty Validation feature that ensures research concepts truly describe novel contributions before proceeding to draft writing.
flowchart LR
A["📝 Concept File"] --> B["🔍 Structure Check"]
B --> C{"Required sections?"}
C -->|No| D["❌ FAIL"]
C -->|Yes| E["🎯 Novelty Scoring"]
E --> F["Round 1"]
E --> G["Round 2"]
E --> H["Round 3"]
F & G & H --> I{"All ≥ 75?"}
I -->|No| J["❌ FAIL + Suggestions"]
I -->|Yes| K["✅ PASS"]
| Setting | Value | Description |
|---|---|---|
| Rounds | 3 | Number of independent evaluations |
| Threshold | 75/100 | Minimum score per round |
| Pass Criteria | All 3 rounds ≥ 75 | Must pass all rounds |
| Dimension | Weight | What It Checks |
|---|---|---|
| Uniqueness | 25% | Is the approach/method unique? |
| Significance | 25% | Is the contribution meaningful? |
| Gap Alignment | 20% | Does novelty address the research gap? |
| Specificity | 15% | Is the claim specific and concrete? |
| Verifiability | 15% | Can the claim be verified/tested? |
📋 Concept Validation Report
📄 File: concept.md
## 🔒 Protected Sections (Required)
| Section | Found | Has Content | Status |
|---------|-------|-------------|--------|
| 🔒 NOVELTY STATEMENT | ✅ | ✅ | ✅ PASS |
| 🔒 KEY SELLING POINTS (4 points) | ✅ | ✅ | ✅ PASS |
## 🎯 Novelty Evaluation
**Status:** ✅ PASSED
**Average Score:** 82.3/100
**Threshold:** 75
| Round | Score | Status |
|-------|-------|--------|
| 1 | 84 | ✅ |
| 2 | 79 | ✅ |
| 3 | 84 | ✅ |
## ✅ VALIDATION PASSED
-
Mandatory Before Draft Writing: The system enforces validation before any concept file can be used for draft generation.
-
Multi-Round Evaluation: Using 3 rounds increases reliability and reduces false positives.
-
High Threshold: Requiring 75+ ensures only well-articulated novelty claims pass.
-
Actionable Feedback: Failed validations provide specific suggestions for improvement.
Skills are complete workflow definitions that guide the AI through complex multi-step tasks. Unlike individual tools that perform single actions, Skills define the entire process from start to finish.
📁 See full documentation: .skills/README.md
| User Request | Skill to Load |
|---|---|
| "Help me do a literature review" | literature_review |
| "Develop my research concept" | concept_development |
| "Search for papers on [topic]" | parallel_search |
| "Write the Introduction section" | draft_introduction |
| "Write the Discussion" | draft_discussion |
flowchart LR
A["🗣️ User Request"] --> B["🔍 Identify Intent"]
B --> C["📖 Load Skill"]
C --> D["🔧 Follow Workflow"]
D --> E["✅ Deliverables"]
Example: When you say "help me do a literature review", the AI:
- Loads
.skills/research/literature_review.md - Follows the defined phases (search → screen → synthesize)
- Asks at decision points
- Produces the expected deliverables
| Tool | Purpose |
|---|---|
list_skills |
Show all available skills |
load_skill |
Load a specific skill's workflow |
suggest_skill |
Get skill recommendation based on task |
Parallel Search dramatically speeds up literature discovery by running multiple search strategies simultaneously.
flowchart LR
A["🎯 Topic"] --> B["generate_search_queries"]
B --> C["5 Query Strategies"]
C --> D["⚡ Parallel Execution"]
D --> E["merge_search_results"]
E --> F["📊 Deduplicated Results"]
User: "Find papers about remimazolam ICU sedation"
AI executes:
1. generate_search_queries(topic="remimazolam ICU sedation")
→ Returns 5 different query strategies
2. Parallel execution of search_literature × 5
→ All queries run simultaneously
3. merge_search_results(...)
→ Returns: 42 unique papers (56 total, 14 duplicates removed)
→ Papers found by multiple strategies are flagged as "high relevance"
Configure your search strategy once, and it automatically applies to all parallel queries:
configure_search_strategy({
"date_range": "2020-2025",
"exclusions": ["animal", "review"],
"article_types": ["Clinical Trial", "RCT"]
})
generate_search_queries(topic="...", use_saved_strategy=True)
→ All 5 queries include date filters, exclusions, and article type restrictions
| Category | Tools | Description |
|---|---|---|
| Search (10) | search_literature, find_related_articles, find_citing_articles, fetch_article_details, configure_search_strategy, get_search_strategy, generate_search_queries, merge_search_results, expand_search_queries, search_local_references |
Literature discovery via pubmed-search-mcp submodule |
| Reference (8) | save_reference, list_saved_references, get_reference_details, read_reference_fulltext, retry_pdf_download, format_references, set_citation_style, insert_citation |
Reference management |
| Writing (16) | write_draft, read_draft, list_drafts, draft_section, get_section_template, count_words, validate_concept, validate_concept_quick, list_templates, read_template, start_document_session, insert_section, verify_document, check_word_limits, save_document, export_word |
Manuscript preparation and export |
| Project (15) | create_project, list_projects, switch_project, get_current_project, update_project_status, get_project_paths, get_paper_types, update_project_settings, setup_project_interactive, start_exploration, get_exploration_status, convert_exploration_to_project, save_diagram, save_diagram_standalone, list_diagrams |
Project & diagram management |
| Skills (3) | list_skills, load_skill, suggest_skill |
Workflow automation via Skills System |
Note: Analysis tools (
analyze_dataset,run_statistical_test,create_plot,generate_table_one) have been moved to a separate data-analysis-mcp project.
🎨 drawio Tools (15 total) - Optional Integration
| Category | Tools | Description |
|---|---|---|
| Diagram | create_diagram, edit_diagram, get_diagram_info, apply_diagram_changes |
Create and edit diagrams |
| Templates | list_templates, create_from_template |
Architecture templates (AWS, GCP, Azure) |
| Guidelines | get_drawing_guidelines, get_style, list_styles |
Drawing best practices |
| File | load_file, save_tab |
File management |
```bash
source .venv/bin/activate
pytest tests/
pytest tests/test_search.py
pytest tests/ -v ```
We're actively developing new features. Here's what's coming:
| Status | Feature | Description |
|---|---|---|
| ✅ | Draw.io Integration | Generate CONSORT/PRISMA flowcharts with real-time WebSocket sync via next-ai-draw-io |
| ✅ | Skills System | Workflow definitions guiding AI through complex tasks - see documentation |
| ✅ | Parallel Search | Generate multiple search queries and execute in parallel - how it works |
| ✅ | Search Strategy Integration | Configure once, apply everywhere - strategy auto-integrates into parallel queries |
| ✅ | Table 1 Generator | Auto-generate baseline characteristics table from CSV via generate_table_one |
| ✅ | Foam Integration | Wikilinks [[citation_key]], hover preview, backlinks panel for reference management |
| ✅ | PubMed MCP | Independent MCP server for literature search - can be used standalone |
| 🔜 | Multi-language Support | Full UI localization beyond English/Chinese |
| 🔜 | Journal Style Library | Pre-configured styles for major medical journals |
| 📋 | REST API Mode | Expose MCP tools as REST API for external integrations |
| 📋 | Dashboard File Browser | Integrate Chonky React file browser into Dashboard for visual project file management |
| 📋 | Collaboration Mode | Multi-author workflow with version control |
| 📋 | AI-Assisted Review | Use LLM to review and improve manuscript sections |
Legend: ✅ Complete | 🔜 In Progress | 📋 Planned
Want to help? Check out CONTRIBUTING.md or open an issue to discuss!
We welcome contributions from the community! Whether you're a medical researcher with workflow ideas, a developer who wants to add features, or someone who found a bug - we'd love to hear from you.
Ways to contribute:
- 🐛 Report bugs - Open an issue describing the problem
- 💡 Suggest features - Share your ideas for new tools or workflows
- 📝 Improve documentation - Help make the README clearer
- 🔧 Submit code - Fork, code, and send a PR
- 🌐 Translations - Help translate to other languages
Getting started:
- Fork this repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License. See LICENSE for details.
If you find this project helpful, please consider giving it a star! It helps others discover the project.
傳統論文寫作工具要求你在開始前就知道確切的方向。但研究很少是這麼線性的。
Medical Paper Assistant 不一樣:
- 🔍 先探索,後決定 - 自由瀏覽文獻、儲存有興趣的論文,再決定研究方向
- 💬 對話式工作流程 - 用自然語言與 AI 對話來精煉想法,不用填表單
- 🧭 引導式流程 - 一步步的提示引導你從構思到可投稿的論文
- 🔗 原生 MCP + Copilot 整合 - 直接在 VS Code 中運作,不用切換應用程式
| 傳統工具 | Medical Paper Assistant |
|---|---|
| 固定模板、僵化流程 | 彈性、探索式方法 |
| 搜尋/寫作/引用分開多個 App | 一站式整合體驗 |
| 手動管理參考文獻 | 自動儲存 + PDF + 引用格式 |
| 匯出後再排版 | 直接匯出符合期刊格式的 Word |
| 學習複雜介面 | 自然語言對話 |
Medical Paper Assistant(醫學論文寫作助手)是一款專為醫學研究人員設計的 AI 輔助寫作工具。基於 Model Context Protocol (MCP) 架構,可與 VS Code 的 GitHub Copilot 無縫整合,提供從文獻檢索、數據分析、草稿生成到格式化輸出的完整工作流程。
| 功能 | 說明 |
|---|---|
| 文獻檢索與管理 | 連接 PubMed API 搜尋文獻,從 PMC Open Access 下載 PDF,建立本地文獻庫 |
| 數據分析 | 自動讀取 CSV 數據,執行統計檢定(t-test、相關性分析等),生成出版品質的圖表 |
| 智慧草稿生成 | 根據您的研究構想與分析結果,自動生成論文草稿 |
| 自動引用 | 插入引用標記 `[1]` 並生成格式化的參考文獻列表(支援 Vancouver、APA、Nature 格式) |
| 互動式修正 | 透過對話方式微調特定段落 |
| Word 匯出 | 將 Markdown 草稿匯出為符合期刊格式的 `.docx` 檔案 |
開始之前,請確認您已安裝以下軟體:
| 需求 | 版本 | 檢查方式 | 安裝指南 |
|---|---|---|---|
| Python | 3.10 或更高 | 終端機輸入 `python3 --version` | python.org |
| Git | 任何近期版本 | 終端機輸入 `git --version` | git-scm.com |
| VS Code | 最新版 | 開啟 VS Code → 說明 → 關於 | code.visualstudio.com |
| GitHub Copilot | 擴充功能 | VS Code 擴充功能面板 | 在擴充功能中搜尋 "GitHub Copilot" |
步驟 1:複製專案
開啟終端機並執行:
```bash
cd ~/projects # 或任何您選擇的目錄
git clone https://github.com/u9401066/med-paper-assistant.git
cd med-paper-assistant ```
💡 什麼是 `git clone`? `git clone` 會從 GitHub 下載完整的專案副本到您的電腦。這包含所有程式碼、歷史記錄和分支。
步驟 2:執行安裝腳本
Linux/macOS: ```bash
chmod +x scripts/setup.sh
./scripts/setup.sh ```
Windows(PowerShell - 推薦): ```powershell
.\scripts\setup.ps1 ```
Windows(命令提示字元): ```cmd
scripts\setup.bat ```
這個腳本會自動完成:
- ✅ 建立 Python 虛擬環境(`.venv/`)
- ✅ 安裝所有必要的套件
- ✅ 建立 `.vscode/mcp.json` 設定檔(自動偵測作業系統)
- ✅ 驗證安裝
💡 什麼是虛擬環境? 虛擬環境是一個隔離的 Python 環境,讓這個專案的套件與系統的 Python 分開。這樣可以避免與其他專案產生衝突。
步驟 3:重新載入 VS Code
安裝完成後:
- 開啟 VS Code
- 按下 `Ctrl+Shift+P`(Windows/Linux)或 `Cmd+Shift+P`(Mac)
- 輸入 `Developer: Reload Window` 並按 Enter
💡 為什麼要重新載入? VS Code 需要重新讀取 `.vscode/mcp.json` 設定檔才能啟動 MCP 伺服器。
步驟 4:驗證安裝
在 VS Code 的 Copilot Chat 面板中:
- 輸入
/mcp並按 Enter - 您應該會看到列表中有
mdpaper (50 tools)(如果啟用 Draw.io 整合,還會有drawio (15 tools)) - 如果看到這個,表示安裝成功!🎉
如需圖表生成功能(CONSORT/PRISMA 流程圖),執行:
# 初始化子模組並設定 Draw.io
./scripts/setup-integrations.sh這會新增 drawio MCP 伺服器,提供圖表生成工具。
使用方式:
- 啟動網頁應用:
./scripts/start-drawio.sh - 重新載入 VS Code
- 在 Copilot Chat 中使用 drawio 工具
這些擴展可以增強你的研究工作流程:
| 擴展 | 用途 | 安裝 |
|---|---|---|
| Project Manager | 快速切換專案、側邊欄、標籤 | ext install alefragnani.project-manager |
| Foam | Wikilinks、反向連結、浮動預覽 | ext install foam.foam-vscode |
快速安裝:
code --install-extension alefragnani.project-manager
code --install-extension foam.foam-vscodeMedical Paper Assistant 整合了 Foam 來提供強大的參考文獻連結和預覽系統。
Foam 是一個受 Roam Research 啟發的個人知識管理系統。它將你的 Markdown 文件轉換為互相連結的知識圖譜:
- Wikilinks
[[連結]]- 在筆記之間建立連結 - 浮動預覽 - 滑鼠懸停即可看到內容,無需打開文件
- 反向連結 (Backlinks) - 查看哪些筆記引用了當前文件
- 圖譜視覺化 - 視覺化你的文獻關聯
步驟 1:安裝 Foam 擴展
在 VS Code 中:
- 按
Ctrl+Shift+X打開擴展面板 - 搜尋
foam.foam-vscode - 點擊 安裝
- 重新載入 VS Code(
Ctrl+Shift+P→Developer: Reload Window)
步驟 2:儲存參考文獻
當你儲存參考文獻時,系統會自動建立 Foam 相容的檔案:
# 使用 MCP 工具
save_reference(pmid="38049909")
# 建立的檔案:
references/
├── 38049909/
│ ├── content.md ← 主內容,包含所有引用格式
│ └── metadata.json ← 結構化資料
└── tang2023_38049909.md ← Foam 別名檔,方便連結
步驟 3:在草稿中使用 Wikilinks
# 我的研究草稿
根據 [[tang2023_38049909]] 的研究,remimazolam 在 ICU 鎮靜中
顯示出比 propofol 更好的效果。
另一篇 [[smith2024_41285088]] 的研究也支持這個發現...步驟 4:懸停預覽
將滑鼠移到任何 [[連結]] 上,即可立即看到:
- 📄 論文標題和作者
- 📋 所有引用格式(Vancouver、APA、Nature)
- 📝 完整摘要
- 🔗 可點擊的 DOI 連結
參考文獻以「人性化 + 可驗證」的格式儲存:
[[作者_年份_pmid]]
│ │ │
│ │ └── PMID 用於驗證
│ └── 出版年份
└── 第一作者姓氏
範例:[[tang2023_38049909]]
→ Tang et al., 2023, PMID: 38049909
→ 驗證:https://pubmed.ncbi.nlm.nih.gov/38049909/
懸停參考文獻時,你會看到所有引用格式。專案選擇的格式會用 ⭐ 標記並置頂:
## 📋 Citation Formats
**⭐ APA**: Tang, Y., Gao, X., ... (2023). Remimazolam besylate versus...
**Vancouver**: Tang Y, Gao X, et al. Remimazolam besylate versus...
**Nature**: Tang Y, et al. Remimazolam besylate versus... *Crit Care* **27**...
**In-text**: (Tang et al., 2023)設定你偏好的引用格式:
set_citation_style(style="apa") # 選項:vancouver, apa, nature, harvard, ama
| 功能 | 使用方式 | 好處 |
|---|---|---|
| 懸停預覽 | 滑鼠移到 [[連結]] |
不用開檔案就能看摘要 |
| 反向連結面板 | 開啟任何參考文獻檔案 | 查看哪些草稿引用了這篇論文 |
| 圖譜視圖 | Ctrl+Shift+P → Foam: Show Graph |
視覺化論文之間的關聯 |
| 孤立參考文獻 | Ctrl+Shift+P → Foam: Show Orphans |
找出已儲存但未被引用的論文 |
點擊展開手動安裝步驟
步驟 1:複製專案
```bash git clone https://github.com/u9401066/med-paper-assistant.git cd med-paper-assistant ```
步驟 2:建立虛擬環境
```bash
python3 -m venv .venv
source .venv/bin/activate
.venv\Scripts\activate.bat
.venv\Scripts\Activate.ps1 ```
💡 如何確認虛擬環境已啟動? 啟動後,您的終端機提示符前面會出現 `(.venv)`,例如: ``` (.venv) user@computer:~/med-paper-assistant$ ```
步驟 3:安裝套件
```bash
pip install --upgrade pip
pip install -e . ```
💡 什麼是 `pip install -e .`? `-e` 代表「可編輯模式」(editable mode),這表示當您修改程式碼時,不需要重新安裝就能看到變更。`.` 代表當前目錄。
步驟 4:設定 VS Code MCP
在專案根目錄建立 `.vscode/mcp.json` 檔案:
```bash
mkdir -p .vscode
cat > .vscode/mcp.json << 'EOF' { "inputs": [], "servers": { "mdpaper": { "type": "stdio", "command": "${workspaceFolder}/.venv/bin/python", "args": ["-m", "med_paper_assistant.interfaces.mcp"], "env": { "PYTHONPATH": "${workspaceFolder}/src" } } } } EOF ```
⚠️ Windows 使用者注意:請將 `.venv/bin/python` 改為 `.venv\Scripts\python.exe`
步驟 5:重新載入 VS Code
按下 `Ctrl+Shift+P` → 輸入 `Developer: Reload Window` → 按 Enter
❌ 「找不到命令:python3」
問題:Python 未安裝或不在系統 PATH 中。
解決方案:
- 從 python.org 下載並安裝 Python
- 安裝時,務必勾選「Add Python to PATH」選項
- 重新啟動終端機後再試一次
❌ Copilot 中看不到 MCP 伺服器
問題:VS Code 無法偵測到 MCP 伺服器。
解決方案:
- 確認 `.vscode/mcp.json` 檔案存在且路徑正確
- 確認虛擬環境已建立:執行 `ls .venv/`
- 嘗試重新載入 VS Code:`Ctrl+Shift+P` → `Developer: Reload Window`
- 檢查 VS Code 輸出面板:`檢視` → `輸出` → 從下拉選單選擇「MCP」
❌ 「ModuleNotFoundError: med_paper_assistant」
問題:套件未安裝或 PYTHONPATH 設定錯誤。
解決方案: ```bash
source .venv/bin/activate # Linux/Mac
pip install -e . ```
本助手透過 MCP 與 GitHub Copilot 整合。在 Copilot Chat 中使用 `/mcp.mdpaper.*` 指令。
flowchart LR
A["📝 研究構想<br/>/concept"] --> B["🔍 文獻搜尋<br/>/strategy"]
B --> C["📊 數據分析<br/>/analysis"]
C --> D["✍️ 撰寫草稿<br/>/draft"]
D --> E["🔄 內容修正<br/>/clarify"]
E --> F["📄 格式匯出<br/>/format"]
還不確定研究方向? 先從探索文獻開始!
指令:/mcp.mdpaper.search
flowchart LR
A["🔍 開始探索"] --> B["📚 搜尋並儲存論文"]
B --> C{"找到方向了嗎?"}
C -->|還沒| B
C -->|找到了!| D["📁 轉換成正式專案"]
D --> E["✍️ 開始撰寫"]
使用方式:
-
開始探索 - 自動建立臨時工作區
start_exploration() -
搜尋並儲存有興趣的論文 - 不需要事先決定專案
search_literature(query="您感興趣的主題") save_reference(pmid="12345678") # 儲存有興趣的論文 -
找到研究方向後 - 將探索內容轉換成正式專案
convert_exploration_to_project( name="Your Research Title", # 英文名稱 paper_type="original-research" )
💡 好處:探索期間儲存的所有文獻都會自動轉移到新專案!
開始之前,請整理您的檔案:
| 目錄 | 用途 |
|---|---|
data/ |
將您的 CSV 研究數據放在這裡 |
templates/ |
(選用)期刊 Word 範本 |
指令:`/mcp.mdpaper.concept`
這個引導式流程會幫助您建構具有創新性保護的結構化研究構想:
flowchart LR
A["📚 文獻搜尋"] --> B["🔍 缺口識別"]
B --> C{"❓ 用戶確認缺口"}
C -->|是| D["✍️ 概念撰寫"]
C -->|否| B
D --> E["✅ 驗證概念"]
逐步流程:
-
📚 文獻搜尋(強制)
- Agent 搜尋 PubMed 找出 5-10 篇相關研究
- 重要文獻自動儲存到參考文獻庫
-
🔍 缺口識別(強制)
- Agent 呈現文獻摘要
- 識別研究缺口與限制
- 🛑 詢問您確認您的研究要解決哪個缺口
-
✍️ 概念撰寫(用戶確認後)
- 建立具有保護區塊的結構化概念:
- 🔒 NOVELTY STATEMENT - 創新性聲明(受保護)
- 🔒 KEY SELLING POINTS - 您的 3-5 個核心賣點(受保護)
- 📝 背景、方法、預期結果(可編輯)
- 建立具有保護區塊的結構化概念:
-
✅ 驗證
- 使用
validate_concept工具驗證完整性
- 使用
輸出會儲存到 `drafts/concept_*.md`。
💡 為什麼需要受保護區塊? 🔒 標記確保您的關鍵創新點在撰寫完整論文時被保留。Agent 必須在修改這些區塊前先詢問您。
指令:`/mcp.mdpaper.strategy`
設定文獻搜尋參數:
- 關鍵字與 MeSH 術語
- 排除條件
- 文章類型(Review、Clinical Trial、Meta-Analysis)
- 日期範圍
- 最小樣本數
指令:`/mcp.mdpaper.analysis`
助手會:
- 列出 `data/` 中可用的 CSV 檔案
- 詢問您指定分組變數與結果變數
- 執行適當的統計檢定
- 生成圖表(儲存到 `results/figures/`)
- 建立 Table 1(基線特徵表)
指令:`/mcp.mdpaper.draft`
助手會:
- 讀取您的 `concept.md` 和分析結果
- 詢問使用哪個範本
- 生成 Markdown 草稿,包含:
- 嵌入的圖表
- 自動引用
- 格式化的表格
⚠️ 重要提示:此指令需要 concept 檔案。請先使用 `/mcp.mdpaper.concept` 建立。
指令:`/mcp.mdpaper.clarify`
互動式改善特定段落:
- 「讓 Introduction 寫得更保守一點」
- 「擴充 limitations 段落」
- 「簡化統計方法的描述」
指令:/mcp.mdpaper.format
依照 7 步驟流程:
- 讀取範本結構
- 讀取草稿內容
- 對應章節
- 插入內容
- 驗證文件
- 檢查字數限制
- 儲存最終文件
輸出:results/your_paper.docx
| 目錄 | 用途 |
|---|---|
projects/ |
研究專案(獨立工作區) |
projects/{slug}/concept.md |
研究概念(含受保護區塊) |
projects/{slug}/drafts/ |
Markdown 草稿 |
projects/{slug}/references/{PMID}/ |
本地文獻庫 |
projects/{slug}/data/ |
原始資料檔案(CSV) |
projects/{slug}/results/ |
生成的輸出(圖表、表格、docx) |
└ metadata.json |
引用資訊、格式化的參考文獻 |
└ content.md |
摘要與筆記 |
└ fulltext.pdf |
PDF(若可從 PMC 取得) |
templates/ |
期刊 Word 範本(.docx 用於匯出) |
src/med_paper_assistant/core/ |
核心邏輯模組 |
src/med_paper_assistant/mcp_server/ |
MCP 伺服器實作 |
└ templates/ |
Agent 引導用內部範本(.md) |
tests/ |
測試套件 |
.memory/ |
專案脈絡檔案 |
└ .agent_constitution.md |
Agent 行為規則(動態載入) |
MCP 伺服器會動態載入 .memory/.agent_constitution.md 中的 Agent 憲法。此檔案定義 Copilot 必須遵循的核心行為規則。
憲法結構:
| 部分 | 內容 |
|---|---|
| 第一部分:系統開發 | 語言規則、Memory Bank 維護、程式碼品質、隱私 |
| 第二部分:研究操作 | Concept 流程、受保護內容規則、Draft 撰寫規則 |
受保護內容規則 (🔒):
## 2.2 🔒 受保護內容規則
| 區塊 | 說明 | 規則 |
|------|------|------|
| 🔒 NOVELTY STATEMENT | 研究創新性聲明 | 必須詢問才能修改 |
| 🔒 KEY SELLING POINTS | 核心賣點(3-5點)| 必須詢問才能修改 |
| 🔒 Author Notes | 作者私人備註 | 不可修改 |
修改規則:
✅ 可以潤飾文字
✅ 可以改善學術表達
⛔ 實質修改前必須詢問用戶
⛔ 絕不可刪除受保護內容
⛔ 絕不可弱化核心賣點自訂方式: 編輯 .memory/.agent_constitution.md 並重新載入 VS Code,新規則將自動套用。
系統內建智慧型新穎性驗證功能,確保研究概念在撰寫草稿前真正描述了創新貢獻。
| 設定 | 值 | 說明 |
|---|---|---|
| 評分輪數 | 3 | 獨立評估的次數 |
| 通過門檻 | 75/100 | 每輪最低分數 |
| 通過條件 | 3 輪皆 ≥ 75 | 必須全部通過 |
| 維度 | 權重 | 檢查項目 |
|---|---|---|
| 獨特性 | 25% | 方法/途徑是否獨特? |
| 重要性 | 25% | 貢獻是否有意義? |
| 缺口對齊 | 20% | 新穎性是否解決研究缺口? |
| 具體性 | 15% | 宣稱是否具體明確? |
| 可驗證性 | 15% | 宣稱是否可被驗證/測試? |
- 草稿撰寫前強制驗證:系統強制在使用概念檔案生成草稿前進行驗證
- 多輪評估:使用 3 輪評估提高可靠性,減少誤判
- 高門檻:要求 75+ 確保只有表達清晰的新穎性宣稱能通過
- 可操作的回饋:驗證失敗時提供具體改進建議
技能(Skills)是完整的工作流程定義,引導 AI 完成複雜的多步驟任務。與執行單一動作的工具不同,技能定義了從開始到完成的整個流程。
📁 完整說明文件:.skills/README.md
| 使用者請求 | 要載入的技能 |
|---|---|
| 「幫我做文獻回顧」 | literature_review |
| 「發展研究概念」 | concept_development |
| 「搜尋 [主題] 的論文」 | parallel_search |
| 「寫 Introduction」 | draft_introduction |
| 「寫 Discussion」 | draft_discussion |
| 工具 | 用途 |
|---|---|
list_skills |
顯示所有可用技能 |
load_skill |
載入特定技能的工作流程 |
suggest_skill |
根據任務描述建議適合的技能 |
並行搜尋透過同時執行多組搜尋策略,大幅加速文獻探索。
1. generate_search_queries(topic="remimazolam ICU sedation")
→ 返回 5 組不同的查詢策略
2. 並行執行 search_literature × 5
→ 所有查詢同時執行
3. merge_search_results(...)
→ 返回:42 篇獨特論文(總共 56 篇,移除 14 篇重複)
→ 被多個策略找到的論文標記為「高相關性」
設定一次搜尋策略,自動套用到所有並行查詢:
configure_search_strategy({
"date_range": "2020-2025",
"exclusions": ["animal", "review"],
"article_types": ["Clinical Trial", "RCT"]
})
generate_search_queries(topic="...", use_saved_strategy=True)
→ 所有 5 組查詢都包含日期篩選、排除詞和文章類型限制
| 類別 | 工具 | 說明 |
|---|---|---|
| 搜尋 (10) | search_literature, find_related_articles, find_citing_articles, fetch_article_details, configure_search_strategy, get_search_strategy, generate_search_queries, merge_search_results, expand_search_queries, search_local_references |
文獻探索,透過 pubmed-search-mcp 子模組 |
| 參考文獻 (8) | save_reference, list_saved_references, get_reference_details, read_reference_fulltext, retry_pdf_download, format_references, set_citation_style, insert_citation |
參考文獻管理 |
| 寫作 (16) | write_draft, read_draft, list_drafts, draft_section, get_section_template, count_words, validate_concept, validate_concept_quick, list_templates, read_template, start_document_session, insert_section, verify_document, check_word_limits, save_document, export_word |
草稿準備與匯出 |
| 專案 (15) | create_project, list_projects, switch_project, get_current_project, update_project_status, get_project_paths, get_paper_types, update_project_settings, setup_project_interactive, start_exploration, get_exploration_status, convert_exploration_to_project, save_diagram, save_diagram_standalone, list_diagrams |
專案與圖表管理 |
| 技能 (3) | list_skills, load_skill, suggest_skill |
透過技能系統自動化工作流程 |
備註: 分析工具(
analyze_dataset,run_statistical_test,create_plot,generate_table_one)已移至獨立的 data-analysis-mcp 專案。
🎨 drawio 工具(15 個)- 選用整合
| 類別 | 工具 | 說明 |
|---|---|---|
| 圖表 | create_diagram, edit_diagram, get_diagram_info, apply_diagram_changes |
建立和編輯圖表 |
| 範本 | list_templates, create_from_template |
架構範本(AWS、GCP、Azure) |
| 指引 | get_drawing_guidelines, get_style, list_styles |
繪圖最佳實踐 |
| 檔案 | load_file, save_tab |
檔案管理 |
```bash
source .venv/bin/activate
pytest tests/
pytest tests/test_search.py
pytest tests/ -v ```
我們正在積極開發新功能,以下是規劃中的項目:
| 狀態 | 功能 | 說明 |
|---|---|---|
| ✅ | Draw.io 整合 | 透過 next-ai-draw-io 生成 CONSORT/PRISMA 流程圖,支援即時 WebSocket 同步 |
| ✅ | 技能系統 | 工作流程定義,引導 AI 完成複雜任務 - 見說明文件 |
| ✅ | 並行搜尋 | 生成多組搜尋語法並同時執行 - 運作方式 |
| ✅ | 搜尋策略整合 | 設定一次,處處套用 - 策略自動整合到並行查詢 |
| ✅ | Table 1 生成器 | 透過 generate_table_one 從 CSV 自動生成基線特徵表 |
| ✅ | Foam 整合 | Wikilinks [[citation_key]]、懸停預覽、反向連結面板 - 參考文獻管理 |
| ✅ | PubMed MCP | 獨立的 MCP 伺服器用於文獻搜尋 - 可單獨使用 |
| 🔜 | 多語言支援 | 完整 UI 本地化,不只英文/中文 |
| 🔜 | 期刊樣式庫 | 預設主要醫學期刊的格式設定 |
| 📋 | REST API 模式 | 將 MCP 工具以 REST API 形式公開,供外部整合 |
| 📋 | Dashboard 檔案瀏覽器 | 整合 Chonky React 檔案瀏覽元件到 Dashboard,視覺化管理專案檔案 |
| 📋 | 協作模式 | 多作者工作流程與版本控制 |
| 📋 | AI 輔助審稿 | 使用 LLM 審閱並改善論文段落 |
圖例: ✅ 已完成 | 🔜 進行中 | 📋 規劃中
想幫忙?查看 CONTRIBUTING.md 或開 issue 來討論!
我們歡迎社群的貢獻!無論你是有工作流程想法的醫學研究人員、想添加功能的開發者,或是發現 bug 的使用者 - 我們都很樂意聽到你的聲音。
貢獻方式:
- 🐛 回報 Bug - 開 issue 描述問題
- 💡 建議功能 - 分享你對新工具或工作流程的想法
- 📝 改善文件 - 幫忙讓 README 更清楚
- 🔧 提交程式碼 - Fork、開發、送 PR
- 🌐 翻譯 - 幫忙翻譯成其他語言
開始貢獻:
- Fork 這個 repository
- 建立功能分支 (
git checkout -b feature/amazing-feature) - Commit 你的修改 (
git commit -m 'Add amazing feature') - Push 到分支 (
git push origin feature/amazing-feature) - 開一個 Pull Request
詳細指南請參閱 CONTRIBUTING.md。
本專案採用 MIT 授權。詳見 LICENSE 檔案。
如果你覺得這個專案有幫助,請考慮給它一顆星!這能幫助其他人發現這個專案。
