MCP-Query-Validation

このプロジェクトは、入力されたクエリを検証し、機密情報の漏洩を防ぐためのMCPサーバーを提供します。自動的に機密データを検出し、マスクする機能を持ち、すべての活動は監査と監視のためにログに記録されます。

GitHubスター

1

ユーザー評価

未評価

フォーク

0

イシュー

0

閲覧数

2

お気に入り

0

README
MCP Validation Server

This project provides an MCP server for validation of entered queries to prevent sensitive information leaks. It automatically detects and masks sensitive data (such as emails, phone numbers, SSNs, credit cards, etc.) in every query processed by the server. All activities are logged for audit and monitoring purposes.

Features
  • Sensitive Data Masking: Automatically detects and masks sensitive information in queries, including:
    • Emails
    • Phone numbers
    • Social Security Numbers (SSNs)
    • Credit card numbers
    • IP addresses
    • Dates of birth
    • Addresses
    • Zip codes
  • Comprehensive Logging: All validation activities and system events are logged with timestamps.
  • MCP Server Integration: Runs as an MCP server, validating every incoming query before further processing.
How It Works
  • The server uses a custom FastMCP class that intercepts every query, applies sensitive data masking, and then processes the (masked) query.
  • All validation and masking actions are logged to timestamped log files in the logs/ directory.
Setup & Installation
  1. Clone the repository

    git clone <your-repo-url>
    cd mcp-validation
    
  2. Install Python 3.11+ Ensure you have Python 3.11 or higher installed.

  3. Install dependencies

    pip install -r requirements.txt
    # OR, if using PEP 621/pyproject.toml:
    pip install .
    

    (Dependencies are specified in pyproject.toml.)

Running the MCP Validation Server

Start the server with:

python main.py

You should see output indicating the MCP server is running for validation.

Usage Example

You can interact with the MCP server using your preferred MCP client, or by integrating it into your workflow. Every query sent to the server will be validated and masked as needed.

If you want to use the validation logic directly in Python:

from validation_tools import validate_data

result = validate_data("My email is john@example.com and phone is 555-123-4567")
print(result)
Logging
  • Logs are stored in the logs/ directory.
  • Each server session creates a new log file named validation_tools_YYYYMMDD_HHMMSS.log.
  • Logs include:
    • Query validation events
    • Masked sensitive data
    • System events (startup, shutdown, errors)
Example Log Entry
{
  "timestamp": "2024-01-15T10:30:45.123456",
  "event": "Validating data: My email is john@example.com and phone is 555-123-4567"
}
File Structure
mcp-validation/
├── main.py                 # Main server entry point
├── validation_tools.py     # Core validation and masking logic
├── logs/                   # Log files directory
│   └── validation_tools_YYYYMMDD_HHMMSS.log
├── pyproject.toml          # Project dependencies
├── uv.lock                 # Dependency lock file
└── README.md               # This file
Security & Privacy
  • All sensitive information in queries is masked before further processing.
  • All actions are logged for audit and monitoring.
Troubleshooting
  • Log Files Not Created: Ensure the logs/ directory exists and has write permissions.
  • Python Version Issues: Make sure you are using Python 3.11 or higher.
License

MIT License (or specify your license here)

作者情報
SIvasai Mudadla

Generative AI developer with 2.5 years of experience crafting innovative Retrieval-Augmented Generation (RAG) applications, smart assistants, and agentic workfl

Youngsoft India Pvt. Ltd.Hyderabad, India

0

フォロワー

9

リポジトリ

0

Gist

1

貢献数

トップ貢献者

スレッド