Skip to content

Commit 2773bc4

Browse files
authored
Data modeling add guidance prompt (#141)
* add create new data model prompt tested with Claude Desktop * update readme and changelog
1 parent deba7fe commit 2773bc4

File tree

3 files changed

+77
-1
lines changed

3 files changed

+77
-1
lines changed

servers/mcp-neo4j-data-modeling/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Changed
66

77
### Added
8+
* Add `create_new_data_model` prompt that provides a structured prompt for generating a graph data model
89

910
## v0.3.0
1011

servers/mcp-neo4j-data-modeling/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,17 @@ These tools may be used to create Cypher ingest queries based on the data model.
152152
- `relationship_end_node_label` (str): The label of the end node
153153
- Returns: Parameterized Cypher query for bulk relationship ingestion (using `$records`)
154154

155+
### 💡 Prompts
156+
157+
- `create_new_data_model`
158+
- Provide a structured parameterized prompt for generating a new graph data model
159+
- Input:
160+
- `data_context` (str): Description of the data and any specific details to focus on
161+
- `use_cases` (str): List of use cases for the data model to address
162+
- `desired_nodes` (str, optional): Node labels to include in the data model
163+
- `desired_relationships` (str, optional): Relationship types to include in the data model
164+
- Returns: Structured prompt that guides the agent through a 3-step process: analysis of sample data and examples, generation of the data model with validation, and presentation of results with visualization
165+
155166
## 🔧 Usage with Claude Desktop
156167

157168
### 💾 Released Package

servers/mcp-neo4j-data-modeling/src/mcp_neo4j_data_modeling/server.py

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import json
22
import logging
3-
from typing import Any, Literal
3+
from typing import Any, Literal, Optional
44

55
from fastmcp.server import FastMCP
66
from pydantic import Field, ValidationError
@@ -322,6 +322,70 @@ def list_example_data_models() -> dict[str, Any]:
322322
"total_examples": len(examples),
323323
"usage": "Use the get_example_data_model tool with any of the example names above to get a specific data model",
324324
}
325+
326+
@mcp.prompt(title="Create New Data Model")
327+
def create_new_data_model(data_context: str = Field(..., description="A description of the data and any specific details the agent should focus on."),
328+
use_cases: str = Field(..., description="A list of use cases for the data model to address."),
329+
desired_nodes: str = "",
330+
desired_relationships: str = ""
331+
) -> str:
332+
"""
333+
Guide the agent in creating a new graph data model.
334+
You should provide the sample data alongside this prompt.
335+
Be as descriptive as possible when providing data context and use cases. These will be used to effectively shape your data model.
336+
If you have an idea of what your data model should look like, you may optionally provide desired nodes and relationships.
337+
338+
Parameters:
339+
* data_context: A description of the data and any specific details the agent should focus on.
340+
* use_cases: A list of use cases for the data model to address.
341+
* desired_nodes (optional): A list of node labels that you would like to be included in the data model.
342+
* desired_relationships (optional): A list of relationship types that you would like to be included in the data model.
343+
"""
344+
345+
prompt = f"""Please use the following context and the provided sample data to generate a new graph data model.
346+
347+
Here is the data context:
348+
{data_context}
349+
350+
Here are the use cases:
351+
{use_cases}
352+
"""
353+
354+
if desired_nodes:
355+
prompt += f"""
356+
Here are the desired nodes:
357+
{desired_nodes}
358+
"""
359+
360+
if desired_relationships:
361+
prompt += f"""
362+
Here are the desired relationships:
363+
{desired_relationships}
364+
"""
365+
366+
prompt += """
367+
Additional Instructions:
368+
* Ensure that if you know the source information for Properties, you include it in the data model.
369+
* If you deviate from the user's requests, you must clearly explain why you did so.
370+
* Only use data from the provided sample data to create the data model (Unless explicitly stated otherwise).
371+
* If the user requests use cases that are outside the scope of the provided sample data, you should explain why you cannot create a data model for those use cases.
372+
373+
Process:
374+
1. Analysis
375+
1a. Analyze the sample data
376+
1b. Use the `list_example_data_models` tool to check if there are any relevant examples that you can use to guide your data model
377+
1c. Use the `get_example_data_model` tool to get any relevant example data models
378+
2. Generation
379+
2a. Generate a new data model based on your analysis, the provided context and any examples
380+
2b. Use the `get_mermaid_config_str` tool to validate the data model and get a Mermaid visualization configuration
381+
2c. If necessary, correct any validation errors and repeat step 2b
382+
3. Final Response
383+
3a. Show the user the visualization with Mermaid, if possible
384+
3b. Explain the data model and any gaps between the requested use cases
385+
3c. Request feedback from the user (remember that data modeling is an iterative process)
386+
"""
387+
388+
return prompt
325389

326390
return mcp
327391

0 commit comments

Comments
 (0)