Multi-Agent

raywong2121/Multi-Agent

3.2

If you are the rightful owner of Multi-Agent and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

This project implements a multi-agent deliberative intelligence approach for Chinese medical imaging report text standardization using the Model Context Protocol (MCP).

Tools
5
Resources
0
Prompts
0

Multi-Agent Deliberative Intelligence Chinese Medical Imaging Report Text Standardization MCP Server

Project Overview

This project implements a multi-agent deliberative intelligence approach for Chinese medical imaging report text standardization, delivered through the Model Context Protocol (MCP). The system employs a complete processing pipeline of "LLM Tokenization & POS Tagging → Medical Entity Recognition → Six-Agent Collaboration → Quality Gates" to efficiently and accurately convert Chinese imaging reports to OMOP CDM 5.4 standard format.

Core Features

šŸ¤– Six-Agent Collaborative Architecture

  • Linguist Agent: Performs text normalization, syntactic analysis, and ambiguity resolution
  • Structurer Agent: Strictly follows OHDSI separation of concerns principles, decomposing concepts into independent standard components
  • Mapper Agent: Uses ReAct (Reasoning-Acting) mode to rapidly generate concept mapping proposals
  • Skeptic Agent: Specializes in challenging and validating mapper proposals to ensure quality control
  • Auditor Agent: Performs final validation based on complete deliberation history
  • OMOP Builder: Converts validated concept mappings to OMOP CDM 5.4 standard format according to OHDSI community best practices

🧠 Deliberative Intelligence Algorithm

  • Proposer-Skeptic Adversarial Mechanism: Ensures high-quality and reliable concept mapping through multi-round deliberation
  • Dynamic Threshold Adjustment: Adaptive threshold adjustment based on terminology complexity and context
  • Multi-Strategy Concept Search: Four-tier matching strategies (exact match, synonym match, fuzzy match, semantic match)

šŸ›”ļø Quality Control System

  • Four-Dimensional Quality Assessment: Logical consistency, deliberation quality, evidence strength, OHDSI compliance
  • Multi-Level Quality Gate Mechanism: High/medium/low confidence level processing
  • Real-Time Quality Monitoring: Provides detailed quality assessment reports and improvement recommendations

šŸ„ OMOP CDM 5.4 Integration

  • SNOMED CT Terminology Mapping: Precise concept alignment and standardization
  • Multi-Table Record Generation: Reasonable allocation to OBSERVATION, MEASUREMENT, FACT_RELATIONSHIP tables
  • OHDSI Best Practices: Follows Observational Health Data Sciences and Informatics collaborative organization standards

Technical Architecture

Chinese Imaging Report → [LLM Sentence-by-Sentence Tokenization + POS Tagging] → POS-Tagged Entities → [Medical Entity Validation] → Enhanced Entity Annotation
    ↓                    (ANATOMY/FINDING/ATTRIBUTE/MODIFIER/NEGATION/MEASUREMENT/PROCEDURE)
[Linguist Agent] → Normalized Text + Semantic Segments → [Structurer Agent] → Structured Entity List
    ↓
[Mapper ↔ Skeptic Deliberation] → POS Tag Validated Mapping → [Auditor Agent] → Quality Validation
    ↓
[OMOP Builder] → OBSERVATION/MEASUREMENT/FACT_RELATIONSHIP Table Records → Local Database Storage

Installation and Deployment

Environment Requirements

  • Node.js >= 18.0.0
  • TypeScript >= 5.3.0
  • OpenAI-compatible LLM Service
  • PostgreSQL Database

Installation Steps

  1. Clone Repository
git clone <repository-url>
cd medical-text-standardization-mcp
  1. Configure Environment Variables
# Copy environment configuration file
cp .env.example .env

# Edit configuration file (pre-configured with real services)
# LLM Service:
# Database: 
  1. Install Dependencies
npm install
  1. Build Project
npm run build
  1. Health Check
# Check LLM service


# Check database connection

  1. Start Server
npm start

Development Mode

npm run dev

MCP Tools Usage

1. Process Medical Report

{
  "name": "process_medical_report",
  "arguments": {
    "reportText": "Patient chest CT examination shows a nodule in the left upper lobe with a diameter of approximately 12mm, clear boundaries, and uniform density.",
    "reportId": "R001",
    "patientId": "P12345",
    "reportType": "CT"
  }
}

2. Analyze Medical Concept

{
  "name": "analyze_medical_concept",
  "arguments": {
    "concept": "pulmonary nodule",
    "context": "chest CT examination finding"
  }
}

3. Validate Concept Mapping

{
  "name": "validate_concept_mapping",
  "arguments": {
    "sourceText": "pulmonary nodule",
    "targetConceptId": 4230254
  }
}

4. Search OMOP Concepts

{
  "name": "search_omop_concepts",
  "arguments": {
    "query": "pulmonary nodule",
    "domain": "Condition",
    "limit": 10
  }
}

5. Get Processing Statistics

{
  "name": "get_processing_statistics",
  "arguments": {}
}

Configuration Guide

Agent Configuration

agents: {
  linguist: {
    name: 'Linguist',
    model: '',
    temperature: 0.3,
    maxTokens: 2048
  },
  // ... other agent configurations
}

Quality Threshold Configuration

qualityThresholds: {
  logicalConsistency: 0.8,
  deliberationQuality: 0.75,
  evidenceStrength: 0.7,
  ohdsiCompliance: 0.85,
  overallScore: 0.8
}

Performance Metrics

Based on research paper experimental results:

  • Concept Mapping Accuracy: 95.2%
  • Processing Speed: 1,200 reports/hour
  • F1 Score: 0.943
  • Quality Gate Pass Rate: 93.7%
  • Deliberation Rounds: Average 2.3 rounds
  • Consensus Achievement Rate: 94.7%

Project Structure

src/
ā”œā”€ā”€ agents/           # Six-agent implementation
│   ā”œā”€ā”€ system.ts     # Multi-agent system
│   ā”œā”€ā”€ linguist.ts   # Linguist agent
│   ā”œā”€ā”€ structurer.ts # Structurer agent
│   ā”œā”€ā”€ mapper.ts     # Mapper agent
│   ā”œā”€ā”€ skeptic.ts    # Skeptic agent
│   ā”œā”€ā”€ auditor.ts    # Auditor agent
│   └── omop-builder.ts # OMOP Builder agent
ā”œā”€ā”€ core/             # Core processing logic
│   ā”œā”€ā”€ processor.ts  # Medical text processor
│   └── quality-gate.ts # Quality gate mechanism
ā”œā”€ā”€ services/         # Service layer
│   └── omop-builder.ts # OMOP builder service
ā”œā”€ā”€ types/            # Type definitions
│   └── index.ts
ā”œā”€ā”€ utils/            # Utility classes
│   └── logger.ts
ā”œā”€ā”€ config/           # Configuration management
│   └── index.ts
└── index.ts          # MCP server entry point

Data Privacy and Security

Real Service Integration

  • Production-Grade LLM Service: Integrated OpenAI-compatible LLM2.5 model providing high-quality medical text understanding
  • Enterprise Database: Connected to PostgreSQL OHDSI database supporting real OMOP concept queries
  • Health Check Mechanism: Automatic service availability detection ensuring stable system operation
  • Configuration Management: Flexible service connection parameter configuration through environment variables

Security Features

  • Data Encryption: Support for data transmission and storage encryption
  • Access Control: Role-based access control mechanism
  • Audit Logging: Complete operational audit tracking

Quality Assurance

Test Coverage

  • Unit Testing: Coverage of all core components
  • Integration Testing: End-to-end process validation
  • Performance Testing: Large-scale data processing validation

Quality Monitoring

  • Real-time Monitoring: Real-time processing quality monitoring
  • Anomaly Detection: Automatic identification of abnormal mappings
  • Quality Reports: Regular generation of quality analysis reports

Extension and Customization

Agent Extension

// Custom agent example
class CustomAgent extends BaseAgent {
  async process(input: any): Promise<any> {
    // Custom processing logic
  }
}

Mapping Strategy Extension

// Custom mapping strategy
const customStrategy: MappingStrategyConfig = {
  strategy: 'custom_match',
  weight: 0.9,
  threshold: 0.85,
  enabled: true
};

Troubleshooting

Common Issues

  1. Server Startup Failure

    • Check if Node.js version >= 18.0.0
    • Confirm all dependencies are correctly installed
    • Check if port is occupied
  2. Low Mapping Quality

    • Adjust quality threshold configuration
    • Check medical dictionary completeness
    • Optimize agent prompts
  3. Slow Processing Speed

    • Check local LLM performance
    • Adjust concurrent processing count
    • Optimize database queries

Log Analysis

# View server logs
tail -f logs/mcp-server.log

# View quality gate logs
tail -f logs/quality-gate.log

# View agent logs
tail -f logs/linguist.log

Contributing Guide

Development Environment Setup

  1. Fork the project repository
  2. Create feature branch
  3. Commit code changes
  4. Create Pull Request

Code Standards

  • Use TypeScript strict mode
  • Follow ESLint configuration
  • Add appropriate unit tests
  • Update relevant documentation

License

This project is licensed under the MIT License.

Contact

Acknowledgments

Thanks to the following organizations and projects for their support:

  • OHDSI (Observational Health Data Sciences and Informatics)
  • SNOMED International
  • Model Context Protocol (MCP) Community

Note: This project is for research and educational purposes only. Before using in production environments, please ensure compliance with relevant medical regulations and data protection requirements.