Skip to content

[BugFix] Wire database tools into MCP reference template execution (backport #1468) - #1561

Closed
mergify[bot] wants to merge 1 commit into
release/0.4.0from
mergify/bp/release/0.4.0/pr-1468
Closed

mergify[bot] wants to merge 1 commit into
release/0.4.0from
mergify/bp/release/0.4.0/pr-1468

Conversation

@mergify

@mergify mergify Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Automated backport of #1468 to release/0.4.0.

…1468)

* fix(mcp): wire db tool into reference template execution

- Connect `db_tool` to `reference_template_tool` in
  `ToolContextManager` and `DatusMCPServer` so rendered SQL executes
  consistently with Chat API agents.
- Remove the redundant `close_all` docstring in
  `ToolContextManager`.

* test(mcp): Override collaborative initialization of reference templates and database tools
- Override dynamic and static tool initialization paths in MCP service tests
- Verify that reference templates can execute rendered SQL and reuse database tool instances
- Ensure remaining available tools are retained when a tool is missing or fails to initialize

* test(mcp-server): import lightweight server in unit tests

* fix(mcp): defer pinned context cleanup during shutdown

- Update `ToolContextManager.close_all` in `datus/mcp_server.py` to drop
  cache ownership without immediate connector teardown, allowing active
  requests and workers to release contexts safely.
- Add regression coverage in `tests/unit_tests/test_mcp_server.py` for
  deferred connector cleanup and live-context draining after final release.

---------

Co-authored-by: 李长福 <lichangfu@pinpianyi.com>
(cherry picked from commit ab336ed)

# Conflicts:
#	tests/unit_tests/test_mcp_server.py
@mergify mergify Bot added the conflicts label Oct 29, 2026
@mergify

mergify Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of ab336ed has failed:

On branch mergify/bp/release/0.4.0/pr-1468
Your branch is up to date with 'origin/release/0.4.0'.

You are currently cherry-picking commit ab336ed.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   datus/mcp_server.py

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   tests/unit_tests/test_mcp_server.py

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae4518eb-024f-43cc-bf24-4813de4fc73b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

@github-actions

Copy link
Copy Markdown
Contributor

Test Audit Report

Mode: diff-only (P0 blocks, P1 warns)
Files scanned: 1

✅ No issues detected.

Static test-quality audit — rules from xUnit Test Patterns / Google Hermetic Tests / F.I.R.S.T. / Khorikov. Source: ci/audit_tests.py.

@mergify

mergify Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@mergify[bot]: Conflict detected, please resolve the conflict and resubmit the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant