adbpg-mcp-server 1.0.7__tar.gz → 1.0.8__tar.gz

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.
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: adbpg-mcp-server
3
- Version: 1.0.7
4
- Summary: MCP server for AnalyticDB PostgreSQL
3
+ Version: 1.0.8
4
+ Summary: MCP Server for AnalyticDB PostgreSQL
5
5
  License-File: LICENSE
6
6
  Requires-Python: >=3.10
7
7
  Requires-Dist: mcp>=1.4.0
@@ -43,7 +43,8 @@ Add the following configuration to the MCP client configuration file:
43
43
  "LLMEMORY_API_KEY": "llm memory api_key",
44
44
  "LLMEMORY_BASE_URL": "llm memory base_url",
45
45
  "LLMEMORY_LLM_MODEL": "llm memory model name",
46
- "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
46
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
47
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
47
48
  }
48
49
  }
49
50
  }
@@ -78,6 +79,7 @@ pip install adbpg_mcp_server
78
79
  "LLMEMORY_BASE_URL": "llm memory base_url",
79
80
  "LLMEMORY_LLM_MODEL": "llm memory model name",
80
81
  "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
82
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
81
83
  }
82
84
  }
83
85
  }
@@ -206,6 +208,7 @@ MCP Server requires the following environment variables to initialize graphRAG a
206
208
  - `LLMEMORY_BASE_URL`: Base URL for LLM or embedding service endpoint
207
209
  - `LLMEMORY_LLM_MODEL`: LLM model name or identifier
208
210
  - `LLMEMORY_EMBEDDING_MODEL`: Embedding model name or identifier
211
+ - `LLMEMORY_ENABLE_GRAPH`: (Optional) Enable graph engine for llm memory (Default: false)
209
212
 
210
213
  ## Dependencies
211
214
 
@@ -70,7 +70,7 @@ except Exception as e:
70
70
  logger.error(f"Error loading environment variables: {e}")
71
71
  sys.exit(1)
72
72
 
73
- SERVER_VERSION = "0.1.0"
73
+ SERVER_VERSION = "0.2.0"
74
74
 
75
75
 
76
76
  # 获得 graphrag 初始化配置
@@ -91,6 +91,22 @@ def get_graphrag_config():
91
91
 
92
92
  # 获得llmemory 初始化配置
93
93
  def get_llmemory_config():
94
+ config = get_db_config()
95
+ port = 3000
96
+ sql = """
97
+ select port from gp_segment_configuration where content = -1 and role = 'p';
98
+ """
99
+ try:
100
+ with psycopg.connect(**config) as conn:
101
+ conn.autocommit = True
102
+ with conn.cursor() as cursor:
103
+ cursor.execute(sql)
104
+ port = cursor.fetchone()[0]
105
+ except Error as e:
106
+ raise RuntimeError(f"Database error: {str(e)}")
107
+ llmemory_enable_graph = os.getenv("LLMEMORY_ENABLE_GRAPH", "False")
108
+
109
+
94
110
  llm_memory_config = {
95
111
  "llm": {
96
112
  "provider": "openai",
@@ -116,10 +132,22 @@ def get_llmemory_config():
116
132
  "password": os.getenv("ADBPG_PASSWORD"),
117
133
  "dbname": os.getenv("ADBPG_DATABASE"),
118
134
  "hnsw": "True",
119
- "embedding_model_dims": os.getenv("LLMEMORY_EMBEDDING_DIMS", 1024)
135
+ "embedding_model_dims": os.getenv("LLMEMORY_EMBEDDING_DIMS", 1024),
136
+ "port": port
120
137
  }
121
138
  }
122
139
  }
140
+ if llmemory_enable_graph == "True" or llmemory_enable_graph == "true":
141
+ llm_memory_config["graph_store"] = {
142
+ "provider": "adbpg",
143
+ "config": {
144
+ "url": "http://localhost",
145
+ "username": os.getenv("ADBPG_USER"),
146
+ "password": os.getenv("ADBPG_PASSWORD"),
147
+ "database": os.getenv("ADBPG_DATABASE"),
148
+ "port": port
149
+ }
150
+ }
123
151
  return llm_memory_config
124
152
 
125
153
  def get_db_config():
@@ -870,14 +898,18 @@ async def call_tool(name: str, arguments: dict) -> list[TextContent]:
870
898
  if not query_mode:
871
899
  # default mode
872
900
  query_mode = "mix"
873
- if not start_search_node_id:
874
- start_search_node_id = None
875
-
876
- # 命令拼接
901
+
877
902
  wrapped_sql = f"""
878
- SELECT adbpg_graphrag.query(%s::text, %s::text, %s::text)
879
- """
880
- params = [query_str, query_mode, start_search_node_id]
903
+ SELECT adbpg_graphrag.query(%s::text, %s::text)
904
+ """
905
+ params = [query_str, query_mode]
906
+
907
+ if start_search_node_id:
908
+ wrapped_sql = f"""
909
+ SELECT adbpg_graphrag.query(%s::text, %s::text, %s::text)
910
+ """
911
+ params = [query_str, query_mode, start_search_node_id]
912
+
881
913
  return get_graphrag_tool_result(wrapped_sql, params)
882
914
 
883
915
  elif name == "adbpg_graphrag_reset_tree_query":
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "adbpg-mcp-server"
7
- version = "1.0.7"
8
- description = "MCP server for AnalyticDB PostgreSQL"
7
+ version = "1.0.8"
8
+ description = "MCP Server for AnalyticDB PostgreSQL"
9
9
  requires-python = ">=3.10"
10
10
  dependencies = [
11
11
  "mcp>=1.4.0",