adbpg-mcp-server 1.0.6__py3-none-any.whl → 1.0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {adbpg_mcp_server-1.0.6.dist-info → adbpg_mcp_server-1.0.7.dist-info}/METADATA +1 -1
- adbpg_mcp_server-1.0.7.dist-info/RECORD +6 -0
- adbpg_mcp_server.py +63 -30
- adbpg_mcp_server-1.0.6.dist-info/RECORD +0 -6
- {adbpg_mcp_server-1.0.6.dist-info → adbpg_mcp_server-1.0.7.dist-info}/WHEEL +0 -0
- {adbpg_mcp_server-1.0.6.dist-info → adbpg_mcp_server-1.0.7.dist-info}/entry_points.txt +0 -0
- {adbpg_mcp_server-1.0.6.dist-info → adbpg_mcp_server-1.0.7.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
adbpg_mcp_server.py,sha256=g4iiTd2iq9GNzvrZFzeN19Gl06mGOFVahdExeUd5PUQ,44038
|
2
|
+
adbpg_mcp_server-1.0.7.dist-info/METADATA,sha256=YwLjxYvfr9fov4Ts-mDkG-0JjtttJPZhgrlYlE-XZh0,275
|
3
|
+
adbpg_mcp_server-1.0.7.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
4
|
+
adbpg_mcp_server-1.0.7.dist-info/entry_points.txt,sha256=n2NpLR8WNfa3Edju2l7Ngnsp7EiCUqNdYkF0dg42dnQ,58
|
5
|
+
adbpg_mcp_server-1.0.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
6
|
+
adbpg_mcp_server-1.0.7.dist-info/RECORD,,
|
adbpg_mcp_server.py
CHANGED
@@ -84,7 +84,8 @@ def get_graphrag_config():
|
|
84
84
|
"embedding_url": os.getenv("GRAPHRAG_EMBEDDING_BASE_URL"),
|
85
85
|
"language": os.getenv("GRAPHRAG_LANGUAGE", "English"),
|
86
86
|
"entity_types": os.getenv("GRAPHRAG_ENTITY_TYPES"),
|
87
|
-
"relationship_types": os.getenv("GRAPHRAG_RELATIONSHIP_TYPES")
|
87
|
+
"relationship_types": os.getenv("GRAPHRAG_RELATIONSHIP_TYPES"),
|
88
|
+
"postgres_password": os.getenv("ADBPG_PASSWORD")
|
88
89
|
}
|
89
90
|
return graphrag_config
|
90
91
|
|
@@ -186,8 +187,8 @@ def get_graphrag_tool_connection() -> Connection:
|
|
186
187
|
|
187
188
|
LLM_MEMORY_CONN: Connection | None = None
|
188
189
|
def get_llm_memory_tool_connection() -> Connection:
|
189
|
-
global LLM_MEMORY_CONN
|
190
190
|
global LLMEMORY_ENV_IS_READY
|
191
|
+
global LLM_MEMORY_CONN
|
191
192
|
config = get_db_config()
|
192
193
|
# 如果未连接,或者连接失效 重新连接
|
193
194
|
if LLM_MEMORY_CONN is None or LLM_MEMORY_CONN.closed:
|
@@ -507,7 +508,7 @@ async def list_tools() -> list[Tool]:
|
|
507
508
|
#### graphrag & llm_memory tool list
|
508
509
|
Tool(
|
509
510
|
name = "adbpg_graphrag_upload",
|
510
|
-
description = "
|
511
|
+
description = "Execute graphrag upload operation",
|
511
512
|
# 参数:filename text, context text
|
512
513
|
# filename 表示文件名称, context 表示文件内容
|
513
514
|
inputSchema = {
|
@@ -515,11 +516,11 @@ async def list_tools() -> list[Tool]:
|
|
515
516
|
"properties": {
|
516
517
|
"filename": {
|
517
518
|
"type": "string",
|
518
|
-
"description": "The name
|
519
|
+
"description": "The file name need to upload"
|
519
520
|
},
|
520
521
|
"context": {
|
521
522
|
"type": "string",
|
522
|
-
"description": "
|
523
|
+
"description": "the context of your file"
|
523
524
|
}
|
524
525
|
},
|
525
526
|
"required": ["filename", "context"]
|
@@ -527,7 +528,7 @@ async def list_tools() -> list[Tool]:
|
|
527
528
|
),
|
528
529
|
Tool(
|
529
530
|
name = "adbpg_graphrag_query",
|
530
|
-
description = "
|
531
|
+
description = "Execute graphrag query operation",
|
531
532
|
# 参数:query_str text, [query_mode text]
|
532
533
|
# query_str 是询问的问题,query_mode 选择查询模式
|
533
534
|
inputSchema = {
|
@@ -535,11 +536,15 @@ async def list_tools() -> list[Tool]:
|
|
535
536
|
"properties": {
|
536
537
|
"query_str": {
|
537
538
|
"type": "string",
|
538
|
-
"description": "The query
|
539
|
+
"description": "The query you want to ask"
|
539
540
|
},
|
540
541
|
"query_mode": {
|
541
542
|
"type": "string",
|
542
|
-
"description": "The query mode
|
543
|
+
"description": "The query mode you need to choose [ bypass,naive, local, global, hybrid, mix[default], tree ]."
|
544
|
+
},
|
545
|
+
"start_search_node_id": {
|
546
|
+
"type": "string",
|
547
|
+
"description": "If using 'tree' query mode, set the start node ID of tree."
|
543
548
|
}
|
544
549
|
},
|
545
550
|
"required": ["query_str"]
|
@@ -593,24 +598,40 @@ async def list_tools() -> list[Tool]:
|
|
593
598
|
"root_node_entity": {
|
594
599
|
"type": "string",
|
595
600
|
"description": "the root_noot_entity"
|
601
|
+
|
596
602
|
}
|
597
603
|
},
|
598
604
|
"required": ["root_node_entity"]
|
599
605
|
}
|
600
606
|
),
|
601
|
-
|
602
|
-
|
607
|
+
Tool(
|
608
|
+
name = "adbpg_graphrag_reset_tree_query",
|
609
|
+
description = " Reset the decision tree in the tree query mode",
|
610
|
+
# para:
|
611
|
+
inputSchema = {
|
612
|
+
"type": "object",
|
613
|
+
"required": []
|
614
|
+
}
|
615
|
+
),
|
603
616
|
Tool(
|
604
617
|
name = "adbpg_llm_memory_add",
|
605
|
-
description = "
|
618
|
+
description = "Execute llm_memory add operation",
|
606
619
|
# 参数:messages json, user_id text, run_id text, agent_id text, metadata json
|
607
620
|
# 增加新的记忆
|
608
621
|
inputSchema={
|
609
622
|
"type": "object",
|
610
623
|
"properties": {
|
611
624
|
"messages": {
|
612
|
-
"type": "
|
613
|
-
"
|
625
|
+
"type": "array",
|
626
|
+
"items": {
|
627
|
+
"type": "object",
|
628
|
+
"properties": {
|
629
|
+
"role": {"type": "string"},
|
630
|
+
"content": {"type": "string"}
|
631
|
+
},
|
632
|
+
"required": ["role", "content"]
|
633
|
+
},
|
634
|
+
"description": "List of messages objects (e.g., conversation history)"
|
614
635
|
},
|
615
636
|
"user_id": {
|
616
637
|
"type": "string",
|
@@ -642,7 +663,7 @@ async def list_tools() -> list[Tool]:
|
|
642
663
|
),
|
643
664
|
Tool(
|
644
665
|
name = "adbpg_llm_memory_get_all",
|
645
|
-
description = "
|
666
|
+
description = "Execute llm_memory get_all operation",
|
646
667
|
# 参数:user_id text, run_id text, agent_id text
|
647
668
|
# 获取某个用户或者某个agent的所有记忆
|
648
669
|
inputSchema={
|
@@ -666,7 +687,7 @@ async def list_tools() -> list[Tool]:
|
|
666
687
|
),
|
667
688
|
Tool(
|
668
689
|
name = "adbpg_llm_memory_search",
|
669
|
-
description = "
|
690
|
+
description = "Execute llm_memory search operation",
|
670
691
|
# 参数:query text, user_id text, run_id text, agent_id text, filter json
|
671
692
|
# 获取与给定 query 相关的记忆
|
672
693
|
inputSchema={
|
@@ -699,7 +720,7 @@ async def list_tools() -> list[Tool]:
|
|
699
720
|
,
|
700
721
|
Tool(
|
701
722
|
name = "adbpg_llm_memory_delete_all",
|
702
|
-
description = "
|
723
|
+
description = "Execute llm_memory delete_all operation",
|
703
724
|
# 参数:user_id text, run_id text, agent_id text
|
704
725
|
# 删除某个用户或者agent的所有记忆
|
705
726
|
inputSchema={
|
@@ -741,6 +762,7 @@ def get_llm_memory_tool_result(wrapped_sql, params) -> list[TextContent]:
|
|
741
762
|
try:
|
742
763
|
conn = get_llm_memory_tool_connection()
|
743
764
|
with conn.cursor() as cursor:
|
765
|
+
|
744
766
|
cursor.execute(wrapped_sql, params)
|
745
767
|
|
746
768
|
if cursor.description:
|
@@ -788,6 +810,11 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
788
810
|
raise ValueError("Query is required")
|
789
811
|
if not query.strip().upper().startswith("SELECT"):
|
790
812
|
raise ValueError("Query must be a SELECT statement")
|
813
|
+
query = query.rstrip().rstrip(';')
|
814
|
+
query = f"""
|
815
|
+
SELECT json_agg(row_to_json(t))
|
816
|
+
FROM ({query}) AS t
|
817
|
+
"""
|
791
818
|
elif name == "execute_dml_sql":
|
792
819
|
query = arguments.get("query")
|
793
820
|
if not query:
|
@@ -798,7 +825,7 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
798
825
|
query = arguments.get("query")
|
799
826
|
if not query:
|
800
827
|
raise ValueError("Query is required")
|
801
|
-
if not any(query.strip().upper().startswith(keyword) for keyword in ["CREATE", "ALTER", "DROP"]):
|
828
|
+
if not any(query.strip().upper().startswith(keyword) for keyword in ["CREATE", "ALTER", "DROP", "TRUNCATE"]):
|
802
829
|
raise ValueError("Query must be a DDL statement (CREATE, ALTER, DROP)")
|
803
830
|
elif name == "analyze_table":
|
804
831
|
schema = arguments.get("schema")
|
@@ -836,18 +863,32 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
836
863
|
raise ValueError("GraphRAG Server initialization failed. This tool cannot be used.")
|
837
864
|
query_str = arguments.get("query_str")
|
838
865
|
query_mode = arguments.get("query_mode")
|
866
|
+
start_search_node_id = arguments.get("start_search_node_id")
|
867
|
+
|
839
868
|
if not query_str:
|
840
869
|
raise ValueError("Query is required")
|
841
870
|
if not query_mode:
|
842
871
|
# default mode
|
843
872
|
query_mode = "mix"
|
873
|
+
if not start_search_node_id:
|
874
|
+
start_search_node_id = None
|
875
|
+
|
844
876
|
# 命令拼接
|
845
877
|
wrapped_sql = f"""
|
846
|
-
SELECT adbpg_graphrag.query(%s::text, %s::text)
|
878
|
+
SELECT adbpg_graphrag.query(%s::text, %s::text, %s::text)
|
847
879
|
"""
|
848
|
-
params = [query_str, query_mode]
|
880
|
+
params = [query_str, query_mode, start_search_node_id]
|
849
881
|
return get_graphrag_tool_result(wrapped_sql, params)
|
850
|
-
|
882
|
+
|
883
|
+
elif name == "adbpg_graphrag_reset_tree_query":
|
884
|
+
if GRAPHRAG_ENV_IS_READY == False:
|
885
|
+
raise ValueError("GraphRAG Server initialization failed. This tool cannot be used.")
|
886
|
+
wrapped_sql = f"""
|
887
|
+
SELECT adbpg_graphrag.reset_tree_query()
|
888
|
+
"""
|
889
|
+
params = []
|
890
|
+
return get_graphrag_tool_result(wrapped_sql, params)
|
891
|
+
|
851
892
|
elif name == "adbpg_graphrag_upload_decision_tree":
|
852
893
|
if GRAPHRAG_ENV_IS_READY == False:
|
853
894
|
raise ValueError("GraphRAG Server initialization failed. This tool cannot be used.")
|
@@ -1040,15 +1081,8 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
1040
1081
|
conn.autocommit = True
|
1041
1082
|
with conn.cursor() as cursor:
|
1042
1083
|
|
1043
|
-
|
1044
|
-
|
1045
|
-
query = query.rstrip().rstrip(';')
|
1046
|
-
wrapped_query = f"""
|
1047
|
-
SELECT json_agg(row_to_json(t))
|
1048
|
-
FROM ({query}) AS t
|
1049
|
-
"""
|
1050
|
-
cursor.execute(wrapped_query)
|
1051
|
-
|
1084
|
+
cursor.execute(query)
|
1085
|
+
|
1052
1086
|
if name == "analyze_table":
|
1053
1087
|
return [TextContent(type="text", text=f"Successfully analyzed table {schema}.{table}")]
|
1054
1088
|
|
@@ -1057,7 +1091,6 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
|
|
1057
1091
|
json_result = cursor.fetchone()[0]
|
1058
1092
|
json_str = json.dumps(json_result, ensure_ascii = False, indent = 2)
|
1059
1093
|
result = [TextContent(type="text", text=json_str)]
|
1060
|
-
|
1061
1094
|
try:
|
1062
1095
|
json.loads(result[0].text)
|
1063
1096
|
except json.JSONDecodeError as e:
|
@@ -1,6 +0,0 @@
|
|
1
|
-
adbpg_mcp_server.py,sha256=dFuiaubyCP0_KJddz2mTxzDTxQmOCGCrinGqi8DxG6I,42882
|
2
|
-
adbpg_mcp_server-1.0.6.dist-info/METADATA,sha256=lgLvhiuNHXR8oUeH_igvQsqOodrwiyGO9JbSXPnBxBc,275
|
3
|
-
adbpg_mcp_server-1.0.6.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
4
|
-
adbpg_mcp_server-1.0.6.dist-info/entry_points.txt,sha256=n2NpLR8WNfa3Edju2l7Ngnsp7EiCUqNdYkF0dg42dnQ,58
|
5
|
-
adbpg_mcp_server-1.0.6.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
6
|
-
adbpg_mcp_server-1.0.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|