Skip to content

fix(mcp): prefer exact match for containers in inspect_schema before case-insensitive fallback (MCP3) - #2136

Merged
cevheri merged 2 commits into
libredb:mainfrom
Maaz2212:fix/mcp-inspect-schema-case-matching
Nov 8, 2026
Merged

cevheri merged 2 commits into
libredb:mainfrom
Maaz2212:fix/mcp-inspect-schema-case-matching

Conversation

@Maaz2212

@Maaz2212 Maaz2212 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Description

When calling the MCP tool inspect_schema with a schema argument, chooseContainer previously performed a purely case-insensitive match (candidate.name.toLowerCase() === wanted).

On engines or brokers supporting case-sensitive container names (such as RabbitMQ virtual hosts like Billing and billing), requesting schema: "billing" would pick whichever container was enumerated first by the provider. This change updates chooseContainer to prioritize an exact match first, falling back to case-insensitive matching only when no exact match exists.

Closes item MCP3 from docs/BACKLOG.md.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Test addition or update

Related Issue

Closes item MCP3 in docs/BACKLOG.md

Changes Made

  • src/lib/mcp/tools/inspect-schema.ts: Updated chooseContainer to check candidate.name === schema before falling back to candidate.name.toLowerCase() === wanted.
  • tests/integration/mcp/inspect-schema.test.ts: Added integration test prefers an exact match when two containers differ only by case, and falls back to case-insensitive verifying:
    1. Exact match for "billing" chooses billing even when Billing is listed first.
    2. Exact match for "Billing" chooses Billing.
    3. Case-insensitive fallback for "BILLING" selects Billing.
  • docs/BACKLOG.md: Removed completed item MCP3 and updated the Table of Contents count.

Testing

  • I have tested this locally
  • I have added/updated tests
  • All existing tests pass

Test Environment

  • LibreDB Studio Version: 1.2.0
  • Browser: Headless MCP
  • OS: macOS (darwin-x64)
  • Node.js/Bun Version: Bun 1.4.3 / Node.js 24
  • Database Type: DuckDB / RabbitMQ / MCP Providers

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • The required CI test job passes the 100% line-coverage gate (bun run test:coverage and bun run coverage:check — 205/205 lines hit on inspect-schema.ts)
  • Typecheck passed (tsc --noEmit with 0 errors)
  • Linters passed (oxlint, eslint, only-check with 0 errors)
  • Knip passed (knip with 0 issues)
  • Biome formatting checked (biome format)

@codecov

codecov Bot commented Nov 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@cevheri

cevheri commented Nov 2, 2026

Copy link
Copy Markdown
Member

I am working on a critical development related to MCP; I will review this PR once the MCP development is complete. If any conflicts arise and provided they involve only non-critical documentation updates I will proceed with the merge.

@Maaz2212

Maaz2212 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Hey @cevheri is everything good if you want any thing help or any issues solving please feel free to ask i will look into that.

@cevheri
cevheri merged commit eb8069b into libredb:main Nov 8, 2026
27 checks passed
@cevheri

cevheri commented Nov 8, 2026

Copy link
Copy Markdown
Member

Thanks for your patience, @Maaz2212, merged. As I said I would, I resolved the BACKLOG conflict myself by merging main into your branch. I also dropped the sentence in MCP22 that still pointed at MCP3.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants