Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
1. Support projecting specific relationship types for heterogeneous graphs.

### Bug Fixes
1. Fix bug where get_relationship_properties, get_node_properties, and get_node_labels might not returning entire answer set
1. Fix a bug where get_relationship_properties, get_node_properties, and get_node_labels might not returning entire answer set.
2. Fix a bug in the signature of nested arrays for article_rank, eigenvector_centrality, pagerank and k_nearest_neighbour that certain LLM clients do not support.

### Other Changes

68 changes: 10 additions & 58 deletions mcp_server/src/mcp_server_neo4j_gds/centrality_algorithm_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,9 @@
"description": "Property of the relationship to use for weighting. If not specified, all relationships are treated equally.",
},
"sourceNodes": {
"description": "The nodes or node-bias pairs to use for computing Personalized Article Rank. To use different bias for different source nodes, use the syntax: [[node1, bias1], [node2, bias2], ...]",
"anyOf": [
{"type": "string", "description": "Single node"},
{
"type": "array",
"items": {"type": "string"},
"description": "List of nodes",
},
{
"type": "array",
"items": {
"type": "array",
"prefixItems": [{"type": "string"}, {"type": "number"}],
"minItems": 2,
"maxItems": 2,
},
"description": "List of [node, bias] pairs",
},
],
"description": "The nodes to use for computing Personalized Article Rank.",
"type": "array",
"items": {"type": "string"},
},
"scaler": {
"type": "string",
Expand Down Expand Up @@ -249,7 +233,7 @@
"nodeLabels": {
"type": "array",
"items": {"type": "string"},
"description": "The node labels used to project and run Degree Centrality on. Nodes with different node labels will be ignored. Do not specify to run for all nodes",
"description": "The node labels used to project and run Degree Centrality on. This is used to filter the graph to run the algorithm on. Nodes with other node labels will be hidden and ignored. Include all node labels for nodes that you want to run the algorithm on.",
},
"relTypes": {
"type": "array",
Expand Down Expand Up @@ -314,25 +298,9 @@
"description": "Property of the relationship to use for weighting. If not specified, all relationships are treated equally.",
},
"sourceNodes": {
"description": "The nodes or node-bias pairs to use for computing Personalized Eigenvector Centrality. To use different bias for different source nodes, use the syntax: [[node1, bias1], [node2, bias2], ...]",
"anyOf": [
{"type": "string", "description": "Single node"},
{
"type": "array",
"items": {"type": "string"},
"description": "List of nodes",
},
{
"type": "array",
"items": {
"type": "array",
"prefixItems": [{"type": "string"}, {"type": "number"}],
"minItems": 2,
"maxItems": 2,
},
"description": "List of [node, bias] pairs",
},
],
"description": "The nodes to use for computing Personalized Eigenvector Centrality.",
"type": "array",
"items": {"type": "string"},
},
"scaler": {
"type": "string",
Expand Down Expand Up @@ -381,25 +349,9 @@
"description": "Minimum change in scores between iterations. If all scores change less than the tolerance value the result is considered stable and the algorithm returns.",
},
"sourceNodes": {
"description": "The nodes or node-bias pairs to use for computing Personalized PageRank. To use different bias for different source nodes, use the syntax: [[node1, bias1], [node2, bias2], ...]",
"anyOf": [
{"type": "string", "description": "Single node"},
{
"type": "array",
"items": {"type": "string"},
"description": "List of nodes",
},
{
"type": "array",
"items": {
"type": "array",
"prefixItems": [{"type": "string"}, {"type": "number"}],
"minItems": 2,
"maxItems": 2,
},
"description": "List of [node, bias] pairs",
},
],
"description": "The nodes to use for computing Personalized PageRank.",
"type": "array",
"items": {"type": "string"},
},
},
"required": [],
Expand Down
52 changes: 42 additions & 10 deletions mcp_server/src/mcp_server_neo4j_gds/similarity_algorithm_specs.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,28 @@
"type": "object",
"properties": {
"sourceNodeFilter": {
"type": ["integer", "array", "string"],
"description": "The source node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
"anyOf": [
{
"type": "array",
"items": {"type": "string"},
},
{
"type": "string",
},
],
"description": "The source node filter to apply. Accepts a List of node names, or a single label.",
},
"targetNodeFilter": {
"type": ["integer", "array", "string"],
"description": "The target node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
"anyOf": [
{
"type": "array",
"items": {"type": "string"},
},
{
"type": "string",
},
],
"description": "The target node filter to apply. Accepts a List of node names, or a single label.",
},
"similarityCutoff": {
"type": "number",
Expand Down Expand Up @@ -103,16 +119,32 @@
"type": "object",
"properties": {
"sourceNodeFilter": {
"type": ["integer", "array", "string"],
"description": "The source node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
"anyOf": [
{
"type": "array",
"items": {"type": "string"},
},
{
"type": "string",
},
],
"description": "The source node filter to apply. Accepts a List of node names, or a single label.",
},
"targetNodeFilter": {
"type": ["integer", "array", "string"],
"description": "The target node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
"anyOf": [
{
"type": "array",
"items": {"type": "string"},
},
{
"type": "string",
},
],
"description": "The target node filter to apply. Accepts a List of node names, or a single label.",
},
"nodeProperties": {
"type": ["string", "object", "array"],
"description": "The node properties to use for similarity computation along with their selected similarity metrics. Accepts a single property key, a Map of property keys to metrics, or a List of property keys and/or Maps, as above.",
"type": "object",
"description": "The node properties to use for similarity computation along with their selected similarity metrics. Accepts a Map of property keys to metrics. For example: {embedding: 'COSINE',age: 'DEFAULT',lotteryNumbers: 'OVERLAP'}. DEFAULT refers to COSINE.",
},
"topK": {
"type": "integer",
Expand Down
8 changes: 4 additions & 4 deletions mcp_server/tests/test_similarity_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def test_k_nearest_neighbors(mcp_client):
{
"nodeIdentifierProperty": "name",
"topK": 3,
"nodeProperties": "rail",
"nodeProperties": {"rail": "DEFAULT"},
"relTypes": ["LINK"],
"nodeLabels": ["UndergroundStation"],
},
Expand Down Expand Up @@ -140,7 +140,7 @@ async def test_filtered_knn(mcp_client):
"nodeIdentifierProperty": "name",
"topK": 3,
"sourceNodeFilter": ["Acton Town"],
"nodeProperties": "rail",
"nodeProperties": {"rail": "DEFAULT"},
},
)

Expand All @@ -165,7 +165,7 @@ async def test_filtered_knn(mcp_client):
"nodeIdentifierProperty": "name",
"topK": 3,
"targetNodeFilter": "Stamford Brook",
"nodeProperties": "rail",
"nodeProperties": {"rail": "DEFAULT"},
},
)
assert len(result) == 1
Expand All @@ -190,7 +190,7 @@ async def test_filtered_knn(mcp_client):
"sourceNodeFilter": ["Acton Town"],
"targetNodeFilter": ["Stamford Brook"],
"seedTargetNodes": True, # k-nn filtering is a bit special, it might not necessarily find answer if this is not specified (at least for this small example graph)
"nodeProperties": "rail",
"nodeProperties": {"rail": "DEFAULT"},
},
)

Expand Down