Skip to main content
Glama
liangjunyu2010

Baidu Cloud AI Content Safety MCP Server

input_analyze

Analyzes text using Baidu Cloud AI Content Safety MCP Server to identify and flag potential security risks or unsafe content for moderation purposes.

Instructions

Name:
    检测文本安全

Description:
    将文本进行检测,判断是否存在风险内容

Args:
    text:  待检测文本

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
textYes

Implementation Reference

  • The core handler function for the 'input_analyze' tool. It takes input text, authenticates and calls Baidu's LLM input safety analysis API (/rcs/llm/input/analyze), and returns the analysis result.
    @mcp.tool()
    async def input_analyze(
            text: str,
            ctx: Context
    ) -> dict:
        """
        Name:
            检测文本安全
    
        Description:
            将文本进行检测,判断是否存在风险内容
    
        Args:
            text:  待检测文本
        """
    
        try:
    
            credentials = BceCredentials(access_key_id, secret_access_key)  # 填写ak、sk
    
            # API接口的请求方法
            http_method = "POST"
            # 接口请求路径
            input_path = "/rcs/llm/input/analyze"
    
            # -----------------------输入安全------------------------------
            # 接口请求的header头
            headers = {
                "host": "afd.bj.baidubce.com",
                "content-type": "application/json; charset=utf-8",
                "x-bce-date": datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ"),
            }
            # 设置参与鉴权的时间戳
            timestamp = int(time.time())
            # 接口请求参数
            params = {}
            # 接口请求的body数据
            body = {
                "query": text,
                "appid": "",
                "historyQA": []
            }
            # 设置参与鉴权编码的header,即headers_to_sign,至少包含host,百度智能云API的唯一要求是Host域必须被编码
            headers_to_sign = {
                "host",
                "x-bce-date",
            }
            # 设置到期时间,默认1800s
            expiration_in_seconds = 18000
            # 生成鉴权字符串
            result = sign(credentials, http_method, input_path, headers, params, timestamp, expiration_in_seconds,
                          headers_to_sign)
    
            headers['authorization'] = result
    
            # 拼接接口的url地址
            url = 'http://%s%s' % (headers['host'], input_path)
    
            async with httpx.AsyncClient() as client:
                response = await client.post(url, headers=headers, json=body)
                response.raise_for_status()
                result = response.json()
    
            # if result.get("status") != 0:
            #     error_msg = result.get("message", "unkown error")
            #     raise Exception(f"API response error: {error_msg}")
            result['req'] = body
            return result
    
        except httpx.HTTPError as e:
            raise Exception(f"HTTP request failed: {str(e)}") from e
        except KeyError as e:
            raise Exception(f"Failed to parse reponse: {str(e)}") from e
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 of behavioral disclosure. It mentions detecting risky content but doesn't specify what types of risks (e.g., hate speech, spam), how results are returned, error conditions, or any rate limits. This leaves significant gaps for an agent to understand the tool's behavior.

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 appropriately sized and front-loaded with the tool's name and purpose. It uses a clear structure with Name, Description, and Args sections, though the formatting could be more polished. Every sentence earns its place without unnecessary elaboration.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete. It doesn't explain what the output looks like (e.g., risk score, categories), error handling, or operational constraints. For a tool with behavioral complexity (risk detection), this leaves too many unknowns for an agent.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaning by specifying 'text' as '待检测文本' (text to be detected), which clarifies the parameter's purpose. However, it doesn't provide details on text length limits, language support, or format requirements, leaving some ambiguity.

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: '检测文本安全' (detect text safety) and '将文本进行检测,判断是否存在风险内容' (analyze text to determine if it contains risky content). It specifies the verb (detect/analyze) and resource (text), though it doesn't differentiate from siblings since none exist.

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?

No guidance is provided on when to use this tool versus alternatives. The description only states what the tool does, not when it should be invoked or any prerequisites. With no sibling tools, this is less critical, but still a gap in usage context.

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

Related 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/liangjunyu2010/mcp_server_safe_content_check'

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