Skip to content

docs: MCP server#1122

Merged
MicBun merged 1 commit intomainfrom
docs/mcp-server
Aug 25, 2025
Merged

docs: MCP server#1122
MicBun merged 1 commit intomainfrom
docs/mcp-server

Conversation

@williamrusdyputra
Copy link
Contributor

@williamrusdyputra williamrusdyputra commented Aug 25, 2025

resolves: https://github.com/trufnetwork/truf-network/issues/1121

Summary by CodeRabbit

  • Documentation
    • Added an MCP Server section with a link to learn how to query TRUF.NETWORK data through AI clients.
    • Published a step-by-step guide for setting up and using the TRUF.NETWORK Postgres MCP server with AI clients (currently Claude Desktop), covering prerequisites, OS-specific setup, installation, available tools, troubleshooting, and uninstall instructions.

@williamrusdyputra williamrusdyputra self-assigned this Aug 25, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

Added a new MCP Server section to README and introduced a new docs/mcp-server.md detailing setup and usage of the TRUF.NETWORK Postgres MCP server with AI clients (Claude Desktop), including prerequisites, installation, tools, troubleshooting, and uninstall steps.

Changes

Cohort / File(s) Summary
README update
README.md
Inserted “MCP Server” section with a brief description and link to docs/mcp-server.md, placed after SDK features and before Development Guide.
New MCP documentation
docs/mcp-server.md
Added end-to-end guide for TRUF.NETWORK Postgres MCP server: prerequisites, OS-specific installs, setup via postgres-mcp, tool list, troubleshooting, and uninstall.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User as User (Claude Desktop)
    participant Claude as AI Client
    participant MCP as TRUF.NETWORK Postgres MCP Server
    participant DB as Kwil/Postgres

    User->>Claude: Ask to query TRUF.NETWORK data
    Claude->>MCP: Invoke MCP tools (list_schemas, execute_sql, ...)
    MCP->>DB: Connect and run SQL
    DB-->>MCP: Results / errors
    MCP-->>Claude: Structured response
    Claude-->>User: Present findings

    rect rgb(235, 245, 255)
    note over Claude,MCP: Configuration via install.sh and Claude config
    end
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Assessment against linked issues

Objective Addressed Explanation
Document MCP server integration for clients (#1121)

Poem

A whisk of ears, a hop of cheer—
I linked the docs so all is clear!
From Claude to MCP we bound,
Into Kwil’s burrow, data found.
Thump-thump feet, queries fly—
Carrots of insight pile high. 🥕✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch docs/mcp-server

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@holdex
Copy link

holdex bot commented Aug 25, 2025

Time Submission Status

Member Status Time Action Last Update
williamrusdyputra ✅ Submitted 30min Update time Aug 25, 2025, 10:01 AM
MicBun ✅ Submitted 15min Update time Aug 25, 2025, 10:02 AM

@williamrusdyputra williamrusdyputra changed the title docs: mcp server docs: MCP server Aug 25, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (13)
docs/mcp-server.md (12)

5-8: Polish heading and fix grammar; clarify multi-client stance.

Rename the section and rephrase the note to read more naturally.

-## Current Supported AI Client
-1. Claude Desktop
-
-Please inquiry for another client support.
+## Supported AI clients
+1. Claude Desktop
+
+For other clients, please inquire or open an issue.

12-16: Tighten prerequisite phrasing and consistency.

Add articles, use parallel structure, and clarify intent.

-1. **Local Kwil Node** - Running TRUF.NETWORK node
-2. **Python 3.12+** - Required for MCP server
-3. **pipx** - For isolated installation
-4. **Claude Desktop** - For AI integration
+1. **Local Kwil node** — a running TRUF.NETWORK node
+2. **Python 3.12+** — required to run the MCP server
+3. **pipx** — for isolated installation
+4. **Claude Desktop** — for AI integration

19-27: macOS: mention restarting the shell after ensurepath.

pipx modifies PATH; users often miss the need to restart/reload the shell.

 pipx ensurepath
+## Open a new terminal (or `exec $SHELL -l`) so PATH changes take effect

29-37: Linux: provide a fallback for Python 3.12 and venv; verify availability.

On many Ubuntu/Debian releases, apt install python3.12 may not exist without extra repos. Suggest adding python3.12-venv and a fallback note.

-# Install Python 3.12+
-sudo apt update && sudo apt install python3.12
+# Install Python 3.12+ (ensure your distro provides this package)
+sudo apt update && sudo apt install -y python3.12 python3.12-venv || echo "If not available, consider using the Deadsnakes PPA or pyenv."
 
 # Install pipx
-python3 -m pip install --user pipx
-python3 -m pipx ensurepath
+python3 -m pip install --user pipx
+python3 -m pipx ensurepath
+## Open a new terminal so PATH changes take effect

To confirm the best instruction for your target distros, please verify whether Ubuntu 22.04/24.04 provide python3.12 in the default repos and whether recommending Deadsnakes is acceptable for your docs.


39-48: Windows: align pipx invocation with Windows conventions and add PATH note.

Use the py launcher and mention restarting the shell. Optionally suggest Chocolatey install for pipx.

-# Install pipx
-python -m pip install --user pipx
-python -m pipx ensurepath
+# Install pipx
+py -m pip install --user pipx
+py -m pipx ensurepath
+:: Close and reopen your terminal so PATH changes take effect
+:: (Alternatively: `choco install pipx`)

50-52: Fix markdownlint MD034 (bare URL).

Replace the bare URL with a markdown link.

-Download from https://claude.ai/download
+Download from [claude.ai/download](https://claude.ai/download)

55-61: Call out OS support for install.sh; specify Windows approach.

install.sh implies Unix-like environments. Clarify Windows instructions (e.g., Git Bash/WSL) or provide a PowerShell alternative if available.

-./install.sh
+./install.sh
+# On Windows:
+# - Use Git Bash or WSL to run install.sh, or
+# - If a PowerShell script is provided, run: `powershell -ExecutionPolicy Bypass -File .\install.ps1`

If there is a Windows-native installer/script in the postgres-mcp repo, reference it explicitly; otherwise, note Git Bash/WSL as the recommended path.


62-64: Improve configuration sentence for clarity.

-   - Database connection details (default: localhost:5432/kwild), just use the default if you didn't custom anything.
+   - Database connection details (default: host=localhost, port=5432, database=kwild).
+     If you haven't customized your setup, accept the defaults.

69-77: Add a security note: run with a read-only DB role when possible.

Executing SQL from an AI client can be risky. Recommend least-privilege credentials and provide a quick-start snippet.

 - `execute_sql` - Run basic SQL queries, including getting records, checking stream type, taxonomies, etc.
 - `get_index` - Get stream index data
 - `get_index_change` - Calculate percentage changes
+
+### Security best practices
+- Use a dedicated, least-privilege Postgres role for MCP (prefer read-only wherever possible).
+- Avoid connecting with superuser credentials.
+
+Example (Postgres):
+```sql
+-- Create a read-only role and grant minimal privileges
+CREATE ROLE mcp_reader LOGIN PASSWORD '<strong-unique-password>';
+GRANT CONNECT ON DATABASE kwild TO mcp_reader;
+GRANT USAGE ON SCHEMA public TO mcp_reader;
+GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_reader;
+ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO mcp_reader;
+```

80-84: Clarify networking language and add a common Postgres gotcha.

“from local” is awkward; also mention pg_hba.conf and service status.

-**Connection issues:**
-- Verify your Kwil node is running
-- Check database credentials
-- Ensure PostgreSQL port 5432 is accessible from local
+**Connection issues:**
+- Verify your Kwil node is running.
+- Check database credentials (host, port, db, user, password).
+- Ensure PostgreSQL port 5432 is accessible from localhost/your machine.
+- On Postgres, confirm `pg_hba.conf` allows local connections for the MCP user and restart Postgres after changes.

85-88: Add OS-specific config locations for Claude Desktop.

The current path is macOS-only. Include Windows and Linux paths if applicable.

-**Claude integration:**
-- Restart Claude Desktop after installation
-- Check config file: `~/Library/Application Support/Claude/claude_desktop_config.json`
+**Claude integration:**
+- Restart Claude Desktop after installation.
+- Check the config file:
+  - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
+  - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
+  - Linux: `~/.config/Claude/claude_desktop_config.json` (if applicable)

Please verify the exact Windows/Linux paths for the current Claude Desktop builds and update accordingly.


91-93: Uninstall: mention config cleanup and client restart.

Users may expect complete removal.

 ```bash
 pipx uninstall postgres-mcp

+Optionally remove the MCP configuration file and restart Claude Desktop to clear cached settings.


</blockquote></details>
<details>
<summary>README.md (1)</summary><blockquote>

`53-56`: **Optional: add to TOC and mirror style.**

If you maintain a Table of Contents, consider adding “MCP Server” there. Also consider sentence-case for “AI clients” to match surrounding style.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

**💡 Knowledge Base configuration:**

- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 993e96900e00b61bcf653828964d4c8c16d8b43b and 69c1a0dbcbb8cc9a9777c470b0c4435dd862e473.

</details>

<details>
<summary>📒 Files selected for processing (2)</summary>

* `README.md` (1 hunks)
* `docs/mcp-server.md` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/mcp-server.md</summary>

[grammar] ~12-~12: There might be a mistake here.
Context: ... Kwil Node** - Running TRUF.NETWORK node 2. **Python 3.12+** - Required for MCP server...

(QB_NEW_EN)

---

[grammar] ~13-~13: There might be a mistake here.
Context: ...Python 3.12+** - Required for MCP server 3. **pipx** - For isolated installation 4. **...

(QB_NEW_EN)

---

[grammar] ~14-~14: There might be a mistake here.
Context: ... 3. **pipx** - For isolated installation 4. **Claude Desktop** - For AI integration  #...

(QB_NEW_EN)

---

[grammar] ~50-~50: There might be a mistake here.
Context: ...pipx ensurepath ```  **Claude Desktop:** Download from https://claude.ai/download...

(QB_NEW_EN)

---

[grammar] ~80-~80: There might be a mistake here.
Context: ...## Troubleshooting  **Connection issues:** - Verify your Kwil node is running - Check...

(QB_NEW_EN)

---

[grammar] ~85-~85: There might be a mistake here.
Context: ...ssible from local  **Claude integration:** - Restart Claude Desktop after installatio...

(QB_NEW_EN)

</details>

</details>
<details>
<summary>🪛 markdownlint-cli2 (0.17.2)</summary>

<details>
<summary>docs/mcp-server.md</summary>

51-51: Bare URL used

(MD034, no-bare-urls)

</details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)</summary>

* GitHub Check: acceptance-test

</details>

<details>
<summary>🔇 Additional comments (1)</summary><blockquote>

<details>
<summary>README.md (1)</summary><blockquote>

`53-56`: **LGTM: succinct README entry with correct relative link.**

The new section is well placed between SDK features and the Development Guide. Link resolves to `./docs/mcp-server.md`.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Copy link
Member

@MicBun MicBun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@MicBun MicBun merged commit 190c298 into main Aug 25, 2025
8 of 10 checks passed
@MicBun MicBun deleted the docs/mcp-server branch August 25, 2025 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants