From 00c880adab3b22be92e90a60dd6cf62a5a9e6a48 Mon Sep 17 00:00:00 2001 From: "Claude Sonnet 4.6" Date: Sun, 5 Apr 2026 09:47:53 +0000 Subject: [PATCH] fix: update cypher-rs to support claims via graph relationships MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update cypher-rs to latest version with unified JSON-to-graph conversion - Fix API call: from_json_auto_as_root_with_label → from_json_with_label - Update SKILL.md to document relationship-based claims access With the new cypher-rs, array fields (claims, description_paragraphs) are converted to graph relationships rather than properties. Users must now access claims via: MATCH (p:Patent)-[:claims]->(c) RETURN c.number, c.text Co-Authored-By: Claude Sonnet 4.6 --- Cargo.lock | 2 +- claude-plugin/skills/patent-fetch/SKILL.md | 28 +++++++++++++++++++--- src/mcp/mod.rs | 2 +- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26795a1..61d5130 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -303,7 +303,7 @@ dependencies = [ [[package]] name = "cypher-rs" version = "0.1.0" -source = "git+https://github.com/sonesuke/cypher-rs#1908b41baa2b0ab18e3f6a63b37989210fb14c03" +source = "git+https://github.com/sonesuke/cypher-rs#0f8d18798a195aaef63eae4787311b6a6c1652a3" dependencies = [ "anyhow", "async-trait", diff --git a/claude-plugin/skills/patent-fetch/SKILL.md b/claude-plugin/skills/patent-fetch/SKILL.md index d8dbe8f..7f4c065 100644 --- a/claude-plugin/skills/patent-fetch/SKILL.md +++ b/claude-plugin/skills/patent-fetch/SKILL.md @@ -48,12 +48,12 @@ MATCH (p:Patent) RETURN p.title, p.abstract_text |--------------|------------------| | Assignee, owner, applicant | `p.assignee` | | Legal status, status, expired/active | `p.legal_status` | -| Claims, what is claimed | `p.claims` | +| Claims, what is claimed | `MATCH (p:Patent)-[:claims]->(c:claims) RETURN c.number, c.text` | | Description, details, specification | `p.description` | | Filing date, application date | `p.filing_date` | | Publication date | `p.publication_date` | | Priority date | `p.priority_date` | -| Everything, full details | `p.title, p.abstract_text, p.description, p.assignee, p.filing_date, p.publication_date, p.priority_date, p.legal_status, p.claims` | +| Everything, full details | `p.title, p.abstract_text, p.description, p.assignee, p.filing_date, p.publication_date, p.priority_date, p.legal_status` (claims: use relationship query) | **Example queries based on user request:** @@ -67,7 +67,10 @@ User: "What's the legal status of US9152718B2?" → Include legal_status: `MATCH (p:Patent) RETURN p.title, p.legal_status` User: "Get full details for US9152718B2" -→ Include everything: `MATCH (p:Patent) RETURN p.title, p.abstract_text, p.description, p.assignee, p.filing_date, p.publication_date, p.priority_date, p.legal_status, p.claims` +→ Include everything: `MATCH (p:Patent) RETURN p.title, p.abstract_text, p.description, p.assignee, p.filing_date, p.publication_date, p.priority_date, p.legal_status` + +User: "What are the claims for US9152718B2?" +→ Use relationship: `MATCH (p:Patent)-[:claims]->(c:claims) RETURN c.number, c.text ORDER BY c.number` ## Important Notes @@ -75,6 +78,25 @@ User: "Get full details for US9152718B2" - **Always use `execute_cypher` to access patent data** - do not use the Read tool on the output_file - The dataset is automatically loaded into memory for efficient querying +## Graph Structure + +Patent data is loaded as a graph with the following structure: + +- **Patent node** (`:Patent`) - Main patent with id, title, abstract_text, etc. +- **Array fields become relationships**: + - `(:Patent)-[:claims]->(:claims)` - Claim nodes with number, text + - `(:Patent)-[:description_paragraphs]->(:description_paragraphs)` - Description nodes + - `(:Patent)-[:images]->(:images)` - Image nodes + +**Accessing claims via relationship:** +```cypher +# Get all claim numbers and texts +MATCH (p:Patent)-[:claims]->(c:claims) RETURN c.number, c.text + +# Get claims for a specific patent +MATCH (p:Patent)-[:claims]->(c:claims) WHERE p.id = 'US9152718B2' RETURN c.number, c.text ORDER BY c.number +``` + ## Parameters - `patent_id` (string, required): Patent ID (e.g., "US9152718B2", "JP2023-123456-A") diff --git a/src/mcp/mod.rs b/src/mcp/mod.rs index f96cc4e..a28144a 100644 --- a/src/mcp/mod.rs +++ b/src/mcp/mod.rs @@ -234,7 +234,7 @@ impl PatentHandler { ) -> Option { // Try to create engine from the provided JSON let engine_result = if let Some(label) = root_label { - CypherEngine::from_json_auto_as_root_with_label(json, label) + CypherEngine::from_json_with_label(json, label) } else { CypherEngine::from_json_auto(json) };