Token导航 LogoToken导航TokenDH.com
MCP Llamaindex Crud Agent logo
数据服务stdio官方级别未说明来源级核验

MCP Llamaindex Crud Agent

MCP Server

一个基于LLM的PostgreSQL数据库代理系统,支持通过自然语言进行数据库操作,具有工具驱动执行和模块化工作流特性。

工具数

0

提示词数

0

GitHub Stars

0

资源数

0
PostgreSQL自然语言处理模型集成

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

00VALAK00

提供方

00VALAK00

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

pip install -r requirements.txt # or use pyproject.toml with pip/uv

详细介绍

MCP-AgentDB

概述

该项目提供了一个代理的、MCP工具驱动的系统,用于使用LLM与PostgreSQL数据库进行交互。它利用LlamaIndex、Ollama和自定义工作流来解释用户请求,选择适当的数据库工具,并透明地执行操作。该系统的设计具有可扩展性和易用性。

特性

  • 自然语言数据库操作: 使用简明英语查询、插入、更新和管理数据库。
  • 工具驱动执行: 所有操作都是通过明确的工具调用执行的,以确保透明度和可审计性。
  • PostgreSQL后端: 使用PostgreSQL作为默认数据库(可配置)。
  • 代理工作流: 具有内存、事件驱动步骤和LLM驱动推理的模块化工作流。
  • Docker支持: 使用Docker Compose轻松设置应用程序和数据库。

建筑

flowchart LR
    subgraph UserAgent["FunctionAgent (LlamaIndex)"]
        A[FunctionAgent]
    end
    subgraph MCP["MCP Server"]
        B[MCP Server]
    end
    subgraph Ollama["Ollama Server"]
        C[LLM]
    end
    subgraph DB["PostgreSQL DB"]
        D[PostgreSQL DB]
    end

    A -- "MCP Protocol Requests/Responses" --> B
    C -- "Integration" --> A
    B -- "APIs" --> D
  

    style A fill:#cef,stroke:#333,stroke-width:2px,stroke-length:4px
    style B fill:#eef,stroke:#333,stroke-width:2px,stroke-length:8px
    style C fill:#ffe,stroke:#333,stroke-width:2px
    style D fill:#fcf,stroke:#333,stroke-width:2px
  • main.py: 入口点;运行代理工作流循环。
  • scripts/workflow.py: 定义 DatabaseWorkflow,协调LLM、工具选择和执行。
  • mcp/mcpserver.py: 实现MCP服务器公开数据库工具(CRUD、模式等)。
  • config/settings.py: 从环境变量加载Ollama(LLM)和数据库的配置。
  • config/prompts.py: 系统提示指导代理的行为。
  • Dockerfile和docker-compose.yml: 应用程序和PostgreSQL的容器化设置。

设置

1.Docker Compose(推荐)

确保你已经安装了Docker和Docker Compose。

git clone 
docker-compose up --build
  • 该应用程序将在 Agent_MCP_Server 集装箱。
  • PostgreSQL运行在 postgres_db 容器(默认用户: postgres,密码: postgres,db: testdb).
  • 您可以在中自定义环境变量 .env.docker.

2.手动设置

  • 安装Python 3.12+
  • 安装依赖项:
  pip install -r requirements.txt  # or use pyproject.toml with pip/uv
  • 确保PostgreSQL正在运行且可访问(请参阅 config/settings.py 默认值)。
  • 根据需要设置环境变量(请参见 .env.docker 例如)。
  • 启动MCP服务器和主工作流:
  # With Docker
  docker-compose exec -it app bash
  python main.py

  # Without Docker
  python main.py # This will spin up the server and initiate the workflow

用法

  • 启动时,代理将提示: What would you like to do?
  • 输入自然语言请求,例如:

- Show me all the tables in the database. - Add a new customer: 'Alice', 'alice@email.com', 25 to the customers table.

  • 代理人将:

1. 解释您的请求 1. 选择并调用适当的数据库工具 1. 返回结果

交互示例

What would you like to do? Show me all the tables in the database.
Tool: list_tables()
Output: The available tables are: customers, products, orders

目录结构

config/           # Prompts and settings
mcp/              # MCP server and database tool definitions
scripts/          # Workflow and event logic
main.py           # Entry point
Dockerfile        # App container
docker-compose    # Initiates the app, database and MCP server (Make sure ollama is serving)

依赖项

  • Python 3.12+
  • Calma-Index-LLMS-Ollama
  • mcp\[cli\]
  • mlflow
  • 奥拉马
  • psycopg2二进制
  • python dotenv
  • (参见 pyproject.toml 完整列表)

配置

  • Ollama LLM: 通过环境变量设置(请参见 config/settings.py).
  • 数据库: 通过环境变量设置(请参见 config/settings.py).

享受实验的乐趣

目录标签

目录标签

PostgreSQL自然语言处理模型集成数据库代理Python本地部署LLM集成工具驱动

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP