Skip to main content
Glama

export_relations_compact_v1

Export aggregated canonical relationships from academic literature to create compact knowledge graph views for analysis and management.

Instructions

导出紧凑的关系视图(按 canonical 关系聚合)。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
comm_idNo
pack_idNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main tool handler function that queries and exports compact canonical relations with evidence counts, filtered by community or pack.
    def export_relations_compact_v1(
        comm_id: int | None = None,
        pack_id: int | None = None,
    ) -> dict[str, Any]:
        """导出紧凑的关系视图(按 canonical 关系聚合)。"""
        try:
            where_clauses = []
            params = []
            
            if comm_id:
                where_clauses.append("""
                    EXISTS (
                        SELECT 1 FROM community_members cm 
                        WHERE cm.comm_id = %s AND (cm.entity_id = cr.subj_entity_id OR cm.entity_id = cr.obj_entity_id)
                    )
                """)
                params.append(comm_id)
            elif pack_id:
                where_clauses.append("""
                    EXISTS (
                        SELECT 1 FROM evidence_pack_items epi
                        JOIN canonical_relation_evidence cre ON cre.chunk_id = epi.chunk_id
                        WHERE epi.pack_id = %s AND cre.canon_rel_id = cr.canon_rel_id
                    )
                """)
                params.append(pack_id)
                
            where_sql = " WHERE " + " AND ".join(where_clauses) if where_clauses else ""
            
            sql = f"""
                SELECT 
                    cr.canon_rel_id, 
                    s.canonical_name as subj_name, 
                    cr.predicate_norm, 
                    o.canonical_name as obj_name, 
                    cr.qualifiers_norm,
                    (SELECT COUNT(*) FROM canonical_relation_evidence cre WHERE cre.canon_rel_id = cr.canon_rel_id) as evidence_count
                FROM canonical_relations cr
                JOIN entities s ON s.entity_id = cr.subj_entity_id
                JOIN entities o ON o.entity_id = cr.obj_entity_id
                {where_sql}
                ORDER BY evidence_count DESC
            """
            rows = query_all(sql, tuple(params))
            
            return ExportRelationsCompactOut(relations=rows).model_dump()
            
        except Exception as e:
            return ExportRelationsCompactOut(
                error=MCPErrorModel(code="SYSTEM_ERROR", message=str(e))
            ).model_dump()
  • Pydantic input and output models for schema validation of the tool.
    class ExportRelationsCompactIn(BaseModel):
        """export_relations_compact_v1 输入"""
        comm_id: Optional[int] = None
        pack_id: Optional[int] = None
    
    
    class ExportRelationsCompactOut(BaseModel):
        """export_relations_compact_v1 输出"""
        relations: list[dict[str, Any]] = Field(default_factory=list)
        error: Optional[MCPErrorModel] = None
  • Registration of the graph_relation_canonicalize_tools module in the main MCP server, which includes the export_relations_compact_v1 tool.
    register_graph_relation_canonicalize_tools(mcp)
Behavior2/5

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

No annotations are provided, so the description carries full burden. It states '导出' (export), implying a read-only operation that generates output, but doesn't disclose behavioral traits like whether it's safe, requires authentication, has side effects, or handles errors. The mention of '按 canonical 关系聚合' (aggregated by canonical relations) adds some context about processing logic, but critical behavioral aspects remain undocumented.

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

Conciseness5/5

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

The description is a single, efficient sentence in Chinese with zero waste. It's front-loaded with the core action and resource, making it easy to parse. Every word contributes meaning, achieving optimal conciseness for the limited information provided.

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 reduces need to describe return values) but no annotations and 0% schema coverage, the description is minimally adequate. It states the export function and aggregation method, but gaps in parameter semantics and behavioral transparency make it incomplete for confident use. The presence of an output schema slightly mitigates the lack of return value explanation.

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

Parameters2/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 for undocumented parameters. It adds no information about the two parameters (comm_id, pack_id), their meanings, or how they affect the export. Without parameter semantics in the description, the agent lacks context for using these optional integer inputs effectively.

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

Purpose3/5

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

The description '导出紧凑的关系视图(按 canonical 关系聚合)' states the action (export) and resource (compact relation view) but is vague about what 'compact relation view' means. It mentions aggregation by canonical relations, which provides some specificity, but doesn't clearly distinguish from sibling tools like export_claim_matrix_grouped_v1 or export_evidence_matrix_v1. The purpose is understandable but lacks concrete differentiation.

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 doesn't mention prerequisites, context, or exclusions. With multiple export-related siblings (e.g., export_claim_matrix_grouped_v1, export_evidence_matrix_v1), the absence of usage guidelines leaves the agent guessing about appropriate scenarios for this specific export function.

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