Skip to content

feat(search): match server description as well as name#1471

Open
amitvijapur wants to merge 1 commit into
modelcontextprotocol:mainfrom
amitvijapur:feat/search-match-description
Open

feat(search): match server description as well as name#1471
amitvijapur wants to merge 1 commit into
modelcontextprotocol:mainfrom
amitvijapur:feat/search-match-description

Conversation

@amitvijapur

Copy link
Copy Markdown

Fixes #1453

Change

Adds SubstringDescription to ServerFilter; the ?search= handler now sets it alongside SubstringName from the same term, so search matches server name or description.

Two implementation notes where this deviates from the issue's literal proposal, deliberately:

  • OR, not AND: adding two independent filter fields would have let buildFilterConditions' outer AND-join require a match on both name and description. When both fields are set, they're combined into a single (server_name ILIKE ... OR value ->> 'description' ILIKE ...) condition instead. A white-box test asserts the generated SQL to lock this in.
  • JSONB access: description has no dedicated column (unlike server_name, materialized in migration 009) — it lives inside the JSONB value blob, so the condition reads value ->> 'description'.

The existing LIKE-metacharacter escaping is preserved via a shared likePattern helper (same escaping order, same ESCAPE '\' pairing), so ?search=% still can't wildcard-match everything through the new description path either.

Scoped out: the issue also suggests ranking name matches above description matches. ListServers uses keyset/cursor pagination ordered by (server_name, version), and reordering by match-type would break that pagination scheme, so relevance ranking is left out of this PR rather than silently half-done. Happy to explore it separately if there's an agreed approach.

Tests

  • New white-box TestBuildFilterConditions_SearchMatchesNameOrDescription (6 subtests, no DB required) asserting the generated SQL/args, including the OR-not-AND behavior.
  • New DB-backed cases in postgres_test.go and servers_test.go (description-only match, combined search, no-match). Honest note: these compile cleanly (go test -run '^$') but I could not execute them locally because port 5432 is occupied by an unrelated service on my machine and the test harness's connection string is fixed to localhost:5432 — CI's Postgres job will exercise them.
  • go build ./..., go vet ./..., gofmt clean; golangci-lint run reports no new findings versus main on the touched packages.

The ?search= query on GET /v0/servers only matched server_name, so
servers were undiscoverable by what they do unless the search term
happened to appear in the name too (modelcontextprotocol#135 added the name-only version
of this).

Add SubstringDescription to ServerFilter and have the handler set it
alongside SubstringName from the same search term. buildFilterConditions
combines the two into a single OR'd condition (server_name ILIKE ...
OR value ->> 'description' ILIKE ...) rather than the AND every other
filter pair uses, since requiring both would silently break the
description half of the search. The description column lives inside
the JSONB value blob (there's no dedicated column, unlike server_name),
so the condition reads it via value ->> 'description'.

Fixes modelcontextprotocol#1453.
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.

feat: search should also match against server description field

1 participant