alibabacloud-adbpg-mcp-server
alibabacloud-adbpg-mcp-serverは、AIエージェントとAnalyticDB PostgreSQLデータベースの間のユニバーサルインターフェースとして機能します。このツールは、AIエージェントがデータベースのメタデータを取得し、SQL操作を実行するのを容易にします。これにより、データベースとのシームレスな通信が可能になり、AIエージェントの機能を強化します。特に、データ分析やデータベース操作を自動化するための強力なツールです。
GitHubスター
4
ユーザー評価
未評価
フォーク
2
イシュー
0
閲覧数
1
お気に入り
0
AnalyticDB PostgreSQL MCP Server
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.
Configuration
Mode 1: Download
Download from Github
git clone https://github.com/aliyun/alibabacloud-adbpg-mcp-server.git
MCP Integration
Add the following configuration to the MCP client configuration file:
"mcpServers": {
"adbpg-mcp-server": {
"command": "uv",
"args": [
"--directory",
"/path/to/adbpg-mcp-server",
"run",
"adbpg-mcp-server"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database",
"GRAPHRAG_API_KEY": "graphrag llm api key",
"GRAPHRAG_BASE_URL": "graphrag llm base url",
"GRAPHRAG_LLM_MODEL": "graphrag llm model name",
"GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
"GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
"GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
"LLMEMORY_API_KEY": "llm memory api_key",
"LLMEMORY_BASE_URL": "llm memory base_url",
"LLMEMORY_LLM_MODEL": "llm memory model name",
"LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
}
}
}
Mode 2: Using pip
pip install adbpg_mcp_server
MCP Integration
"mcpServers": {
"adbpg-mcp-server": {
"command": "uvx",
"args": [
"adbpg_mcp_server"
],
"env": {
"ADBPG_HOST": "host",
"ADBPG_PORT": "port",
"ADBPG_USER": "username",
"ADBPG_PASSWORD": "password",
"ADBPG_DATABASE": "database",
"GRAPHRAG_API_KEY": "graphrag api_key",
"GRAPHRAG_BASE_URL": "graphrag base_url",
"GRAPHRAG_LLM_MODEL": "graphrag model name",
"GRAPHRAG_EMBEDDING_MODEL": "graphrag embedding model name",
"GRAPHRAG_EMBEDDING_API_KEY": "graphrag embedding api key",
"GRAPHRAG_EMBEDDING_BASE_URL": "graphrag embedding url",
"LLMEMORY_API_KEY": "llm memory api_key",
"LLMEMORY_BASE_URL": "llm memory base_url",
"LLMEMORY_LLM_MODEL": "llm memory model name",
"LLMEMORY_EMBEDDING_MODEL": "llm memory embedding model name"
}
}
}
Components
Tools
execute_select_sql
: Execute SELECT SQL queries on the AnalyticDB PostgreSQL serverexecute_dml_sql
: Execute DML (INSERT, UPDATE, DELETE) SQL queries on the AnalyticDB PostgreSQL serverexecute_ddl_sql
: Execute DDL (CREATE, ALTER, DROP) SQL queries on the AnalyticDB PostgreSQL serveranalyze_table
: Collect table statisticsexplain_query
: Get query execution planadbpg_graphrag_upload
- Description: Upload a text file (with its name) and file content to graphrag to generate a knowledge graph.
- Parameters:
filename
(text
): The name of the file to be uploaded.context
(text
): The textual content of the file.
adbpg_graphrag_query
- Description: Query the graphrag using the specified query string and mode.
- Parameters:
query_str
(text
): The query content.query_mode
(text
): The query mode, choose from[bypass, naive, local, global, hybrid, mix]
. If null, defaults tomix
.
adbpg_graphrag_upload_decision_tree
- Description: Upload a decision tree with the specified
root_node
. If theroot_node
does not exist, a new decision tree will be created. - Parameters:
context
(text
): The textual representation of the decision tree.root_node
(text
): The content of the root node.
- Description: Upload a decision tree with the specified
adbpg_graphrag_append_decision_tree
- Description: Append a subtree to an existing decision tree at the node specified by
root_node_id
. - Parameters:
context
(text
): The textual representation of the subtree.root_node_id
(text
): The ID of the node to which the subtree will be appended.
- Description: Append a subtree to an existing decision tree at the node specified by
adbpg_graphrag_delete_decision_tree
- Description: Delete a sub-decision tree under the node specified by
root_node_entity
. - Parameters:
root_node_entity
(text
): The ID of the root node of the sub-decision tree to be deleted.
- Description: Delete a sub-decision tree under the node specified by
adbpg_llm_memory_add
- Description: Add LLM long memory with a specific user, run or agent.
- Parameters:
messages
(json
): The messages.user_id
(text
): User id.run_id
(text
): Run id.agent_id
(text
): Agent id.metadata
(json
): The metadata json(optional).memory_type
(text
): The memory type(optional).prompt
(text
): The prompt(optional). Note:
At least one ofuser_id
,run_id
, oragent_id
should be provided.
adbpg_llm_memory_get_all
- Description: Retrieves all memory records associated with a specific user, run or agent.
- Parameters:
user_id
(text
): User ID.run_id
(text
): Run ID.agent_id
(text
): Agent ID. Note:
At least one ofuser_id
,run_id
, oragent_id
should be provided.
adbpg_llm_memory_search
- Description: Retrieves memories relevant to the given query for a specific user, run, or agent.
- Parameters:
query
(text
): The search query string.user_id
(text
): User ID.run_id
(text
): Run ID.agent_id
(text
): Agent ID.filter
(json
): Additional filter conditions in JSON format (optional). Note:
At least one ofuser_id
,run_id
, oragent_id
should be provided.
adbpg_llm_memory_delete_all
:- Description: Delete all memory records associated with a specific user, run or agent.
- Parameters:
user_id
(text
): User ID.run_id
(text
): Run ID.agent_id
(text
): Agent ID. Note:
At least one ofuser_id
,run_id
, oragent_id
should be provided.
Resources
Built-in Resources
adbpg:///schemas
: Get all schemas in the database
Resource Templates
adbpg:///{schema}/tables
: List all tables in a specific schemaadbpg:///{schema}/{table}/ddl
: Get table DDLadbpg:///{schema}/{table}/statistics
: Show table statistics
Environment Variables
MCP Server requires the following environment variables to connect to AnalyticDB PostgreSQL instance:
ADBPG_HOST
: Database host addressADBPG_PORT
: Database portADBPG_USER
: Database usernameADBPG_PASSWORD
: Database passwordADBPG_DATABASE
: Database name
MCP Server requires the following environment variables to initialize graphRAG and llm memory server:
GRAPHRAG_API_KEY
: API key for LLM providerGRAPHRAG_BASE_URL
: Base URL for LLM service endpointGRAPHRAG_LLM_MODEL
: LLM model name or identifierGRAPHRAG_EMBEDDING_MODEL
: Embedding model name or identifierGRAPHRAG_EMBEDDING_API_KEY
: API key for embedding model providerGRAPHRAG_EMBEDDING_BASE_URL
: Base URL for embedding service endpointGRAPHRAG_LANGUAGE
: (Optional)The language used by graphrag. Defaults to English if not set.GRAPHRAG_ENTITY_TYPES
: (Optional) Specifies the types of entity nodes to be extracted when parsing the document to generate the knowledge graph.GRAPHRAG_RELATIONSHIP_TYPES
: (Optional) Specifies the types of relationship edges to be extracted when parsing the document to generate the knowledge graph.LLMEMORY_API_KEY
: API key for LLM provider or embedding APILLMEMORY_BASE_URL
: Base URL for LLM or embedding service endpointLLMEMORY_LLM_MODEL
: LLM model name or identifierLLMEMORY_EMBEDDING_MODEL
: Embedding model name or identifier
Dependencies
- Python 3.10 or higher
- Required packages:
- mcp >= 1.4.0
- psycopg >= 3.1.0
- python-dotenv >= 1.0.0
- pydantic >= 2.0.0
Running
# Create and activate virtual environment
uv venv .venv
source .venv/bin/activate # Linux/Mac
# or
.venv\Scripts\activate # Windows
# Install dependencies
uv pip install -e .
# Run server
uv run adbpg-mcp-server