adbpg-mcp-server 1.0.3__tar.gz → 1.0.5__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.
@@ -0,0 +1,260 @@
1
+ Metadata-Version: 2.4
2
+ Name: adbpg_mcp_server
3
+ Version: 1.0.5
4
+ Summary: ADBPG MCP Server
5
+ Home-page: https://github.com/aliyun/alibabacloud-adbpg-mcp-server
6
+ Author: Yutian Qiu
7
+ Author-email: qiuytian@gmail.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.10
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: psycopg>=3.1.0
15
+ Requires-Dist: psycopg-binary>=3.1.0
16
+ Requires-Dist: mcp>=1.4.0
17
+ Requires-Dist: pydantic>=2.0.0
18
+ Requires-Dist: python-dotenv>=1.0.0
19
+ Dynamic: author
20
+ Dynamic: author-email
21
+ Dynamic: classifier
22
+ Dynamic: description
23
+ Dynamic: description-content-type
24
+ Dynamic: home-page
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: requires-python
28
+ Dynamic: summary
29
+
30
+ # AnalyticDB PostgreSQL MCP Server
31
+
32
+ AnalyticDB PostgreSQL MCP Server serves as a universal interface between AI Agents and AnalyticDB PostgreSQL databases. It enables seamless communication between AI Agents and AnalyticDB PostgreSQL, helping AI Agents retrieve database metadata and execute SQL operations.
33
+
34
+ ## Configuration
35
+
36
+
37
+
38
+ ### Mode 1: Download
39
+
40
+ Download from Github
41
+
42
+ ```shell
43
+ git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
44
+ ```
45
+
46
+ #### MCP Integration
47
+
48
+ Add the following configuration to the MCP client configuration file:
49
+
50
+ ```json
51
+ "mcpServers": {
52
+ "adbpg-mcp-server": {
53
+ "command": "uv",
54
+ "args": [
55
+ "--directory",
56
+ "/path/to/adbpg-mcp-server",
57
+ "run",
58
+ "adbpg-mcp-server"
59
+ ],
60
+ "env": {
61
+ "ADBPG_HOST": "host",
62
+ "ADBPG_PORT": "port",
63
+ "ADBPG_USER": "username",
64
+ "ADBPG_PASSWORD": "password",
65
+ "ADBPG_DATABASE": "database",
66
+ "GRAPHRAG_API_KEY": "graphrag llm api key",
67
+ "GRAPHRAG_BASE_URL": "graphrag llm base url",
68
+ "GRAPHRAG_LLM_MODEL": "graphrag llm model name",
69
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
70
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
71
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
72
+ "LLMEMORY_API_KEY": "llm memory api_key",
73
+ "LLMEMORY_BASE_URL": "llm memory base_url",
74
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
75
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### Mode 2: Using pip
82
+
83
+ ```
84
+ pip install adbpg_mcp_server
85
+ ```
86
+ #### MCP Integration
87
+ ```json
88
+ "mcpServers": {
89
+ "adbpg-mcp-server": {
90
+ "command": "uvx",
91
+ "args": [
92
+ "adbpg_mcp_server"
93
+ ],
94
+ "env": {
95
+ "ADBPG_HOST": "host",
96
+ "ADBPG_PORT": "port",
97
+ "ADBPG_USER": "username",
98
+ "ADBPG_PASSWORD": "password",
99
+ "ADBPG_DATABASE": "database",
100
+ "GRAPHRAG_API_KEY": "graphrag api_key",
101
+ "GRAPHRAG_BASE_URL": "graphrag base_url",
102
+ "GRAPHRAG_LLM_MODEL": "graphrag model name",
103
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
104
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
105
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
106
+ "LLMEMORY_API_KEY": "llm memory api_key",
107
+ "LLMEMORY_BASE_URL": "llm memory base_url",
108
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
109
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ ## Components
116
+
117
+ ### Tools
118
+
119
+ * `execute_select_sql`: Execute SELECT SQL queries on the AnalyticDB PostgreSQL server
120
+ * `execute_dml_sql`: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL server
121
+ * `execute_ddl_sql`: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL server
122
+ * `analyze_table`: Collect table statistics
123
+ * `explain_query`: Get query execution plan
124
+
125
+ * `adbpg_graphrag_upload`
126
+ - **Description:** Upload a text file (with its name) and file content to graphrag to generate a knowledge graph.
127
+ - **Parameters:**
128
+ - `filename` (`text`): The name of the file to be uploaded.
129
+ - `context` (`text`): The textual content of the file.
130
+
131
+ * `adbpg_graphrag_query`
132
+ - **Description:** Query the graphrag using the specified query string and mode.
133
+ - **Parameters:**
134
+ - `query_str` (`text`): The query content.
135
+ - `query_mode` (`text`): The query mode, choose from `[bypass, naive, local, global, hybrid, mix]`. If null, defaults to `mix`.
136
+
137
+ * `adbpg_graphrag_upload_decision_tree`
138
+ - **Description:** Upload a decision tree with the specified `root_node`. If the `root_node` does not exist, a new decision tree will be created.
139
+ - **Parameters:**
140
+ - `context` (`text`): The textual representation of the decision tree.
141
+ - `root_node` (`text`): The content of the root node.
142
+
143
+ * `adbpg_graphrag_append_decision_tree`
144
+ - **Description:** Append a subtree to an existing decision tree at the node specified by `root_node_id`.
145
+ - **Parameters:**
146
+ - `context` (`text`): The textual representation of the subtree.
147
+ - `root_node_id` (`text`): The ID of the node to which the subtree will be appended.
148
+
149
+ * `adbpg_graphrag_delete_decision_tree`
150
+ - **Description:** Delete a sub-decision tree under the node specified by `root_node_entity`.
151
+ - **Parameters:**
152
+ - `root_node_entity` (`text`): The ID of the root node of the sub-decision tree to be deleted.
153
+
154
+ * `adbpg_llm_memory_add`
155
+ - **Description:** Add LLM long memory with a specific user, run or agent.
156
+ - **Parameters:**
157
+ - `messages` (`json`): The messages.
158
+ - `user_id` (`text`): User id.
159
+ - `run_id` (`text`): Run id.
160
+ - `agent_id` (`text`): Agent id.
161
+ - `metadata` (`json`): The metadata json(optional).
162
+ - `memory_type` (`text`): The memory type(optional).
163
+ - `prompt` (`text`): The prompt(optional).
164
+ **Note:**
165
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
166
+
167
+ * `adbpg_llm_memory_get_all`
168
+ - **Description:** Retrieves all memory records associated with a specific user, run or agent.
169
+ - **Parameters:**
170
+ - `user_id` (`text`): User ID.
171
+ - `run_id` (`text`): Run ID.
172
+ - `agent_id` (`text`): Agent ID.
173
+ **Note:**
174
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
175
+
176
+ * `adbpg_llm_memory_search`
177
+ - **Description:** Retrieves memories relevant to the given query for a specific user, run, or agent.
178
+ - **Parameters:**
179
+ - `query` (`text`): The search query string.
180
+ - `user_id` (`text`): User ID.
181
+ - `run_id` (`text`): Run ID.
182
+ - `agent_id` (`text`): Agent ID.
183
+ - `filter` (`json`): Additional filter conditions in JSON format (optional).
184
+ **Note:**
185
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
186
+
187
+ * `adbpg_llm_memory_delete_all`:
188
+ - **Description:** Delete all memory records associated with a specific user, run or agent.
189
+ - **Parameters:**
190
+ - `user_id` (`text`): User ID.
191
+ - `run_id` (`text`): Run ID.
192
+ - `agent_id` (`text`): Agent ID.
193
+ **Note:**
194
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
195
+
196
+ ### Resources
197
+
198
+ #### Built-in Resources
199
+
200
+ * `adbpg:///schemas`: Get all schemas in the database
201
+
202
+ #### Resource Templates
203
+
204
+ * `adbpg:///{schema}/tables`: List all tables in a specific schema
205
+ * `adbpg:///{schema}/{table}/ddl`: Get table DDL
206
+ * `adbpg:///{schema}/{table}/statistics`: Show table statistics
207
+
208
+ ## Environment Variables
209
+
210
+ MCP Server requires the following environment variables to connect to AnalyticDB PostgreSQL instance:
211
+
212
+ - `ADBPG_HOST`: Database host address
213
+ - `ADBPG_PORT`: Database port
214
+ - `ADBPG_USER`: Database username
215
+ - `ADBPG_PASSWORD`: Database password
216
+ - `ADBPG_DATABASE`: Database name
217
+
218
+ MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
219
+
220
+ - `GRAPHRAG_API_KEY`: API key for LLM provider
221
+ - `GRAPHRAG_BASE_URL`: Base URL for LLM service endpoint
222
+ - `GRAPHRAG_LLM_MODEL`: LLM model name or identifier
223
+ - `GRAPHRAG_EMBEDDING_MODEL`: Embedding model name or identifier
224
+ - `GRAPHRAG_EMBEDDING_API_KEY`: API key for embedding model provider
225
+ - `GRAPHRAG_EMBEDDING_BASE_URL`: Base URL for embedding service endpoint
226
+ - `GRAPHRAG_LANGUAGE`: (Optional)The language used by graphrag. Defaults to English if not set.
227
+ - `GRAPHRAG_ENTITY_TYPES`: (Optional) Specifies the types of entity nodes to be extracted when parsing the document to generate the knowledge graph.
228
+ - `GRAPHRAG_RELATIONSHIP_TYPES`: (Optional) Specifies the types of relationship edges to be extracted when parsing the document to generate the knowledge graph.
229
+
230
+ - `LLMEMORY_API_KEY`: API key for LLM provider or embedding API
231
+ - `LLMEMORY_BASE_URL`: Base URL for LLM or embedding service endpoint
232
+ - `LLMEMORY_LLM_MODEL`: LLM model name or identifier
233
+ - `LLMEMORY_EMBEDDING_MODEL`: Embedding model name or identifier
234
+
235
+ ## Dependencies
236
+
237
+ - Python 3.10 or higher
238
+ - Required packages:
239
+ - mcp >= 1.4.0
240
+ - psycopg >= 3.1.0
241
+ - python-dotenv >= 1.0.0
242
+ - pydantic >= 2.0.0
243
+
244
+ ## Running
245
+
246
+ ```bash
247
+ # Create and activate virtual environment
248
+ uv venv .venv
249
+ source .venv/bin/activate # Linux/Mac
250
+ # or
251
+ .venv\Scripts\activate # Windows
252
+
253
+ # Install dependencies
254
+ uv pip install -e .
255
+
256
+ # Run server
257
+ uv run adbpg-mcp-server
258
+ ```
259
+
260
+
@@ -0,0 +1,231 @@
1
+ # AnalyticDB PostgreSQL MCP Server
2
+
3
+ AnalyticDB PostgreSQL MCP Server serves as a universal interface between AI Agents and AnalyticDB PostgreSQL databases. It enables seamless communication between AI Agents and AnalyticDB PostgreSQL, helping AI Agents retrieve database metadata and execute SQL operations.
4
+
5
+ ## Configuration
6
+
7
+
8
+
9
+ ### Mode 1: Download
10
+
11
+ Download from Github
12
+
13
+ ```shell
14
+ git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
15
+ ```
16
+
17
+ #### MCP Integration
18
+
19
+ Add the following configuration to the MCP client configuration file:
20
+
21
+ ```json
22
+ "mcpServers": {
23
+ "adbpg-mcp-server": {
24
+ "command": "uv",
25
+ "args": [
26
+ "--directory",
27
+ "/path/to/adbpg-mcp-server",
28
+ "run",
29
+ "adbpg-mcp-server"
30
+ ],
31
+ "env": {
32
+ "ADBPG_HOST": "host",
33
+ "ADBPG_PORT": "port",
34
+ "ADBPG_USER": "username",
35
+ "ADBPG_PASSWORD": "password",
36
+ "ADBPG_DATABASE": "database",
37
+ "GRAPHRAG_API_KEY": "graphrag llm api key",
38
+ "GRAPHRAG_BASE_URL": "graphrag llm base url",
39
+ "GRAPHRAG_LLM_MODEL": "graphrag llm model name",
40
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
41
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
42
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
43
+ "LLMEMORY_API_KEY": "llm memory api_key",
44
+ "LLMEMORY_BASE_URL": "llm memory base_url",
45
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
46
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
47
+ }
48
+ }
49
+ }
50
+ ```
51
+
52
+ ### Mode 2: Using pip
53
+
54
+ ```
55
+ pip install adbpg_mcp_server
56
+ ```
57
+ #### MCP Integration
58
+ ```json
59
+ "mcpServers": {
60
+ "adbpg-mcp-server": {
61
+ "command": "uvx",
62
+ "args": [
63
+ "adbpg_mcp_server"
64
+ ],
65
+ "env": {
66
+ "ADBPG_HOST": "host",
67
+ "ADBPG_PORT": "port",
68
+ "ADBPG_USER": "username",
69
+ "ADBPG_PASSWORD": "password",
70
+ "ADBPG_DATABASE": "database",
71
+ "GRAPHRAG_API_KEY": "graphrag api_key",
72
+ "GRAPHRAG_BASE_URL": "graphrag base_url",
73
+ "GRAPHRAG_LLM_MODEL": "graphrag model name",
74
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
75
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
76
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
77
+ "LLMEMORY_API_KEY": "llm memory api_key",
78
+ "LLMEMORY_BASE_URL": "llm memory base_url",
79
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
80
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
81
+ }
82
+ }
83
+ }
84
+ ```
85
+
86
+ ## Components
87
+
88
+ ### Tools
89
+
90
+ * `execute_select_sql`: Execute SELECT SQL queries on the AnalyticDB PostgreSQL server
91
+ * `execute_dml_sql`: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL server
92
+ * `execute_ddl_sql`: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL server
93
+ * `analyze_table`: Collect table statistics
94
+ * `explain_query`: Get query execution plan
95
+
96
+ * `adbpg_graphrag_upload`
97
+ - **Description:** Upload a text file (with its name) and file content to graphrag to generate a knowledge graph.
98
+ - **Parameters:**
99
+ - `filename` (`text`): The name of the file to be uploaded.
100
+ - `context` (`text`): The textual content of the file.
101
+
102
+ * `adbpg_graphrag_query`
103
+ - **Description:** Query the graphrag using the specified query string and mode.
104
+ - **Parameters:**
105
+ - `query_str` (`text`): The query content.
106
+ - `query_mode` (`text`): The query mode, choose from `[bypass, naive, local, global, hybrid, mix]`. If null, defaults to `mix`.
107
+
108
+ * `adbpg_graphrag_upload_decision_tree`
109
+ - **Description:** Upload a decision tree with the specified `root_node`. If the `root_node` does not exist, a new decision tree will be created.
110
+ - **Parameters:**
111
+ - `context` (`text`): The textual representation of the decision tree.
112
+ - `root_node` (`text`): The content of the root node.
113
+
114
+ * `adbpg_graphrag_append_decision_tree`
115
+ - **Description:** Append a subtree to an existing decision tree at the node specified by `root_node_id`.
116
+ - **Parameters:**
117
+ - `context` (`text`): The textual representation of the subtree.
118
+ - `root_node_id` (`text`): The ID of the node to which the subtree will be appended.
119
+
120
+ * `adbpg_graphrag_delete_decision_tree`
121
+ - **Description:** Delete a sub-decision tree under the node specified by `root_node_entity`.
122
+ - **Parameters:**
123
+ - `root_node_entity` (`text`): The ID of the root node of the sub-decision tree to be deleted.
124
+
125
+ * `adbpg_llm_memory_add`
126
+ - **Description:** Add LLM long memory with a specific user, run or agent.
127
+ - **Parameters:**
128
+ - `messages` (`json`): The messages.
129
+ - `user_id` (`text`): User id.
130
+ - `run_id` (`text`): Run id.
131
+ - `agent_id` (`text`): Agent id.
132
+ - `metadata` (`json`): The metadata json(optional).
133
+ - `memory_type` (`text`): The memory type(optional).
134
+ - `prompt` (`text`): The prompt(optional).
135
+ **Note:**
136
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
137
+
138
+ * `adbpg_llm_memory_get_all`
139
+ - **Description:** Retrieves all memory records associated with a specific user, run or agent.
140
+ - **Parameters:**
141
+ - `user_id` (`text`): User ID.
142
+ - `run_id` (`text`): Run ID.
143
+ - `agent_id` (`text`): Agent ID.
144
+ **Note:**
145
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
146
+
147
+ * `adbpg_llm_memory_search`
148
+ - **Description:** Retrieves memories relevant to the given query for a specific user, run, or agent.
149
+ - **Parameters:**
150
+ - `query` (`text`): The search query string.
151
+ - `user_id` (`text`): User ID.
152
+ - `run_id` (`text`): Run ID.
153
+ - `agent_id` (`text`): Agent ID.
154
+ - `filter` (`json`): Additional filter conditions in JSON format (optional).
155
+ **Note:**
156
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
157
+
158
+ * `adbpg_llm_memory_delete_all`:
159
+ - **Description:** Delete all memory records associated with a specific user, run or agent.
160
+ - **Parameters:**
161
+ - `user_id` (`text`): User ID.
162
+ - `run_id` (`text`): Run ID.
163
+ - `agent_id` (`text`): Agent ID.
164
+ **Note:**
165
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
166
+
167
+ ### Resources
168
+
169
+ #### Built-in Resources
170
+
171
+ * `adbpg:///schemas`: Get all schemas in the database
172
+
173
+ #### Resource Templates
174
+
175
+ * `adbpg:///{schema}/tables`: List all tables in a specific schema
176
+ * `adbpg:///{schema}/{table}/ddl`: Get table DDL
177
+ * `adbpg:///{schema}/{table}/statistics`: Show table statistics
178
+
179
+ ## Environment Variables
180
+
181
+ MCP Server requires the following environment variables to connect to AnalyticDB PostgreSQL instance:
182
+
183
+ - `ADBPG_HOST`: Database host address
184
+ - `ADBPG_PORT`: Database port
185
+ - `ADBPG_USER`: Database username
186
+ - `ADBPG_PASSWORD`: Database password
187
+ - `ADBPG_DATABASE`: Database name
188
+
189
+ MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
190
+
191
+ - `GRAPHRAG_API_KEY`: API key for LLM provider
192
+ - `GRAPHRAG_BASE_URL`: Base URL for LLM service endpoint
193
+ - `GRAPHRAG_LLM_MODEL`: LLM model name or identifier
194
+ - `GRAPHRAG_EMBEDDING_MODEL`: Embedding model name or identifier
195
+ - `GRAPHRAG_EMBEDDING_API_KEY`: API key for embedding model provider
196
+ - `GRAPHRAG_EMBEDDING_BASE_URL`: Base URL for embedding service endpoint
197
+ - `GRAPHRAG_LANGUAGE`: (Optional)The language used by graphrag. Defaults to English if not set.
198
+ - `GRAPHRAG_ENTITY_TYPES`: (Optional) Specifies the types of entity nodes to be extracted when parsing the document to generate the knowledge graph.
199
+ - `GRAPHRAG_RELATIONSHIP_TYPES`: (Optional) Specifies the types of relationship edges to be extracted when parsing the document to generate the knowledge graph.
200
+
201
+ - `LLMEMORY_API_KEY`: API key for LLM provider or embedding API
202
+ - `LLMEMORY_BASE_URL`: Base URL for LLM or embedding service endpoint
203
+ - `LLMEMORY_LLM_MODEL`: LLM model name or identifier
204
+ - `LLMEMORY_EMBEDDING_MODEL`: Embedding model name or identifier
205
+
206
+ ## Dependencies
207
+
208
+ - Python 3.10 or higher
209
+ - Required packages:
210
+ - mcp >= 1.4.0
211
+ - psycopg >= 3.1.0
212
+ - python-dotenv >= 1.0.0
213
+ - pydantic >= 2.0.0
214
+
215
+ ## Running
216
+
217
+ ```bash
218
+ # Create and activate virtual environment
219
+ uv venv .venv
220
+ source .venv/bin/activate # Linux/Mac
221
+ # or
222
+ .venv\Scripts\activate # Windows
223
+
224
+ # Install dependencies
225
+ uv pip install -e .
226
+
227
+ # Run server
228
+ uv run adbpg-mcp-server
229
+ ```
230
+
231
+
@@ -0,0 +1,4 @@
1
+ from .adbpg_mcp_server import run
2
+
3
+ __version__ = "1.0.5"
4
+ name = "adbpg_mcp_server"