Skip to main content
Glama
czangyeob

MCP PII Tools

by czangyeob

mcp_encrypt_text_pii

Detect and encrypt personally identifiable information (PII) in text using GPT-4o-based detection and advanced cryptographic methods for data protection.

Instructions

MCP Tool: 텍스트에서 PII를 탐지하고 암호화

Args:
    text (str): 처리할 텍스트
    
Returns:
    Dict[str, Any]: 암호화 처리 결과

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'mcp_encrypt_text_pii' tool. It is registered via the @mcp.tool() decorator. The function detects PII using mcp_detect_pii, encrypts each PII item with PIICrypto, replaces them in the original text, and returns the encrypted text along with mappings and summary.
    @mcp.tool()
    def mcp_encrypt_text_pii(text: str) -> Dict[str, Any]:
        """
        MCP Tool: 텍스트에서 PII를 탐지하고 암호화
        
        Args:
            text (str): 처리할 텍스트
            
        Returns:
            Dict[str, Any]: 암호화 처리 결과
        """
        try:
            start_time = time.time()
            
            # 1. PII 탐지
            detection_result = mcp_detect_pii(text)
            
            if not detection_result["success"]:
                return detection_result
            
            if not detection_result["pii_items"]:
                return {
                    "success": True,
                    "original_text": text,
                    "encrypted_text": text,
                    "pii_items": [],
                    "encrypted_items": {},
                    "count": 0,
                    "processing_time": time.time() - start_time,
                    "summary": {}
                }
            
            # 2. PII 항목들 암호화
            crypto = PIICrypto()
            encrypted_items = {}
            encrypted_text = text
            
            for item in detection_result["pii_items"]:
                pii_type = item["type"]
                pii_value = item["value"]
                
                # 암호화
                encrypted_value = crypto.encrypt_pii_item(pii_value, pii_type)
                encrypted_items[pii_value] = encrypted_value
                
                # 텍스트에서 치환
                encrypted_text = encrypted_text.replace(pii_value, encrypted_value)
            
            processing_time = time.time() - start_time
            
            return {
                "success": True,
                "original_text": text,
                "encrypted_text": encrypted_text,
                "pii_items": detection_result["pii_items"],
                "encrypted_items": encrypted_items,
                "count": len(detection_result["pii_items"]),
                "processing_time": processing_time,
                "summary": detection_result["summary"]
            }
            
        except Exception as e:
            return {
                "success": False,
                "error": str(e),
                "original_text": text,
                "encrypted_text": text,
                "pii_items": [],
                "encrypted_items": {},
                "count": 0,
                "processing_time": 0,
                "summary": {}
            }
  • The JSON schema defining the input parameters for the mcp_encrypt_text_pii tool, part of the MCP_TOOLS dictionary used for tool metadata.
    "encrypt_text_pii": {
        "name": "encrypt_text_pii",
        "description": "텍스트에서 PII를 탐지하고 모든 PII를 암호화합니다. 검색 가능한 암호화된 텍스트를 생성합니다.",
        "parameters": {
            "type": "object",
            "properties": {
                "text": {
                    "type": "string",
                    "description": "처리할 텍스트"
                }
            },
            "required": ["text"]
        }
    },
  • The @mcp.tool() decorator registers the mcp_encrypt_text_pii function with the FastMCP server instance.
    @mcp.tool()
  • Test usage of the tool in the main() function.
    encrypt_text_result = mcp_encrypt_text_pii(test_text)
    if encrypt_text_result['success']:
  • Import of the tool function in the example file.
    mcp_encrypt_text_pii,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It mentions detection and encryption but lacks critical behavioral details: what types of PII are detected, the encryption method used, whether the operation is reversible (hinted by 'mcp_decrypt_text_pii' sibling), performance characteristics, or error handling. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured: it starts with the tool's purpose, lists the single argument with a brief explanation, and notes the return type. There's no unnecessary information, and it's front-loaded with the core functionality. However, the lack of usage context or behavioral details slightly limits its effectiveness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (detection and encryption), no annotations, and an output schema (which handles return values), the description is partially complete. It covers the basic purpose and parameter but misses usage guidelines, behavioral transparency, and differentiation from siblings. This makes it minimally viable but insufficient for optimal agent decision-making.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal semantics beyond the input schema. It states 'text (str): 처리할 텍스트' (text to process), which slightly clarifies the parameter's purpose but doesn't provide format constraints, length limits, or examples. With 0% schema description coverage and only one parameter, this is a baseline score—adequate but with clear gaps in detailed guidance.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '텍스트에서 PII를 탐지하고 암호화' (detect and encrypt PII in text). It specifies both the action (detect and encrypt) and the resource (text with PII). However, it doesn't explicitly differentiate from sibling tools like 'mcp_detect_pii' (detection only) or 'mcp_encrypt_pii_item' (encrypts individual PII items), which prevents a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'mcp_detect_pii' (detection only), 'mcp_encrypt_pii_item' (encrypts individual items), and 'mcp_anonymize_text' (anonymization), there's no indication of the specific use cases, prerequisites, or trade-offs for choosing this combined detection+encryption tool over others.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/czangyeob/mcp-pii-tools'

If you have feedback or need assistance with the MCP directory API, please join our Discord server