taxonomy_upsert_term
Add or update taxonomy rules for organizing academic literature by defining classification patterns, priorities, and categories.
Instructions
添加或更新词表规则
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | Yes | ||
| family | Yes | ||
| pattern | Yes | ||
| priority | No | ||
| enabled | No | ||
| notes | No |
Implementation Reference
- The main handler function for the 'taxonomy_upsert_term' tool. It adds or updates a taxonomy term in the 'taxonomy_terms' table using PostgreSQL INSERT with ON CONFLICT DO NOTHING.@mcp.tool() def taxonomy_upsert_term( kind: str, family: str, pattern: str, priority: int = 100, enabled: bool = True, notes: str | None = None, ) -> dict[str, Any]: """添加或更新词表规则""" try: with get_db() as conn: with conn.cursor() as cur: cur.execute(""" INSERT INTO taxonomy_terms (kind, family, pattern, priority, enabled, notes) VALUES (%s, %s, %s, %s, %s, %s) ON CONFLICT DO NOTHING RETURNING term_id """, (kind, family, pattern, priority, enabled, notes)) result = cur.fetchone() term_id = result["term_id"] if result else None return {"term_id": term_id, "created": term_id is not None} except Exception as e: return {"error": str(e)}
- src/paperlib_mcp/server.py:52-52 (registration)Registers the graph_v12 tools, including 'taxonomy_upsert_term', by calling the register_graph_v12_tools function.register_graph_v12_tools(mcp)