Skip to content

refactor(mcp): reuse app layer and add schema discovery tools - #82

Merged
zx06 merged 3 commits into
mainfrom
cursor/mcp-app-schema-tools-ad5b
Oct 10, 2026
Merged

zx06 merged 3 commits into
mainfrom
cursor/mcp-app-schema-tools-ad5b

Conversation

@zx06

@zx06 zx06 commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

摘要(中文)

本 PR 改进 xsql MCP Server 的两块能力:

  1. 复用 internal/app:query 不再在 internal/mcp 内重复建连/SSH,profile 的 skip_host_key 等与 CLI/Web 一致;保留 RFC 0014 写入双重授权、JSON 契约与 stats。
  2. Schema discovery tools:新增 schema_list_tables、schema_dump、schema_describe_table,输出与 CLI JSON 契约一致。

Follow-up(同 PR 后续提交):补充 schema MCP 单元测试(injectable schemaApp hooks)、E2E 自建表 fixture、Sonar 重复字面量修复,满足 Codecov patch ≥80%。

Testing

  • go test ./...
  • go test -tags=integration ./tests/integration/... (MySQL 8 / PG 16)
  • go test -tags=e2e ./tests/e2e/...
  • golangci-lint run ./...
  • internal/mcp package coverage 93.6%(schema_tools.go handlers 100%)
Open in Web Open in Cursor 

cursoragent and others added 2 commits October 10, 2026 06:12
MCP query now uses app.ResolveProfile and app.Query instead of duplicating
connection and SSH setup. Export app.SSHOptionsForProfile for shared SSH
option resolution (including profile skip_host_key). Add consistency unit tests.

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
Expose schema_list_tables, schema_dump, and schema_describe_table MCP tools
via internal/app with standard JSON envelopes. Update ai.md, cli-spec, README,
skill files, and MCP e2e coverage for MySQL 8 and PostgreSQL 16.

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.39583% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.35%. Comparing base (8e71dd4) to head (9d8ce63).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
internal/mcp/schema_tools.go 96.99% 2 Missing and 2 partials ⚠️
internal/mcp/tools.go 97.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   83.25%   84.35%   +1.10%     
==========================================
  Files          65       67       +2     
  Lines        6377     6367      -10     
==========================================
+ Hits         5309     5371      +62     
+ Misses        796      722      -74     
- Partials      272      274       +2     
Flag Coverage Δ
e2e 27.65% <0.00%> (-0.02%) ⬇️
integration 27.65% <0.00%> (-0.02%) ⬇️
unittests 77.63% <97.39%> (+1.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Inject schemaApp hooks for unit tests covering validation, errors, filters,
and JSON envelopes. Fix Sonar duplicate-string smells. E2E schema tests
create and drop their own MySQL/PG tables so CI empty testdb no longer skips.

Co-authored-by: x_zhuo <zx06@users.noreply.github.com>
@sonarqubecloud

Copy link
Copy Markdown

@zx06
zx06 marked this pull request as ready for review October 10, 2026 06:26
@zx06
zx06 merged commit b9b8022 into main Oct 10, 2026
14 checks passed
@zx06
zx06 deleted the cursor/mcp-app-schema-tools-ad5b branch October 20, 2026 03:41
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