Skip to main content
Glama

lock_entity

Prevent automatic normalization and merging of academic literature entities by locking them in Paperlib MCP. Specify entity ID and lock status to control entity management.

Instructions

锁定或解锁实体

锁定的实体不会被自动规范化合并。

Args: entity_id: 实体 ID is_locked: 是否锁定,默认 True

Returns: 操作结果

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
entity_idYes
is_lockedNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'lock_entity' tool. Updates the 'is_locked' field in the 'entities' table for the given entity_id.
    @mcp.tool()
    def lock_entity(entity_id: int, is_locked: bool = True) -> dict[str, Any]:
        """锁定或解锁实体
        
        锁定的实体不会被自动规范化合并。
        
        Args:
            entity_id: 实体 ID
            is_locked: 是否锁定,默认 True
            
        Returns:
            操作结果
        """
        try:
            with get_db() as conn:
                with conn.cursor() as cur:
                    cur.execute(
                        """
                        UPDATE entities SET is_locked = %s, updated_at = now()
                        WHERE entity_id = %s
                        RETURNING entity_id
                        """,
                        (is_locked, entity_id)
                    )
                    result = cur.fetchone()
                    
                    if not result:
                        return LockEntityOut(
                            ok=False,
                            error=MCPErrorModel(code="NOT_FOUND", message=f"Entity {entity_id} not found"),
                        ).model_dump()
            
            return LockEntityOut(ok=True).model_dump()
            
        except Exception as e:
            return LockEntityOut(
                ok=False,
                error=MCPErrorModel(code="DB_CONN_ERROR", message=str(e)),
            ).model_dump()
  • Pydantic schemas defining input (LockEntityIn) and output (LockEntityOut) models for the lock_entity tool.
    class LockEntityIn(BaseModel):
        """lock_entity 输入"""
        entity_id: int
        is_locked: bool = True
    
    
    class LockEntityOut(BaseModel):
        """lock_entity 输出"""
        ok: bool
        error: Optional[MCPErrorModel] = None
  • Registration of the graph_canonicalize_tools module, which includes the lock_entity tool, on the main FastMCP instance.
    register_graph_canonicalize_tools(mcp)
  • The @mcp.tool() decorator registers the lock_entity function directly when the register_graph_canonicalize_tools function is called.
    @mcp.tool()
    def lock_entity(entity_id: int, is_locked: bool = True) -> dict[str, Any]:
        """锁定或解锁实体
        
        锁定的实体不会被自动规范化合并。
        
        Args:
            entity_id: 实体 ID
            is_locked: 是否锁定,默认 True
            
        Returns:
            操作结果
        """
        try:
            with get_db() as conn:
                with conn.cursor() as cur:
                    cur.execute(
                        """
                        UPDATE entities SET is_locked = %s, updated_at = now()
                        WHERE entity_id = %s
                        RETURNING entity_id
                        """,
                        (is_locked, entity_id)
                    )
                    result = cur.fetchone()
                    
                    if not result:
                        return LockEntityOut(
                            ok=False,
                            error=MCPErrorModel(code="NOT_FOUND", message=f"Entity {entity_id} not found"),
                        ).model_dump()
            
            return LockEntityOut(ok=True).model_dump()
            
        except Exception as e:
            return LockEntityOut(
                ok=False,
                error=MCPErrorModel(code="DB_CONN_ERROR", message=str(e)),
            ).model_dump()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that locked entities won't be automatically normalized/merged, which is useful behavioral context. However, it doesn't describe what '操作结果' (operation result) contains, whether the operation requires specific permissions, if it's reversible, or any side effects. For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 concise with a clear structure: purpose statement followed by Args and Returns sections. Each sentence earns its place, though the Returns section is vague ('操作结果'). The Chinese text is efficient without unnecessary elaboration.

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 has an output schema (which should document return values), the description doesn't need to explain returns in detail. However, for a mutation tool with no annotations and 0% schema description coverage, the description should do more to explain behavioral implications, usage context, and parameter details. The current description is minimally adequate but leaves important questions unanswered about when and how to use this tool effectively.

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 schema provides no parameter documentation. The description adds basic semantics: 'entity_id: 实体 ID' and 'is_locked: 是否锁定,默认 True'. This explains what each parameter represents and notes the default value for is_locked. However, it doesn't provide format details for entity_id (e.g., valid ranges) or clarify what '默认 True' means in practice (defaults to locking unless specified otherwise?).

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: '锁定或解锁实体' (lock or unlock entity). It specifies the verb (lock/unlock) and resource (entity), and mentions that locked entities won't be automatically normalized/merged, which adds useful context. However, it doesn't explicitly differentiate this from sibling tools like 'merge_entities' or 'canonicalize_entities_v1', which appear related to entity management.

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. It doesn't mention prerequisites, scenarios where locking/unlocking is appropriate, or how it relates to sibling tools like 'merge_entities' or 'canonicalize_entities_v1'. The only implied usage is controlling entity normalization, but this is too vague for effective tool selection.

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/h-lu/paperlib-mcp'

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