feat(mcp): add lexical capability ranking#2573
Draft
reachjalil wants to merge 1 commit into
Draft
Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
@reachjalil is attempting to deploy a commit to the Different AI Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft Proposal
This proposes replacing Den
/mcp/agentcapability search's per-source additive keyword scoring with a shared lexical ranker. The goal is to improve capability discoverability without adding embeddings, vectors, LLM calls, or npm dependencies.The search/execute surface stays the same:
/mcp/agenttoolssearch_capabilitiesandexecute_capability./mcprich endpointsearchCapabilities(catalog, query, limit)signature.Why This Change
/mcp/agentranks the merged corpus once.store a notemiss the intended Memory capability because wording differs from operation names.needs_connectionrows floor-exempt.sourceon matches and document 0-100 per-response score semantics.What Changed
ee/apps/den-api/src/mcp/ranking.tswith tokenization, stemming, stopwords, synonyms, rarity, coverage, adjacency, noise floor, and suggestions.search.tsintobuildRestCandidates()plus the existingsearchCapabilities()wrapper.listExternalCapabilityCandidates(), preserving grants, credential checks, best-effort connection handling, and setup/error rows.listMarketplaceCapabilityCandidates()and ranks it with the same shared scorer./mcp/agentnow gathers REST + External MCP + marketplace candidates, ranks once, short-circuits all-stopword queries, and returns suggestions on zero-result responses.Benchmarking
Benchmark methodology:
packages/docs/openapi.jsonplus the synthetic Memory/external corpus used by the new unit tests.top1ortop3depending on the query's intended ambiguity.searchCapabilities()calls locally over the checked-in catalog.Quality Summary
Notable Query-Level Changes
invite a teammatepostInvitationsstore a notepostMemorylist workersgetWorkerscreate pluginpostPluginslinearmcp:linear:*needs_connectionrow remains discoverable and actionable.notion pagemcp:notion:createPageLatency
This is still comfortably sub-millisecond per REST catalog search on this machine. External MCP network calls are unchanged; this only changes how returned candidates are ranked.
Important Scope Notes
upstream/dev, which does not yet include the separateskill-capabilities.tsbranch. The ranker type includesskills, so that source can plug into the same candidate interface after the skill PR lands.Validation
pnpm --filter @openwork-ee/den-api exec bun test test/mcp-capability-ranking.test.ts test/mcp-capability-search.test.ts test/external-capabilities-search-divergence.test.ts test/marketplace-capabilities.test.ts test/mcp-agent-config-policy.test.ts test/mcp-tool-name-length.test.ts test/mcp-invoke-body.test.tspnpm --filter @openwork-ee/den-api exec tsc --noEmitpnpm --filter @openwork-ee/den-api buildDB-backed tests required local MySQL databases
openwork_test_pr3andopenwork_test_searchdiv; I created them locally and ranpnpm --filter @openwork-ee/den-db db:pushfor each before the test sweep.