### Execute QuickStart Installation Script Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart_demo.md Run this command in your terminal to download the necessary configuration files and start the demo services. ```bash /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/pgEdge/pgedge-postgres-mcp/main/examples/quickstart-demo/pgedge-ait-demo.sh)" ``` -------------------------------- ### QuickStart Demo Output and Service Status Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart_demo.md Example output showing the automated setup process, service health checks, and connection credentials. ```bash $ /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/pgEdge/pgedge-postgres-mcp/main/examples/quickstart-demo/pgedge-ait-demo.sh)" ℹ Creating workspace: /tmp/pgedge-download.28085 ℹ Downloading files ℹ → docker-compose.yml ℹ → .env.example ✓ Downloads complete pgEdge AI Toolkit Demo setup You need to specify an API key for Anthropic or OpenAI (or both) Anthropic API key (Leave blank to skip) › OpenAI API key (Leave blank to skip) › ✓ Wrote .env ℹ Starting services [+] Running 22/22 ✔ web-client Pulled 15.4s ✔ postgres Pulled 17.5s ✔ postgres-mcp Pulled 8.7s [+] Running 6/6 ✔ Network pgedge-download28085_pgedge-quickstart Created 0.0s ✔ Volume pgedge-download28085_postgres-data Created 0.0s ✔ Volume pgedge-download28085_mcp-data Created 0.0s ✔ Container pgedge-quickstart-db Healthy 6.4s ✔ Container pgedge-quickstart-mcp Healthy 11.2s ✔ Container pgedge-quickstart-web Started 11.3s ℹ Waiting for services to be healthy (this may take up to 60 seconds)... ✓ Services are ready ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ pgEdge AI Toolkit Demo is running! ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Web Client Interface: http://localhost:8081 Login: demo / demo123 PostgreSQL Database: Database: northwind User: demo / demo123 Connect: docker exec -it pgedge-quickstart-db psql -U demo -d northwind MCP Server API: http://localhost:8080 Bearer Token: demo-token-12345 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Workspace: /tmp/pgedge-download.28085 To stop: cd /tmp/pgedge-download.28085 && docker compose down -v ``` -------------------------------- ### MCP Server Startup Examples Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/configuration.md Examples demonstrating how to start the MCP server with different configuration methods. ```APIDOC ## MCP Server Startup Examples ### Description Examples demonstrating how to start the MCP server with different configuration methods, including environment variables, configuration files, and command-line flags. ### Example 1: HTTP Enabled with Command Line Flags ```bash # Environment has: PGEDGE_HTTP_ENABLED="true" ./bin/pgedge-postgres-mcp \ -http \ -addr ":3000" # Result: # - HTTP enabled: true (from command line, highest priority) # - Address: :3000 (from command line, highest priority) ``` ### Example 2: Environment Override ```bash # Config file has: http.address: ":8080" export PGEDGE_HTTP_ADDRESS=":9090" ./bin/pgedge-postgres-mcp # Result: # - Address: :9090 (environment overrides config file) ``` ### Example 3: Config File with Defaults ```bash # No command line flags, no environment variables # Config file has partial settings ./bin/pgedge-postgres-mcp -config myconfig.yaml # Result: # - Values from config file where present # - Hard-coded defaults for missing values ``` ### Example 4: Basic Server Start (Default Config) ```bash # Configure database connection via environment variables, config file, or flags ./bin/pgedge-postgres-mcp ``` ### Example 5: HTTP Server with Command Line Flags ```bash # Configure database connection via environment variables, config file, or flags ./bin/pgedge-postgres-mcp \ -http \ -addr ":9090" ``` ``` -------------------------------- ### Setup Semantic Search CLI Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/prompts.md Demonstrates setting up semantic search via the CLI to find information about pgAgent. Ensure the prompt name and query text are correctly formatted. ```bash /prompt setup-semantic-search query_text="What is pgAgent?" ``` -------------------------------- ### Configure and Start pgEdge MCP Server (Package Manager) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Create a user, set file permissions, and start the server in HTTP mode when installed via package manager. ```bash # Create a user account (runs and exits) sudo pgedge-postgres-mcp \ -config /etc/pgedge/postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set ownership for the user file sudo chown pgedge:pgedge /etc/pgedge/postgres-mcp-users.yaml # Start the server in HTTP mode pgedge-postgres-mcp \ -config /etc/pgedge/postgres-mcp.yaml \ -http -addr :8080 & # Connect the CLI export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... pgedge-nla-cli \ -mcp-mode http \ -mcp-url http://localhost:8080 ``` -------------------------------- ### Navigate to example directory Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/stdio-anthropic-chatbot.md Change the current working directory to the stdio-anthropic-chatbot example folder. ```bash cd examples/stdio-anthropic-chatbot ``` -------------------------------- ### Setup and Verify Ollama Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/provider_config.md Instructions for installing Ollama, pulling an embedding model, and verifying that the Ollama server is running. ```bash # Install Ollama from https://ollama.com/ # Pull embedding model ollama pull nomic-embed-text # Verify it's running curl http://localhost:11434/api/tags ``` -------------------------------- ### Configure Local Setup with Ollama Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/config-examples/cli-client.md Example configuration for a local setup using Ollama. Ensure Ollama is running and the specified model is pulled. ```yaml mcp: mode: stdio server_path: ./bin/pgedge-postgres-mcp server_config_path: ./bin/pgedge-postgres-mcp-stdio.yaml llm: provider: ollama model: llama3 ollama_url: http://localhost:11434 ``` ```bash # Make sure Ollama is running with the model pulled ollama pull llama3 ./bin/pgedge-nla-cli ``` -------------------------------- ### Docker Compose Setup Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Sets up and starts the pgEdge MCP service using Docker Compose. Requires cloning the repository and configuring the .env file. ```bash git clone \ https://github.com/pgEdge/pgedge-postgres-mcp.git cd pgedge-postgres-mcp cp .env.example .env # Edit .env and set the following variables: # - PGEDGE_DB_HOST, PGEDGE_DB_PORT, # PGEDGE_DB_NAME, PGEDGE_DB_USER, # PGEDGE_DB_PASSWORD # - PGEDGE_ANTHROPIC_API_KEY or # PGEDGE_OPENAI_API_KEY # - INIT_USERS=admin:password123 docker compose up -d ``` -------------------------------- ### Install and Run Linter Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/ci-cd.md Instructions for installing golangci-lint v1.x and executing linting commands. ```bash # Install latest v1.x version go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest # Verify installation golangci-lint version # Should show: golangci-lint has version v1.x.x ``` ```bash # Using Makefile (recommended - handles GOPATH/bin automatically) make lint # Direct invocation (if in PATH) golangci-lint run # Using full path $(go env GOPATH)/bin/golangci-lint run # Auto-fix issues golangci-lint run --fix ``` ```text Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1 ``` -------------------------------- ### Configure and Start pgEdge MCP Server (GitHub Release) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Initialize user accounts and start the server using binaries from a GitHub release. ```bash # Create a user account (runs and exits) ./pgedge-postgres-mcp \ -config ./postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set permissions for the user file chmod 640 ./postgres-mcp-users.yaml # Start the server in HTTP mode ./pgedge-postgres-mcp \ -config ./postgres-mcp.yaml \ -http -addr :8080 & # Connect the CLI export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... ./pgedge-nla-cli \ -mcp-mode http \ -mcp-url http://localhost:8080 ``` -------------------------------- ### Build and Start MCP Server Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/http-ollama-chatbot.md Builds the pgEdge MCP server binary and starts it in HTTP mode. Authentication is disabled for this example; use token-based or user-based authentication for production. ```bash cd ../.. go build -o bin/pgedge-postgres-mcp ./cmd/pgedge-pg-mcp-svr # Start the server in HTTP mode (with authentication disabled for this example) ./bin/pgedge-postgres-mcp -http -addr :8080 -no-auth ``` -------------------------------- ### Initialize Configuration Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/config-examples/kb-builder.md Create the configuration file from the provided example template. ```bash cp pgedge-nla-kb-builder.yaml.example pgedge-nla-kb-builder.yaml # Edit pgedge-nla-kb-builder.yaml to configure sources and embedding providers ``` -------------------------------- ### YAML Configuration File Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/cli-client.md Example structure for the .pgedge-nla-cli.yaml configuration file. ```yaml mcp: mode: stdio server_path: ./bin/pgedge-postgres-mcp server_config_path: ./bin/pgedge-postgres-mcp-stdio.yaml # For HTTP mode: # url: http://localhost:8080 # token: your-token-here llm: provider: anthropic # Options: anthropic, openai, or ollama model: claude-sonnet-4-20250514 # API keys (priority: env vars > key files > direct config values) # Option 1: Environment variables (recommended for development) # Option 2: API key files (recommended for production) anthropic_api_key_file: ~/.anthropic-api-key openai_api_key_file: ~/.openai-api-key # Option 3: Direct values (not recommended - use env vars or files) # anthropic_api_key: your-anthropic-key-here # openai_api_key: your-openai-key-here max_tokens: 4096 temperature: 0.7 ui: no_color: false display_status_messages: true # Show/hide status messages during tool execution render_markdown: true # Render markdown with formatting and syntax highlighting ``` -------------------------------- ### Initialize Configuration File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/deploy_docker.md Create the .env file from the provided example template. ```bash cp .env.example .env ``` -------------------------------- ### Verify CLI Setup Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Interact with the CLI client by asking a question to verify the setup and ensure it can list database tables. ```bash You: What tables are in my database? ``` -------------------------------- ### Download Demo Artifacts Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart_demo.md Download the docker-compose.yml and .env.example files for the quickstart demo. ```bash curl -fsSLO https://raw.githubusercontent.com/pgEdge/pgedge-postgres-mcp/main/examples/quickstart-demo/docker-compose.yml curl -fsSLO https://raw.githubusercontent.com/pgEdge/pgedge-postgres-mcp/main/examples/quickstart-demo/.env.example ``` -------------------------------- ### Install golangci-lint Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README.md Install the required linter version for the project. ```bash go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest ``` -------------------------------- ### Install golangci-lint Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/development.md Command to install the golangci-lint tool for Go development. ```bash go install github.com/golangci-lint/golangci-lint/cmd/golangci-lint@latest ``` -------------------------------- ### Create User and Start MCP Server (GitHub Release) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Creates a user account and starts the server in HTTP mode when using a GitHub release binary. Ensure the configuration file is accessible. ```bash # Create a user account (runs and exits) ./pgedge-postgres-mcp \ -config ./postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set permissions for the user file chmod 640 ./postgres-mcp-users.yaml # Start the server in HTTP mode ./pgedge-postgres-mcp \ -config ./postgres-mcp.yaml \ -http -addr :8080 ``` -------------------------------- ### Interaction example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/stdio-anthropic-chatbot.md Example of a user query and the resulting tool execution and response. ```text You: What tables are in my database? → Executing tool: get_schema_info Claude: You have 8 tables in your database: - users - products - orders - order_items - categories - reviews - inventory - shipments You: quit Goodbye! ``` -------------------------------- ### Start Server with Custom User File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/auth_user.md Start the server using the same custom user file path specified for user management. This ensures consistent authentication. ```bash ./bin/pgedge-postgres-mcp -http -user-file /my/custom/users.yaml ``` -------------------------------- ### Start CLI Client (Stdio Mode - Build from Source) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md After building from source, set the LLM API key and start the CLI client, using paths relative to the build directory. ```bash export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... ./bin/pgedge-nla-cli \ -mcp-mode stdio \ -mcp-server-path ./bin/pgedge-postgres-mcp \ -mcp-server-config ./bin/postgres-mcp.yaml ``` -------------------------------- ### Start CLI Client (Stdio Mode - GitHub Release) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Set the LLM API key and start the CLI client from a GitHub release, pointing to the local server binary and configuration file. ```bash export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... ./pgedge-nla-cli \ -mcp-mode stdio \ -mcp-server-path ./pgedge-postgres-mcp \ -mcp-server-config ./postgres-mcp.yaml ``` -------------------------------- ### Create User and Start MCP Server (Systemd) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Creates an admin user account and starts the pgEdge MCP server using systemd. This method is recommended for production environments. ```bash # Create a user account (runs and exits) sudo pgedge-postgres-mcp \ -config /etc/pgedge/postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set ownership for the user file sudo chown pgedge:pgedge /etc/pgedge/postgres-mcp-users.yaml # Start the MCP server (choose one method) # Option 1: Using systemctl (recommended) sudo systemctl start pgedge-postgres-mcp.service # Option 2: Manual start # pgedge-postgres-mcp \ # -config /etc/pgedge/postgres-mcp.yaml \ # -http -addr :8080 & # Start nginx sudo systemctl start nginx.service ``` -------------------------------- ### Build and Install SELinux Module Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Commands to compile, package, and install the SELinux policy, and apply file context labels to the binary and data directories. ```bash # Compile the policy checkmodule -M -m -o pgedge-postgres-mcp.mod pgedge-postgres-mcp.te semodule_package -o pgedge-postgres-mcp.pp -m pgedge-postgres-mcp.mod # Install the module semodule -i pgedge-postgres-mcp.pp # Label the binary semanage fcontext -a -t pgedge_mcp_exec_t '/usr/bin/pgedge-postgres-mcp' restorecon -v /usr/bin/pgedge-postgres-mcp # Label data directories semanage fcontext -a -t var_lib_t '/var/lib/pgedge/nla-server(/.*)?' restorecon -Rv /var/lib/pgedge/nla-server ``` -------------------------------- ### Start pgEdge MCP Server Demo Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/examples/codespaces-demo/README.md Run this script to start the pgEdge MCP Server demo in Codespaces. It may prompt for API keys if not set as secrets. ```bash ./examples/codespaces-demo/start.sh ``` -------------------------------- ### Start CLI Client (Stdio Mode - pgEdge Packages) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Set the LLM API key and start the CLI client in stdio mode, specifying the MCP server path and configuration file. ```bash export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... pgedge-nla-cli \ -mcp-mode stdio \ -mcp-server-path /usr/bin/pgedge-postgres-mcp \ -mcp-server-config /etc/pgedge/postgres-mcp.yaml ``` -------------------------------- ### CLI Prompt Execution Examples Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/prompts.md Provides examples of various prompt invocations from the CLI, including designing a database schema, diagnosing issues, exploring the database, and setting up semantic search. ```bash # Design a database schema /prompt design-schema requirements="User management with roles and permissions" ``` ```bash # Diagnose issue /prompt diagnose-query-issue issue_description="table not found" ``` ```bash # Explore database /prompt explore-database ``` ```bash # Setup semantic search /prompt setup-semantic-search query_text="What is PostgreSQL?" ``` -------------------------------- ### Initialize Configuration File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/provider_config.md Copy the example configuration file to the binary directory and prepare it for use. ```bash # Copy the example to the binary directory cp configs/postgres-mcp.yaml.example bin/postgres-mcp.yaml # Edit with your settings vim bin/postgres-mcp.yaml # Run the server (automatically loads config from default location) ./bin/pgedge-postgres-mcp ``` -------------------------------- ### LLM Provider Integration Test Setup Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/testing.md Set up and run integration tests with Ollama LLM provider. This involves installing Ollama, starting the server, pulling a model, and configuring database connection environment variables before running the main executable. ```bash # 1. Install Ollama # Visit https://ollama.ai/ # 2. Start Ollama ollama serve # 3. Pull a small model (optional, ~600MB) ollama pull tinyllama:1.1b # 4. Test with a real database connection export LLM_PROVIDER="ollama" export OLLAMA_MODEL="tinyllama:1.1b" # Configure database connection via environment variables before starting export PGHOST="localhost" export PGPORT="5432" export PGDATABASE="mydb" export PGUSER="myuser" export PGPASSWORD="mypass" ./bin/pgedge-postgres-mcp ``` -------------------------------- ### Build from Source and Start MCP Server Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Builds the pgEdge MCP server from source, creates a user, and starts the server in HTTP mode. Requires Make and a C/C++ compiler. ```bash make build # Create a user account (runs and exits) ./bin/pgedge-postgres-mcp \ -config ./bin/postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set permissions for the user file chmod 640 ./postgres-mcp-users.yaml # Start the server in HTTP mode ./bin/pgedge-postgres-mcp \ -config ./bin/postgres-mcp.yaml \ -http -addr :8080 ``` -------------------------------- ### Start Ollama Service Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/http-ollama-chatbot.md Starts the Ollama service. This usually runs automatically after installation. ```bash ollama serve ``` -------------------------------- ### Install Prerequisites Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/config-examples/kb-builder.md Pull the required embedding model for Ollama. ```bash # For Ollama (optional) ollama pull nomic-embed-text ``` -------------------------------- ### Initialize and Start the Web Client Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/web/README.md Commands to copy configuration files, edit settings, create a user, and launch the web client environment. ```bash # 1. Copy example config files from the project root cp examples/pgedge-postgres-mcp-http.yaml.example bin/pgedge-postgres-mcp-http.yaml cp examples/pgedge-postgres-mcp-users.yaml.example bin/pgedge-postgres-mcp-users.yaml cp examples/pgedge-postgres-mcp-tokens.yaml.example bin/pgedge-postgres-mcp-tokens.yaml # 2. Edit the config file with your database connection and LLM settings nano bin/pgedge-postgres-mcp-http.yaml # 3. Create a user for web login (will prompt for password) ./bin/pgedge-postgres-mcp user add --username myuser --annotation "My User" # 4. Start the web client ./start_web_client.sh ``` -------------------------------- ### Copy Example Configuration File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/deploy_source.md Copy the sample `.env.example` file to `bin/postgres-mcp.yaml` to create your deployment configuration. ```bash cp .env.example bin/postgres-mcp.yaml ``` -------------------------------- ### Build and Run from Source Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Compile the project from source and initialize the server. ```bash make build # Create a user account (runs and exits) ./bin/pgedge-postgres-mcp \ -config ./bin/postgres-mcp.yaml \ -add-user \ -username admin -password secret123 # Set permissions for the user file chmod 640 ./postgres-mcp-users.yaml # Start the server in HTTP mode ./bin/pgedge-postgres-mcp \ -config ./bin/postgres-mcp.yaml \ -http -addr :8080 & # Connect the CLI export PGEDGE_ANTHROPIC_API_KEY=sk-ant-... ./bin/pgedge-nla-cli \ -mcp-mode http \ -mcp-url http://localhost:8080 ``` -------------------------------- ### Install Python Dependencies Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/http-ollama-chatbot.md Installs Python dependencies from requirements.txt. Ensure Python 3.10+ is installed. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Python Requests Library Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/client-examples.md Install the 'requests' library, which is a prerequisite for the Python client. This command uses pip for installation. ```bash pip install requests ``` -------------------------------- ### Enable Setup Semantic Search Prompt Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/configuration.md Set `builtins.prompts.setup_semantic_search` to true to enable the setup-semantic-search prompt. Defaults to true. ```text builtins.prompts.setup_semantic_search: true ``` -------------------------------- ### Complete Knowledgebase Builder Configuration Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/config-examples/kb-builder.md A comprehensive template demonstrating all available configuration options for the builder tool. ```yaml ## The kb-builder tool processes documentation from multiple sources (Git repos, # local paths) and builds a searchable SQLite database with vector embeddings. # # Configuration Priority (highest to lowest): # 1. Command line flags (--database, --config) # 2. Configuration file values (this file) # 3. Hard-coded defaults # # Copy this file to pgedge-nla-kb-builder.yaml and customize as needed. # By default, kb-builder looks for config in the same directory as the binary. # ============================================================================ # OUTPUT DATABASE CONFIGURATION # ============================================================================ # Path to the output SQLite knowledgebase database # Default: pgedge-nla-kb.db in same directory as config file # Command line flag: --database or -d database_path: "pgedge-nla-kb.db" # ============================================================================ # DOCUMENTATION SOURCE DIRECTORY # ============================================================================ # Directory for storing downloaded/processed documentation # Git repositories will be cloned here # Default: doc-source in same directory as config file doc_source_path: "doc-source" # ============================================================================ # DOCUMENTATION SOURCES # ============================================================================ # List of documentation sources to process ``` -------------------------------- ### Install Delve Debugger Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/development.md Command to install the Delve debugger for Go. ```bash go install github.com/go-delve/delve/cmd/dlv@latest ``` -------------------------------- ### Create and Navigate to Demo Directory Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart_demo.md Use these commands to create a new directory for the demo and change into it. ```bash mkdir ~/pgedge-ait-demo cd ~/pgedge-ait-demo ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/web/README.md Install required project dependencies using npm. ```bash npm install ``` -------------------------------- ### Clone and Setup Project Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/development.md Clones the pgEdge repository and downloads its Go module dependencies. ```bash git clone https://github.com/pgEdge/pgedge-postgres-mcp.git cd pgedge-postgres-mcp go mod download ``` -------------------------------- ### Build the Project Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README.md Clone the repository and compile the server. ```bash git clone https://github.com/pgEdge/pgedge-postgres-mcp.git cd pgedge-postgres-mcp make build ``` -------------------------------- ### Create documentation directory Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/advanced/custom-knowledgebase-tutorial.md Initializes the directory structure for storing project documentation. ```bash mkdir -p ~/my-project/docs ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart_demo.md Start all the services defined in the docker-compose.yml file. ```bash docker compose up ``` -------------------------------- ### View and Configure Custom Definitions Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/advanced/custom-definitions.md Commands to inspect the example definitions file and set the configuration path. ```bash # View the example file cat examples/pgedge-postgres-mcp-custom.yaml # Use it in your configuration custom_definitions_path: "./examples/pgedge-postgres-mcp-custom.yaml" ``` -------------------------------- ### Install Web Dependencies Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/web/README.md Commands to install required npm packages for the web client. ```bash cd web npm install ``` -------------------------------- ### Installation Directory Layout Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Visual representation of the expected file system structure after installation. ```text /etc/pgedge/ ├── nla-server.yaml # Server config ├── nla-server.env # Server environment (optional) ├── nla-cli.yaml # CLI config (optional) └── custom-definitions.yaml # Custom prompts/resources (optional) /usr/bin/ ├── pgedge-postgres-mcp # Server binary └── pgedge-nla-cli # CLI binary /usr/lib/systemd/system/ ├── pgedge-postgres-mcp.service # Server systemd unit └── pgedge-nla-web.service # Web UI systemd unit (optional) /usr/share/pgedge/ ├── nla-kb/ # Knowledgebase (optional package) │ └── kb.db # Pre-built knowledgebase database └── nla-web/ # Web UI files ├── index.html └── assets/ /etc/nginx/sites-available/ └── pgedge-nla-web # Nginx config /var/lib/pgedge/ └── nla-server/ # Server data/state (PGEDGE_DATA_DIR) ├── tokens.json # API authentication tokens ├── users.json # User credentials └── conversations.db # Conversation history (SQLite) /var/log/pgedge/ └── nla-server/ # Server logs (if file logging enabled) /usr/share/doc/ ├── pgedge-postgres-mcp/ │ ├── README.md │ └── LICENSE ├── pgedge-nla-cli/ │ ├── README.md │ └── LICENSE ├── pgedge-nla-web/ │ ├── README.md │ └── LICENSE ├── pgedge-nla-kb/ │ ├── README.md │ ├── LICENSE │ └── VERSION ``` -------------------------------- ### Start Development Server Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/web/README.md Commands to launch the development environment using either a startup script or manual terminal commands. ```bash # Option 1: Use the startup script (recommended - starts both MCP server and Vite) cd .. ./start_web_client.sh # Option 2: Manual startup in separate terminals # Terminal 1: Start MCP server ./bin/pgedge-postgres-mcp --config bin/pgedge-pg-mcp-web.yaml # Terminal 2: Start Vite dev server (frontend) cd web npm run dev ``` -------------------------------- ### Install CLI Client (Debian/Ubuntu) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Install the pgedge-nla-cli package on Debian or Ubuntu systems using apt-get. ```bash # Debian/Ubuntu: sudo apt-get install -y pgedge-nla-cli ``` -------------------------------- ### Install pgEdge MCP via RHEL/Rocky/Alma Linux Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Use these commands to install the package on RHEL-based systems. ```bash sudo dnf install -y \ https://dnf.pgedge.com/reporpm/pgedge-release-latest.noarch.rpm sudo dnf install -y pgedge-postgres-mcp ``` -------------------------------- ### Install pgEdge MCP via Debian/Ubuntu Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Use these commands to install the package on Debian or Ubuntu systems. ```bash sudo apt-get update sudo apt-get install -y curl gnupg2 lsb-release sudo curl -sSL \ https://apt.pgedge.com/repodeb/pgedge-release_latest_all.deb \ -o /tmp/pgedge-release.deb sudo dpkg -i /tmp/pgedge-release.deb rm -f /tmp/pgedge-release.deb sudo apt-get update sudo apt-get install -y pgedge-postgres-mcp ``` -------------------------------- ### Run MCP Server with Configuration File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/configuration.md Starts the server using settings from a specified configuration file. ```bash ./bin/pgedge-postgres-mcp -config myconfig.yaml ``` -------------------------------- ### Install and Manage Helm Chart Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-DOCKER.md Commands for installing, upgrading, and uninstalling the pgEdge NLA Helm chart. ```bash # Install from local chart helm install pgedge-nla examples/helm/pgedge-nla \ --namespace pgedge \ --create-namespace \ --set secrets.postgresPassword="your-secure-password" \ --set secrets.anthropicApiKey="your-api-key" # Install with production values helm install pgedge-nla examples/helm/pgedge-nla \ --namespace pgedge \ --create-namespace \ -f examples/helm/pgedge-nla/values-production.yaml # Upgrade helm upgrade pgedge-nla examples/helm/pgedge-nla \ --namespace pgedge \ -f values.yaml # Uninstall helm uninstall pgedge-nla --namespace pgedge ``` -------------------------------- ### Start Docker Compose Deployment Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/advanced/distributed-deployment.md Command to start the multi-instance MCP server deployment defined in docker-compose.yml. ```bash docker-compose up -d ``` -------------------------------- ### Build KnowledgeBase Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/config-examples/kb-builder.md Execute the builder using the specified configuration file. ```bash ./pgedge-nla-kb-builder --config pgedge-nla-kb-builder.yaml ``` -------------------------------- ### Use CLI Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Commands to set the authentication token and launch the CLI chat interface. ```bash # Set API token export PGEDGE_MCP_TOKEN="your-token-here" # Start chat pgedge-pg-mcp-cli ``` -------------------------------- ### Install CLI Client (RHEL/Rocky) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Install the pgedge-nla-cli package on RHEL or Rocky Linux systems using dnf. ```bash # RHEL/Rocky: sudo dnf install -y pgedge-nla-cli ``` -------------------------------- ### Example Schema Info Output Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/tools.md This is an example of the TSV output format for the get_schema_info tool when querying a specific table. ```text Database: postgres://user@localhost/mydb schema table type table_desc column data_type nullable col_desc is_pk is_unique fk_ref is_indexed identity default is_vector vector_dims public users TABLE User accounts id bigint NO Primary key true false true a false 0 public users TABLE User accounts email text NO User email false true true false 0 public users TABLE User accounts created_at timestamptz YES false false false now() false 0 ``` -------------------------------- ### Manage Development Deployment Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-DOCKER.md Standard commands to start, monitor, and stop the development stack. ```bash # Start the stack docker-compose up -d # View logs docker-compose logs -f # Stop the stack docker-compose down ``` -------------------------------- ### Start PostgreSQL Service Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/cursor.md Start the PostgreSQL service using `systemctl` if `pg_isready` indicates it's not accepting connections. ```bash sudo systemctl start postgresql ``` -------------------------------- ### MCP Server JSON-RPC Response Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/client-examples.md This is an example of a JSON-RPC 2.0 response from the MCP server containing a text result. ```json { "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "PostgreSQL 17.0 on x86_64" } ] } } ``` -------------------------------- ### MCP Server JSON-RPC Request Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/client-examples.md This is an example of a JSON-RPC 2.0 request to the MCP server to execute the 'query_database' tool. ```json { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "query_database", "arguments": { "query": "SELECT version()" } } } ``` -------------------------------- ### Set up environment variables Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/examples/stdio-anthropic-chatbot/README.md Configure the Anthropic API key and PostgreSQL connection details. ```bash # Required: Your Anthropic API key export ANTHROPIC_API_KEY="sk-ant-..." # Required: Database connection configuration # The server connects to the database at startup using PostgreSQL environment variables export PGHOST="localhost" export PGPORT="5432" export PGDATABASE="mydb" export PGUSER="myuser" export PGPASSWORD="mypass" # Or use ~/.pgpass file for better security ``` -------------------------------- ### Execute Post-Install Script Actions Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Commands to set file ownership and permissions for the web UI directory. ```bash # Set ownership chown -R root:root /usr/share/pgedge/nla-web chmod 755 /usr/share/pgedge/nla-web find /usr/share/pgedge/nla-web -type f -exec chmod 644 {} \; find /usr/share/pgedge/nla-web -type d -exec chmod 755 {} \; # Note: Do NOT enable/start the service automatically # Users should configure Nginx or their preferred web server echo "Web UI installed to /usr/share/pgedge/nla-web" echo "Configure Nginx: ln -s /etc/nginx/sites-available/pgedge-nla-web /etc/nginx/sites-enabled/" ``` -------------------------------- ### Install AppArmor Profile Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Installs and loads the AppArmor profile for pgedge-postgres-mcp if AppArmor is enabled. It also attempts to enable the profile on boot. ```bash if [ -x /sbin/apparmor_parser ] && [ -d /etc/apparmor.d ]; then # Load the profile /sbin/apparmor_parser -r /etc/apparmor.d/usr.bin.pgedge-postgres-mcp 2>/dev/null || true # Enable the profile on boot if [ -d /etc/apparmor.d/force-complain ]; then ln -sf /etc/apparmor.d/usr.bin.pgedge-postgres-mcp \ /etc/apparmor.d/force-complain/ 2>/dev/null || true fi fi ``` -------------------------------- ### Retrieve online help Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/help.md Use the -help flag to display a list of available command-line options. ```bash bin/pgedge-postgres-mcp -help ``` -------------------------------- ### LLM Proxy Configuration Example Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/advanced/llm-proxy.md Example YAML configuration for the LLM proxy, specifying provider, model, and API key settings. ```yaml llm: provider: "openai" model: "gpt-4o" api_key: "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ``` -------------------------------- ### Post-Install Database Configuration Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/README-PACKAGING.md Sets ownership, permissions, and verifies the integrity of the knowledgebase database. ```bash # Set ownership and permissions chown -R root:root /usr/share/pgedge/nla-kb chmod 755 /usr/share/pgedge/nla-kb chmod 644 /usr/share/pgedge/nla-kb/kb.db # Verify database integrity (optional) if command -v sqlite3 >/dev/null 2>&1; then sqlite3 /usr/share/pgedge/nla-kb/kb.db "PRAGMA integrity_check;" >/dev/null 2>&1 || { echo "Warning: Knowledgebase database may be corrupted" } fi ``` -------------------------------- ### Get Compact Table List Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/reference/tools.md Set `compact` to `true` to get a quick overview of table names without column details. ```json { "compact": true } ``` -------------------------------- ### Install pgEdge Web Client (Debian/Ubuntu) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Installs the Web client package on Debian or Ubuntu systems. Ensure the pgEdge repository is configured. ```bash # Debian/Ubuntu: sudo apt-get install -y pgedge-nla-web ``` -------------------------------- ### Install pgEdge CLI via Package Manager Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Use system package managers to install the CLI client on Debian/Ubuntu or RHEL/Rocky systems. ```bash # Debian/Ubuntu: sudo apt-get install -y pgedge-nla-cli # RHEL/Rocky: sudo dnf install -y pgedge-nla-cli ``` -------------------------------- ### Development and Production Startup Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/auth_token.md Commands for running the server in local development or secure production modes. ```bash # Use -no-auth for local development (localhost only) ./bin/pgedge-postgres-mcp -http -addr "localhost:8080" -no-auth ``` ```bash # Always use authentication with HTTPS ./bin/pgedge-postgres-mcp -http -tls \ -cert /path/to/cert.pem \ -key /path/to/key.pem ``` -------------------------------- ### Install pgEdge Web Client (RHEL/Rocky) Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Installs the Web client package on RHEL or Rocky Linux systems. Ensure the pgEdge repository is configured. ```bash # RHEL/Rocky: sudo dnf install -y pgedge-nla-web ``` -------------------------------- ### Install pgEdge NLA with Production Values Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/examples/helm/pgedge-nla/README.md Installs the pgEdge Natural Language Agent using a specified production values file for enhanced configuration. ```bash helm install pgedge-nla ./pgedge-nla \ --namespace pgedge \ --create-namespace \ -f values-production.yaml ``` -------------------------------- ### Verify Configuration File Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/troubleshooting.md Check for the existence of the configuration file, start the server with an explicit path, and ensure correct file permissions. ```bash # Check if config file exists ls -la bin/postgres-mcp.yaml # Use explicit path ./bin/pgedge-postgres-mcp -config /full/path/to/config.yaml # Check file permissions chmod 600 bin/postgres-mcp.yaml # Should be readable ``` -------------------------------- ### List and Select Databases Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/client-examples.md Demonstrates listing all accessible databases and then switching the client's context to a different database without invalidating the current session. ```python databases = client.list_databases() print(f"Current: {databases['current']}") for db in databases["databases"]: print(f" - {db['name']} ({db['host']})") result = client.select_database("staging") print(f"Switched to: {result['current']}") ``` -------------------------------- ### Start the CLI Client Source: https://context7.com/pgedge/pgedge-postgres-mcp/llms.txt Launch the CLI client in stdio or HTTP mode, or via direct configuration. ```bash # Stdio mode (recommended for single user) ./start_cli_stdio.sh # HTTP mode (for multi-user or remote access) ./start_cli_http.sh # Direct invocation with configuration ./bin/pgedge-nla-cli \ -mcp-mode stdio \ -llm-provider anthropic \ -llm-model claude-sonnet-4-20250514 # With API key from environment export ANTHROPIC_API_KEY="sk-ant-..." ./bin/pgedge-nla-cli ``` -------------------------------- ### Get User Info API Request Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/developers/api-reference.md HTTP GET request to retrieve information about the authenticated user. Requires an Authorization header with a session token. ```http GET /api/user/info HTTP/1.1 Authorization: Bearer ``` -------------------------------- ### Build from Source Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/guide/quickstart.md Commands to clone the repository and compile the binary. ```bash git clone \ https://github.com/pgEdge/pgedge-postgres-mcp.git cd pgedge-postgres-mcp make build ``` -------------------------------- ### Install and Configure Pre-Commit Hook Source: https://github.com/pgedge/pgedge-postgres-mcp/blob/main/docs/contributing/ci-cd.md Bash script to install a pre-commit hook that runs Go tests and linting before each commit. Includes fallback for finding the linter. ```bash #!/bin/bash set -e echo "Running tests..." go test ./... echo "Running linter..." # Try PATH first, then GOPATH/bin if command -v golangci-lint >/dev/null 2>&1; then golangci-lint run elif [ -f "$(go env GOPATH)/bin/golangci-lint" ]; then $(go env GOPATH)/bin/golangci-lint run else echo "Warning: golangci-lint not found, skipping linter" fi echo "All checks passed!" ```