adbpg-mcp-server 1.0.7__tar.gz → 2.0.0__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.
Files changed (26) hide show
  1. adbpg_mcp_server-2.0.0/PKG-INFO +278 -0
  2. {adbpg_mcp_server-1.0.7 → adbpg_mcp_server-2.0.0}/README.md +111 -78
  3. adbpg_mcp_server-2.0.0/pyproject.toml +24 -0
  4. adbpg_mcp_server-2.0.0/setup.cfg +4 -0
  5. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/__init__.py +0 -0
  6. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/__main__.py +45 -0
  7. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/adbpg.py +113 -0
  8. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/adbpg_basic_operation.py +160 -0
  9. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/adbpg_config.py +155 -0
  10. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/adbpg_graphrag.py +197 -0
  11. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/adbpg_memory.py +201 -0
  12. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/server_http.py +206 -0
  13. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server/server_stdio.py +216 -0
  14. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/PKG-INFO +278 -0
  15. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/SOURCES.txt +17 -0
  16. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/dependency_links.txt +1 -0
  17. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/entry_points.txt +2 -0
  18. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/requires.txt +3 -0
  19. adbpg_mcp_server-2.0.0/src/adbpg_mcp_server.egg-info/top_level.txt +1 -0
  20. adbpg_mcp_server-1.0.7/LICENSE +0 -201
  21. adbpg_mcp_server-1.0.7/PKG-INFO +0 -10
  22. adbpg_mcp_server-1.0.7/adbpg_mcp_server.py +0 -1143
  23. adbpg_mcp_server-1.0.7/images/AnalyticDB.png +0 -0
  24. adbpg_mcp_server-1.0.7/pyproject.toml +0 -21
  25. adbpg_mcp_server-1.0.7/requirements.txt +0 -3
  26. adbpg_mcp_server-1.0.7/uv.lock +0 -374
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.4
2
+ Name: adbpg-mcp-server
3
+ Version: 2.0.0
4
+ Summary: 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.
5
+ Requires-Python: >=3.11
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: mcp>=1.13.1
8
+ Requires-Dist: psycopg>=3.2.10
9
+ Requires-Dist: requests>=2.32.5
10
+
11
+ # AnalyticDB PostgreSQL MCP Server
12
+
13
+ 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.
14
+
15
+ ## Installation
16
+
17
+ You can set up the server either from the source code for development or by installing it from PyPI for direct use.
18
+
19
+ ### Option 1: From Source (for Development)
20
+
21
+ This method is recommended if you want to modify or contribute to the server.
22
+
23
+ ```shell
24
+ # 1. Clone the repository
25
+ git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
26
+ cd alibabacloud-adbpg-mcp-server
27
+
28
+ # 2. Create and activate a virtual environment using uv
29
+ uv venv .venv
30
+ source .venv/bin/activate # On Linux/macOS
31
+ # .\.venv\Scripts\activate # On Windows
32
+
33
+ # 3. Install the project in editable mode
34
+ uv pip install -e .
35
+ ```
36
+
37
+ ### Option 2: From PyPI (for Production/Usage)
38
+
39
+ This is the simplest way to install the server for direct use within your projects.
40
+
41
+ ```shell
42
+ pip install adbpg_mcp_server
43
+ ```
44
+
45
+ ## Running the Server
46
+
47
+ The server can be run in two transport modes: `stdio` (default) for integration with MCP clients, and `http` for direct API access or debugging.
48
+
49
+ Make sure you have set up the required [Environment Variables](#environment-variables) before running the server.
50
+
51
+ ### Stdio Mode (Default)
52
+
53
+ This is the standard mode for communication with an MCP client.
54
+
55
+ ```bash
56
+ # Run using the default transport (stdio)
57
+ uv run adbpg-mcp-server
58
+
59
+ # Or explicitly specify the transport
60
+ uv run adbpg-mcp-server --transport stdio
61
+ ```
62
+
63
+ ### Streamable-HTTP Mode
64
+
65
+ This mode exposes an HTTP server, which is useful for testing, debugging, or direct integration via REST APIs.
66
+
67
+ ```bash
68
+ # Run the server in HTTP mode on the default host and port (127.0.0.1:3000)
69
+ uv run adbpg-mcp-server --transport http
70
+
71
+ # Specify a custom host and port
72
+ uv run adbpg-mcp-server --transport http --host 0.0.0.0 --port 3000
73
+ ```
74
+
75
+ ## MCP Integration
76
+
77
+ To integrate this server with a parent MCP client, add the following configuration to the client's configuration file. The arguments in the `args` array will depend on the transport protocol you choose.
78
+
79
+ ### Example for Stdio Transport
80
+
81
+ ```json
82
+ "mcpServers": {
83
+ "adbpg-mcp-server": {
84
+ "command": "uv",
85
+ "args": [
86
+ "run",
87
+ "adbpg-mcp-server",
88
+ "--transport",
89
+ "stdio"
90
+ ],
91
+ "env": {
92
+ "ADBPG_HOST": "host",
93
+ "ADBPG_PORT": "port",
94
+ "ADBPG_USER": "username",
95
+ "ADBPG_PASSWORD": "password",
96
+ "ADBPG_DATABASE": "database",
97
+ "GRAPHRAG_API_KEY": "graphrag llm api key",
98
+ "GRAPHRAG_BASE_URL": "graphrag llm base url",
99
+ "GRAPHRAG_LLM_MODEL": "graphrag llm model name",
100
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
101
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
102
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
103
+ "LLMEMORY_API_KEY": "llm memory api_key",
104
+ "LLMEMORY_BASE_URL": "llm memory base_url",
105
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
106
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
107
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
108
+ }
109
+ }
110
+ }
111
+ ```
112
+ > **Note:** Since `stdio` is the default, you can optionally omit `"--transport", "stdio"` from the `args` array.
113
+
114
+ ### Example for Streamable-HTTP Transport
115
+
116
+ ```json
117
+ "mcpServers": {
118
+ "adbpg-mcp-server": {
119
+ "command": "uv",
120
+ "args": [
121
+ "run",
122
+ "adbpg-mcp-server",
123
+ "--transport",
124
+ "http",
125
+ "--port",
126
+ "3000"
127
+ ],
128
+ "env": {
129
+ "ADBPG_HOST": "host",
130
+ "ADBPG_PORT": "port",
131
+ "ADBPG_USER": "username",
132
+ "ADBPG_PASSWORD": "password",
133
+ "ADBPG_DATABASE": "database",
134
+ "GRAPHRAG_API_KEY": "graphrag llm api key",
135
+ "GRAPHRAG_BASE_URL": "graphrag llm base url",
136
+ "GRAPHRAG_LLM_MODEL": "graphrag llm model name",
137
+ "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
138
+ "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
139
+ "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
140
+ "LLMEMORY_API_KEY": "llm memory api_key",
141
+ "LLMEMORY_BASE_URL": "llm memory base_url",
142
+ "LLMEMORY_LLM_MODEL": "llm memory model name",
143
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
144
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+
151
+ ### Tools
152
+
153
+ * `execute_select_sql`: Execute SELECT SQL queries on the AnalyticDB PostgreSQL server
154
+ * `execute_dml_sql`: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL server
155
+ * `execute_ddl_sql`: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL server
156
+ * `analyze_table`: Collect table statistics
157
+ * `explain_query`: Get query execution plan
158
+
159
+ * `adbpg_graphrag_upload`
160
+ - **Description:** Upload a text file (with its name) and file content to graphrag to generate a knowledge graph.
161
+ - **Parameters:**
162
+ - `filename` (`text`): The name of the file to be uploaded.
163
+ - `context` (`text`): The textual content of the file.
164
+
165
+ * `adbpg_graphrag_query`
166
+ - **Description:** Query the graphrag using the specified query string and mode。
167
+ - **Parameters:**
168
+ - `query_str` (`text`): the query content.
169
+ - `query_mode` (`text`): The query mode, choose from `[bypass, naive, local, global, hybrid, mix]`. If null, defaults to `mix`.
170
+
171
+ * `adbpg_graphrag.upload_decision_tree(context text, root_node text)`
172
+ - **Description:** Upload a decision tree with the specified `root_node`. If the `root_node` does not exist, a new decision tree will be created.
173
+ - **Parameters:**
174
+ - `context` (`text`): The textual representation of the decision tree.
175
+ - `root_node` (`text`): The content of the root node.
176
+
177
+ * `adbpg_graphrag.append_decision_tree(context text, root_node_id text)`
178
+ - **Description:** Append a subtree to an existing decision tree at the node specified by `root_node_id`.
179
+ - **Parameters:**
180
+ - `context` (`text`): The textual representation of the subtree.
181
+ - `root_node_id` (`text`): The ID of the node to which the subtree will be appended.
182
+
183
+ * `adbpg_graphrag.delete_decision_tree(root_node_entity text)`
184
+ - **Description:** Delete a sub-decision tree under the node specified by `root_node_entity`.
185
+ - **Parameters:**
186
+ - `root_node_entity` (`text`): The ID of the root node of the sub-decision tree to be deleted.
187
+
188
+
189
+
190
+
191
+ * `adbpg_llm_memory_add`
192
+ - **Description:** Add LLM long memory.
193
+ - **Parameters:**
194
+ - `messages` (`json`): The name of the file to be uploaded.
195
+ - `user_id` (`text`): The user id.
196
+ - `run_id` (`text`): The run id.
197
+ - `agent_id` (`text`): The agent id.
198
+ - `metadata` (`json`): The metadata json(optional).
199
+ - `memory_type` (`text`): The memory type(optional).
200
+ - `prompt` (`text`): The prompt(optional).
201
+ **Note:**
202
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
203
+
204
+ * `adbpg_llm_memory_get_all`
205
+ - **Description:** Retrieves all memory records associated with a specific user, run or agent.
206
+ - **Parameters:**
207
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
208
+ - `run_id` (`text`): Run ID (optional).
209
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
210
+ **Note:**
211
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
212
+
213
+ * `adbpg_llm_memory_search`
214
+ - **Description:** Retrieves memories relevant to the given query for a specific user, run, or agent.
215
+ - **Parameters:**
216
+ - `query` (`text`): The search query string.
217
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
218
+ - `run_id` (`text`): Run ID (optional).
219
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
220
+ - `filter` (`json`): Additional filter conditions in JSON format (optional).
221
+ **Note:**
222
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
223
+
224
+ * `adbpg_llm_memory_delete_all`:
225
+ - **Description:** Delete all memory records associated with a specific user, run or agent.
226
+ - **Parameters:**
227
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
228
+ - `run_id` (`text`): Run ID (optional).
229
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
230
+ **Note:**
231
+ At least one of `user_id`, `run_id`, or `agent_id` should be provided.
232
+
233
+ ### Resources
234
+
235
+ #### Built-in Resources
236
+
237
+ * `adbpg:///schemas`: Get all schemas in the database
238
+
239
+ #### Resource Templates
240
+
241
+ * `adbpg:///{schema}/tables`: List all tables in a specific schema
242
+ * `adbpg:///{schema}/{table}/ddl`: Get table DDL
243
+ * `adbpg:///{schema}/{table}/statistics`: Show table statistics
244
+
245
+ ## Environment Variables
246
+
247
+ MCP Server requires the following environment variables to connect to AnalyticDB PostgreSQL instance:
248
+
249
+ - `ADBPG_HOST`: Database host address
250
+ - `ADBPG_PORT`: Database port
251
+ - `ADBPG_USER`: Database username
252
+ - `ADBPG_PASSWORD`: Database password
253
+ - `ADBPG_DATABASE`: Database name
254
+
255
+ MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
256
+
257
+ - `API_KEY`: API key for LLM provider or embedding API
258
+ - `BASE_URL`: Base URL for LLM or embedding service endpoint
259
+ - `LLM_MODEL`: LLM model name or identifier
260
+ - `EMBEDDING_MODEL`: Embedding model name or identifier
261
+
262
+ ### Resources
263
+
264
+ #### Built-in Resources
265
+
266
+ * `adbpg:///schemas`: Get all schemas in the database
267
+
268
+ #### Resource Templates
269
+
270
+ * `adbpg:///{schema}/tables`: List all tables in a specific schema
271
+ * `adbpg:///{schema}/{table}/ddl`: Get table DDL
272
+ * `adbpg:///{schema}/{table}/statistics`: Show table statistics
273
+
274
+
275
+ ## Dependencies
276
+
277
+ * Python 3.11 or higher
278
+ * `uv` (for environment and package management)
@@ -2,31 +2,81 @@
2
2
 
3
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
4
 
5
- ## Configuration
5
+ ## Installation
6
6
 
7
+ You can set up the server either from the source code for development or by installing it from PyPI for direct use.
7
8
 
9
+ ### Option 1: From Source (for Development)
8
10
 
9
- ### Mode 1: Download
10
-
11
- Download from Github
11
+ This method is recommended if you want to modify or contribute to the server.
12
12
 
13
13
  ```shell
14
+ # 1. Clone the repository
14
15
  git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
16
+ cd alibabacloud-adbpg-mcp-server
17
+
18
+ # 2. Create and activate a virtual environment using uv
19
+ uv venv .venv
20
+ source .venv/bin/activate # On Linux/macOS
21
+ # .\.venv\Scripts\activate # On Windows
22
+
23
+ # 3. Install the project in editable mode
24
+ uv pip install -e .
15
25
  ```
16
26
 
17
- #### MCP Integration
27
+ ### Option 2: From PyPI (for Production/Usage)
28
+
29
+ This is the simplest way to install the server for direct use within your projects.
30
+
31
+ ```shell
32
+ pip install adbpg_mcp_server
33
+ ```
34
+
35
+ ## Running the Server
36
+
37
+ The server can be run in two transport modes: `stdio` (default) for integration with MCP clients, and `http` for direct API access or debugging.
38
+
39
+ Make sure you have set up the required [Environment Variables](#environment-variables) before running the server.
18
40
 
19
- Add the following configuration to the MCP client configuration file:
41
+ ### Stdio Mode (Default)
42
+
43
+ This is the standard mode for communication with an MCP client.
44
+
45
+ ```bash
46
+ # Run using the default transport (stdio)
47
+ uv run adbpg-mcp-server
48
+
49
+ # Or explicitly specify the transport
50
+ uv run adbpg-mcp-server --transport stdio
51
+ ```
52
+
53
+ ### Streamable-HTTP Mode
54
+
55
+ This mode exposes an HTTP server, which is useful for testing, debugging, or direct integration via REST APIs.
56
+
57
+ ```bash
58
+ # Run the server in HTTP mode on the default host and port (127.0.0.1:3000)
59
+ uv run adbpg-mcp-server --transport http
60
+
61
+ # Specify a custom host and port
62
+ uv run adbpg-mcp-server --transport http --host 0.0.0.0 --port 3000
63
+ ```
64
+
65
+ ## MCP Integration
66
+
67
+ To integrate this server with a parent MCP client, add the following configuration to the client's configuration file. The arguments in the `args` array will depend on the transport protocol you choose.
68
+
69
+ ### Example for Stdio Transport
20
70
 
21
71
  ```json
22
72
  "mcpServers": {
23
73
  "adbpg-mcp-server": {
24
74
  "command": "uv",
25
75
  "args": [
26
- "--directory",
27
- "/path/to/adbpg-mcp-server",
28
76
  "run",
29
- "adbpg-mcp-server"
77
+ "adbpg-mcp-server",
78
+ "--transport",
79
+ "stdio"
30
80
  ],
31
81
  "env": {
32
82
  "ADBPG_HOST": "host",
@@ -43,24 +93,27 @@ Add the following configuration to the MCP client configuration file:
43
93
  "LLMEMORY_API_KEY": "llm memory api_key",
44
94
  "LLMEMORY_BASE_URL": "llm memory base_url",
45
95
  "LLMEMORY_LLM_MODEL": "llm memory model name",
46
- "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
96
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
97
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
47
98
  }
48
99
  }
49
100
  }
50
101
  ```
102
+ > **Note:** Since `stdio` is the default, you can optionally omit `"--transport", "stdio"` from the `args` array.
51
103
 
52
- ### Mode 2: Using pip
104
+ ### Example for Streamable-HTTP Transport
53
105
 
54
- ```
55
- pip install adbpg_mcp_server
56
- ```
57
- #### MCP Integration
58
106
  ```json
59
107
  "mcpServers": {
60
108
  "adbpg-mcp-server": {
61
- "command": "uvx",
109
+ "command": "uv",
62
110
  "args": [
63
- "adbpg_mcp_server"
111
+ "run",
112
+ "adbpg-mcp-server",
113
+ "--transport",
114
+ "http",
115
+ "--port",
116
+ "3000"
64
117
  ],
65
118
  "env": {
66
119
  "ADBPG_HOST": "host",
@@ -68,22 +121,22 @@ pip install adbpg_mcp_server
68
121
  "ADBPG_USER": "username",
69
122
  "ADBPG_PASSWORD": "password",
70
123
  "ADBPG_DATABASE": "database",
71
- "GRAPHRAG_API_KEY": "graphrag api_key",
72
- "GRAPHRAG_BASE_URL": "graphrag base_url",
73
- "GRAPHRAG_LLM_MODEL": "graphrag model name",
124
+ "GRAPHRAG_API_KEY": "graphrag llm api key",
125
+ "GRAPHRAG_BASE_URL": "graphrag llm base url",
126
+ "GRAPHRAG_LLM_MODEL": "graphrag llm model name",
74
127
  "GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
75
128
  "GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
76
129
  "GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
77
130
  "LLMEMORY_API_KEY": "llm memory api_key",
78
131
  "LLMEMORY_BASE_URL": "llm memory base_url",
79
132
  "LLMEMORY_LLM_MODEL": "llm memory model name",
80
- "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
133
+ "LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name",
134
+ "LLMEMORY_ENABLE_GRAPH": "enable graph engine for llm memory (Default: false)"
81
135
  }
82
136
  }
83
137
  }
84
138
  ```
85
139
 
86
- ## Components
87
140
 
88
141
  ### Tools
89
142
 
@@ -100,49 +153,50 @@ pip install adbpg_mcp_server
100
153
  - `context` (`text`): The textual content of the file.
101
154
 
102
155
  * `adbpg_graphrag_query`
103
- - **Description:** Query the graphrag using the specified query string and mode.
156
+ - **Description:** Query the graphrag using the specified query string and mode
104
157
  - **Parameters:**
105
- - `query_str` (`text`): The query content.
158
+ - `query_str` (`text`): the query content.
106
159
  - `query_mode` (`text`): The query mode, choose from `[bypass, naive, local, global, hybrid, mix]`. If null, defaults to `mix`.
107
160
 
108
- * `adbpg_graphrag_upload_decision_tree`
161
+ * `adbpg_graphrag.upload_decision_tree(context text, root_node text)`
109
162
  - **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
163
  - **Parameters:**
111
164
  - `context` (`text`): The textual representation of the decision tree.
112
165
  - `root_node` (`text`): The content of the root node.
113
166
 
114
- * `adbpg_graphrag_append_decision_tree`
167
+ * `adbpg_graphrag.append_decision_tree(context text, root_node_id text)`
115
168
  - **Description:** Append a subtree to an existing decision tree at the node specified by `root_node_id`.
116
169
  - **Parameters:**
117
170
  - `context` (`text`): The textual representation of the subtree.
118
171
  - `root_node_id` (`text`): The ID of the node to which the subtree will be appended.
119
172
 
120
- * `adbpg_graphrag_delete_decision_tree`
173
+ * `adbpg_graphrag.delete_decision_tree(root_node_entity text)`
121
174
  - **Description:** Delete a sub-decision tree under the node specified by `root_node_entity`.
122
175
  - **Parameters:**
123
176
  - `root_node_entity` (`text`): The ID of the root node of the sub-decision tree to be deleted.
124
177
 
178
+
179
+
180
+
125
181
  * `adbpg_llm_memory_add`
126
- - **Description:** Add LLM long memory with a specific user, run or agent.
182
+ - **Description:** Add LLM long memory.
127
183
  - **Parameters:**
128
- - `messages` (`json`): The messages.
129
- - `user_id` (`text`): User id.
130
- - `run_id` (`text`): Run id.
131
- - `agent_id` (`text`): Agent id.
184
+ - `messages` (`json`): The name of the file to be uploaded.
185
+ - `user_id` (`text`): The user id.
186
+ - `run_id` (`text`): The run id.
187
+ - `agent_id` (`text`): The agent id.
132
188
  - `metadata` (`json`): The metadata json(optional).
133
189
  - `memory_type` (`text`): The memory type(optional).
134
190
  - `prompt` (`text`): The prompt(optional).
135
-
136
191
  **Note:**
137
192
  At least one of `user_id`, `run_id`, or `agent_id` should be provided.
138
193
 
139
194
  * `adbpg_llm_memory_get_all`
140
195
  - **Description:** Retrieves all memory records associated with a specific user, run or agent.
141
196
  - **Parameters:**
142
- - `user_id` (`text`): User ID.
143
- - `run_id` (`text`): Run ID.
144
- - `agent_id` (`text`): Agent ID.
145
-
197
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
198
+ - `run_id` (`text`): Run ID (optional).
199
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
146
200
  **Note:**
147
201
  At least one of `user_id`, `run_id`, or `agent_id` should be provided.
148
202
 
@@ -150,21 +204,19 @@ pip install adbpg_mcp_server
150
204
  - **Description:** Retrieves memories relevant to the given query for a specific user, run, or agent.
151
205
  - **Parameters:**
152
206
  - `query` (`text`): The search query string.
153
- - `user_id` (`text`): User ID.
154
- - `run_id` (`text`): Run ID.
155
- - `agent_id` (`text`): Agent ID.
207
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
208
+ - `run_id` (`text`): Run ID (optional).
209
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
156
210
  - `filter` (`json`): Additional filter conditions in JSON format (optional).
157
-
158
211
  **Note:**
159
212
  At least one of `user_id`, `run_id`, or `agent_id` should be provided.
160
213
 
161
214
  * `adbpg_llm_memory_delete_all`:
162
215
  - **Description:** Delete all memory records associated with a specific user, run or agent.
163
216
  - **Parameters:**
164
- - `user_id` (`text`): User ID.
165
- - `run_id` (`text`): Run ID.
166
- - `agent_id` (`text`): Agent ID.
167
-
217
+ - `user_id` (`text`): User ID (optional). If provided, fetch all memories for this user.
218
+ - `run_id` (`text`): Run ID (optional).
219
+ - `agent_id` (`text`): Agent ID (optional). If provided, fetch all memories for this agent.
168
220
  **Note:**
169
221
  At least one of `user_id`, `run_id`, or `agent_id` should be provided.
170
222
 
@@ -192,44 +244,25 @@ MCP Server requires the following environment variables to connect to AnalyticDB
192
244
 
193
245
  MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
194
246
 
195
- - `GRAPHRAG_API_KEY`: API key for LLM provider
196
- - `GRAPHRAG_BASE_URL`: Base URL for LLM service endpoint
197
- - `GRAPHRAG_LLM_MODEL`: LLM model name or identifier
198
- - `GRAPHRAG_EMBEDDING_MODEL`: Embedding model name or identifier
199
- - `GRAPHRAG_EMBEDDING_API_KEY`: API key for embedding model provider
200
- - `GRAPHRAG_EMBEDDING_BASE_URL`: Base URL for embedding service endpoint
201
- - `GRAPHRAG_LANGUAGE`: (Optional)The language used by graphrag. Defaults to English if not set.
202
- - `GRAPHRAG_ENTITY_TYPES`: (Optional) Specifies the types of entity nodes to be extracted when parsing the document to generate the knowledge graph.
203
- - `GRAPHRAG_RELATIONSHIP_TYPES`: (Optional) Specifies the types of relationship edges to be extracted when parsing the document to generate the knowledge graph.
204
-
205
- - `LLMEMORY_API_KEY`: API key for LLM provider or embedding API
206
- - `LLMEMORY_BASE_URL`: Base URL for LLM or embedding service endpoint
207
- - `LLMEMORY_LLM_MODEL`: LLM model name or identifier
208
- - `LLMEMORY_EMBEDDING_MODEL`: Embedding model name or identifier
247
+ - `API_KEY`: API key for LLM provider or embedding API
248
+ - `BASE_URL`: Base URL for LLM or embedding service endpoint
249
+ - `LLM_MODEL`: LLM model name or identifier
250
+ - `EMBEDDING_MODEL`: Embedding model name or identifier
209
251
 
210
- ## Dependencies
252
+ ### Resources
211
253
 
212
- - Python 3.10 or higher
213
- - Required packages:
214
- - mcp >= 1.4.0
215
- - psycopg >= 3.1.0
216
- - python-dotenv >= 1.0.0
217
- - pydantic >= 2.0.0
254
+ #### Built-in Resources
218
255
 
219
- ## Running
256
+ * `adbpg:///schemas`: Get all schemas in the database
220
257
 
221
- ```bash
222
- # Create and activate virtual environment
223
- uv venv .venv
224
- source .venv/bin/activate # Linux/Mac
225
- # or
226
- .venv\Scripts\activate # Windows
258
+ #### Resource Templates
227
259
 
228
- # Install dependencies
229
- uv pip install -e .
260
+ * `adbpg:///{schema}/tables`: List all tables in a specific schema
261
+ * `adbpg:///{schema}/{table}/ddl`: Get table DDL
262
+ * `adbpg:///{schema}/{table}/statistics`: Show table statistics
230
263
 
231
- # Run server
232
- uv run adbpg-mcp-server
233
- ```
234
264
 
265
+ ## Dependencies
235
266
 
267
+ * Python 3.11 or higher
268
+ * `uv` (for environment and package management)
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "adbpg-mcp-server"
7
+ version = "2.0.0"
8
+ description = "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."
9
+ readme = "README.md"
10
+ requires-python = ">=3.11"
11
+ dependencies = [
12
+ "mcp>=1.13.1",
13
+ "psycopg>=3.2.10",
14
+ "requests>=2.32.5",
15
+ ]
16
+
17
+ [project.scripts]
18
+ adbpg-mcp-server = "adbpg_mcp_server.__main__:main"
19
+
20
+ [tool.setuptools]
21
+ package-dir = {"" = "src"}
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ import argparse
2
+ import sys
3
+
4
+ from .server_http import run_http_server
5
+ from .server_stdio import run_stdio_server
6
+
7
+ def main():
8
+ """
9
+ 通过参数选择使用 stdio 或 http 服务器
10
+ """
11
+ parser = argparse.ArgumentParser(
12
+ description="ADBPG Management & Control Plane MCP Server"
13
+ )
14
+ parser.add_argument(
15
+ "--transport",
16
+ choices = ["stdio", "http"],
17
+ default = "stdio",
18
+ help = "Transport protocol to use (stdio or streamable-http)"
19
+ )
20
+ http_group = parser.add_argument_group("HTTP Server Options")
21
+ http_group.add_argument(
22
+ "--host",
23
+ default="127.0.0.1",
24
+ help = "Host to bind the HTTP server to (default: 127.0.0.1)."
25
+ )
26
+ http_group.add_argument(
27
+ "--port",
28
+ type = int,
29
+ default = 3000,
30
+ help = "Port to bind the HTTP server to (default: 3000)."
31
+ )
32
+
33
+ args = parser.parse_args()
34
+ print(f"Starting ADBPG MCP Server with transport {args.transport}")
35
+
36
+ if args.transport == "http":
37
+ run_http_server(host=args.host, port=args.port)
38
+ elif args.transport == "stdio":
39
+ run_stdio_server()
40
+ else:
41
+ raise ValueError(f"Invalid transport: {args.transport}")
42
+
43
+ if __name__ == "__main__":
44
+ main()
45
+