Skip to content

Commit ddc6d1f

Browse files
authored
Merge pull request #35 from brs96/fix-api-for-some-clients
Fix nested json
2 parents 3c903ec + a43b9d8 commit ddc6d1f

File tree

4 files changed

+58
-73
lines changed

4 files changed

+58
-73
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
1. Support projecting specific relationship types for heterogeneous graphs.
55

66
### Bug Fixes
7-
1. Fix bug where get_relationship_properties, get_node_properties, and get_node_labels might not returning entire answer set
7+
1. Fix a bug where get_relationship_properties, get_node_properties, and get_node_labels might not returning entire answer set.
8+
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.
89

910
### Other Changes
1011

mcp_server/src/mcp_server_neo4j_gds/centrality_algorithm_specs.py

Lines changed: 10 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,9 @@
3434
"description": "Property of the relationship to use for weighting. If not specified, all relationships are treated equally.",
3535
},
3636
"sourceNodes": {
37-
"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], ...]",
38-
"anyOf": [
39-
{"type": "string", "description": "Single node"},
40-
{
41-
"type": "array",
42-
"items": {"type": "string"},
43-
"description": "List of nodes",
44-
},
45-
{
46-
"type": "array",
47-
"items": {
48-
"type": "array",
49-
"prefixItems": [{"type": "string"}, {"type": "number"}],
50-
"minItems": 2,
51-
"maxItems": 2,
52-
},
53-
"description": "List of [node, bias] pairs",
54-
},
55-
],
37+
"description": "The nodes to use for computing Personalized Article Rank.",
38+
"type": "array",
39+
"items": {"type": "string"},
5640
},
5741
"scaler": {
5842
"type": "string",
@@ -249,7 +233,7 @@
249233
"nodeLabels": {
250234
"type": "array",
251235
"items": {"type": "string"},
252-
"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",
236+
"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.",
253237
},
254238
"relTypes": {
255239
"type": "array",
@@ -314,25 +298,9 @@
314298
"description": "Property of the relationship to use for weighting. If not specified, all relationships are treated equally.",
315299
},
316300
"sourceNodes": {
317-
"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], ...]",
318-
"anyOf": [
319-
{"type": "string", "description": "Single node"},
320-
{
321-
"type": "array",
322-
"items": {"type": "string"},
323-
"description": "List of nodes",
324-
},
325-
{
326-
"type": "array",
327-
"items": {
328-
"type": "array",
329-
"prefixItems": [{"type": "string"}, {"type": "number"}],
330-
"minItems": 2,
331-
"maxItems": 2,
332-
},
333-
"description": "List of [node, bias] pairs",
334-
},
335-
],
301+
"description": "The nodes to use for computing Personalized Eigenvector Centrality.",
302+
"type": "array",
303+
"items": {"type": "string"},
336304
},
337305
"scaler": {
338306
"type": "string",
@@ -381,25 +349,9 @@
381349
"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.",
382350
},
383351
"sourceNodes": {
384-
"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], ...]",
385-
"anyOf": [
386-
{"type": "string", "description": "Single node"},
387-
{
388-
"type": "array",
389-
"items": {"type": "string"},
390-
"description": "List of nodes",
391-
},
392-
{
393-
"type": "array",
394-
"items": {
395-
"type": "array",
396-
"prefixItems": [{"type": "string"}, {"type": "number"}],
397-
"minItems": 2,
398-
"maxItems": 2,
399-
},
400-
"description": "List of [node, bias] pairs",
401-
},
402-
],
352+
"description": "The nodes to use for computing Personalized PageRank.",
353+
"type": "array",
354+
"items": {"type": "string"},
403355
},
404356
},
405357
"required": [],

mcp_server/src/mcp_server_neo4j_gds/similarity_algorithm_specs.py

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,28 @@
1212
"type": "object",
1313
"properties": {
1414
"sourceNodeFilter": {
15-
"type": ["integer", "array", "string"],
16-
"description": "The source node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
15+
"anyOf": [
16+
{
17+
"type": "array",
18+
"items": {"type": "string"},
19+
},
20+
{
21+
"type": "string",
22+
},
23+
],
24+
"description": "The source node filter to apply. Accepts a List of node names, or a single label.",
1725
},
1826
"targetNodeFilter": {
19-
"type": ["integer", "array", "string"],
20-
"description": "The target node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
27+
"anyOf": [
28+
{
29+
"type": "array",
30+
"items": {"type": "string"},
31+
},
32+
{
33+
"type": "string",
34+
},
35+
],
36+
"description": "The target node filter to apply. Accepts a List of node names, or a single label.",
2137
},
2238
"similarityCutoff": {
2339
"type": "number",
@@ -103,16 +119,32 @@
103119
"type": "object",
104120
"properties": {
105121
"sourceNodeFilter": {
106-
"type": ["integer", "array", "string"],
107-
"description": "The source node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
122+
"anyOf": [
123+
{
124+
"type": "array",
125+
"items": {"type": "string"},
126+
},
127+
{
128+
"type": "string",
129+
},
130+
],
131+
"description": "The source node filter to apply. Accepts a List of node names, or a single label.",
108132
},
109133
"targetNodeFilter": {
110-
"type": ["integer", "array", "string"],
111-
"description": "The target node filter to apply. Accepts a single node id, a List of node ids, or a single label.",
134+
"anyOf": [
135+
{
136+
"type": "array",
137+
"items": {"type": "string"},
138+
},
139+
{
140+
"type": "string",
141+
},
142+
],
143+
"description": "The target node filter to apply. Accepts a List of node names, or a single label.",
112144
},
113145
"nodeProperties": {
114-
"type": ["string", "object", "array"],
115-
"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.",
146+
"type": "object",
147+
"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.",
116148
},
117149
"topK": {
118150
"type": "integer",

mcp_server/tests/test_similarity_algorithms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ async def test_k_nearest_neighbors(mcp_client):
110110
{
111111
"nodeIdentifierProperty": "name",
112112
"topK": 3,
113-
"nodeProperties": "rail",
113+
"nodeProperties": {"rail": "DEFAULT"},
114114
"relTypes": ["LINK"],
115115
"nodeLabels": ["UndergroundStation"],
116116
},
@@ -140,7 +140,7 @@ async def test_filtered_knn(mcp_client):
140140
"nodeIdentifierProperty": "name",
141141
"topK": 3,
142142
"sourceNodeFilter": ["Acton Town"],
143-
"nodeProperties": "rail",
143+
"nodeProperties": {"rail": "DEFAULT"},
144144
},
145145
)
146146

@@ -165,7 +165,7 @@ async def test_filtered_knn(mcp_client):
165165
"nodeIdentifierProperty": "name",
166166
"topK": 3,
167167
"targetNodeFilter": "Stamford Brook",
168-
"nodeProperties": "rail",
168+
"nodeProperties": {"rail": "DEFAULT"},
169169
},
170170
)
171171
assert len(result) == 1
@@ -190,7 +190,7 @@ async def test_filtered_knn(mcp_client):
190190
"sourceNodeFilter": ["Acton Town"],
191191
"targetNodeFilter": ["Stamford Brook"],
192192
"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)
193-
"nodeProperties": "rail",
193+
"nodeProperties": {"rail": "DEFAULT"},
194194
},
195195
)
196196

0 commit comments

Comments
 (0)