Thanks to visit codestin.com
Credit goes to github.com

Skip to content

new arch#1283

Merged
enesgules merged 11 commits intomasterfrom
just-ranking
Dec 29, 2025
Merged

new arch#1283
enesgules merged 11 commits intomasterfrom
just-ranking

Conversation

@enesakar
Copy link
Contributor

@enesakar enesakar commented Dec 22, 2025

New architecture to decrease token cost. It re-ranks the library and context snippets.

Summary by CodeRabbit

  • Breaking Changes

    • MCP server updated to 2.0.0.
    • Tool renamed: get-library-docsquery-docs.
    • Documentation queries now use query and libraryId (replacing mode/page/topic).
    • resolve-library-id now accepts query alongside libraryName.
    • Package/manifest versions updated to 2.0.0.
  • Behavior Changes

    • Documentation responses now return structured context data (data field) with updated no-results messaging.
    • README examples use pnpm/node commands instead of bun.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 25, 2025

📝 Walkthrough

Walkthrough

Replaces a mode/pagination documentation model with a query/context model: adds ContextRequest/ContextResponse types, introduces fetchLibraryContext and updated searchLibraries signatures, renames tool get-library-docs → query-docs, and bumps MCP server to 2.0.0.

Changes

Cohort / File(s) Summary
Type definitions
packages/mcp/src/lib/types.ts
Removed DOCUMENTATION_MODES and DocumentationMode; added ContextRequest { query, libraryId } and ContextResponse { data }.
API surface / network calls
packages/mcp/src/lib/api.ts
searchLibraries(query, libraryName, ...) now calls /v2/libs/search; fetchLibraryDocumentation renamed to fetchLibraryContext(request: ContextRequest, ...) returning ContextResponse; parseLibraryId removed; errors returned as structured responses.
Tool handlers & server
packages/mcp/src/index.ts
Tool renamed get-library-docsquery-docs; handlers/inputSchemas now use { query, libraryId } and { query, libraryName }; removed DEFAULT_RESULTS_LIMIT; import updated to fetchLibraryContext; logging/header extraction adjusted; McpServer version bumped to 2.0.0.
Packaging & manifest
packages/mcp/mcpb/manifest.json, packages/mcp/package.json, .changeset/*, README.md
Package and manifest version bumped to 2.0.0; tool names/descriptions updated in manifest; packaging script simplified; README examples switched from bun to pnpm/node; changelog updated.

Sequence Diagram(s)

sequenceDiagram
  participant Client as Client / Tool
  participant MCP as MCP Server (tools)
  participant API as Context7 API

  Client->>MCP: resolve-library-id { query, libraryName }
  MCP->>API: GET /v2/libs/search?query=...&libraryName=...
  API-->>MCP: SearchResponse (matches or error)
  alt library found
    MCP-->>Client: libraryId(s)
    Client->>MCP: query-docs { query, libraryId }
    MCP->>API: GET /v2/context?query=...&libraryId=... \n(X-Context7-Source header)
    API-->>MCP: ContextResponse { data: "<documentation text>" } or error
    MCP-->>Client: documentation (response.data) or structured error
  else no libraries
    MCP-->>Client: error ("no libraries found" message)
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐇 I hopped from modes to context fields today,
Query in paw, libraryId leads the way,
Two-oh now hums, responses come as data,
Headers trimmed, handlers leaner than later,
I nibble changes and tumble—hip, hop, hooray! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'new arch' is vague and generic, providing no meaningful information about what architectural change is being implemented or why. Use a more descriptive title such as 'Implement context re-ranking architecture to optimize token costs' or 'Add intelligent library and snippet re-ranking to reduce token consumption'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch just-ranking

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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/mcp/src/lib/api.ts (1)

110-141: Error handling returns errors inline rather than throwing.

The function returns error messages in the data field rather than throwing exceptions or using a discriminated union. This works for the current use case where the LLM processes the text directly, but callers cannot programmatically distinguish success from failure.

Consider adding an optional error field to ContextResponse for future extensibility:

export type ContextResponse = {
  data: string;
  error?: boolean;
};
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 072fa09 and dc972a4.

📒 Files selected for processing (3)
  • packages/mcp/src/index.ts
  • packages/mcp/src/lib/api.ts
  • packages/mcp/src/lib/types.ts
🧰 Additional context used
🧬 Code graph analysis (2)
packages/mcp/src/lib/api.ts (3)
packages/mcp/src/lib/types.ts (3)
  • SearchResponse (16-19)
  • ContextRequest (24-27)
  • ContextResponse (29-31)
packages/sdk/src/http/index.ts (1)
  • request (124-186)
packages/mcp/src/lib/encryption.ts (1)
  • generateHeaders (34-47)
packages/mcp/src/index.ts (1)
packages/mcp/src/lib/api.ts (2)
  • searchLibraries (72-101)
  • fetchLibraryContext (110-141)
🔇 Additional comments (8)
packages/mcp/src/lib/types.ts (1)

24-31: LGTM! Clean type definitions for the new context-based API.

The new ContextRequest and ContextResponse types are well-structured and appropriately minimal. They align with the API changes in api.ts and the tool input schemas in index.ts.

packages/mcp/src/lib/api.ts (2)

66-81: Updated signature aligns with new API design.

The searchLibraries function now accepts separate query and libraryName parameters, allowing the backend to rank results by relevance to the user's intent. The parameter naming is clear and the JSDoc is updated appropriately.


129-135: Good fallback guidance for empty responses.

The empty response handling provides clear, actionable guidance directing users to the resolve-library-id tool when documentation isn't found.

packages/mcp/src/index.ts (5)

101-101: Version bump to 2.0.0 is appropriate.

The semver major version increment correctly signals breaking changes: tool rename (get-library-docsquery-docs), changed input schemas, and modified API behavior.


136-140: Good security guidance for the query parameter.

The warning about not including sensitive information (API keys, passwords, credentials, personal data) in the query is important since these values are passed as URL query parameters and could be logged by intermediate proxies or server access logs.


194-231: Clean tool implementation with appropriate security warnings.

The renamed query-docs tool has a simplified interface and clear documentation. The handler correctly passes parameters to fetchLibraryContext and returns the response data.


133-134: Tool call limit is guidance-only.

The 3-call limit is documented but not enforced programmatically. This is appropriate for LLM clients that respect instructions, but consider adding server-side rate limiting if abuse becomes a concern.


216-230: Handler correctly delegates error messaging to API layer.

The tool handler trusts fetchLibraryContext to return appropriate error messages in response.data, maintaining a clean separation of concerns.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
README.md (3)

1310-1321: Update tool documentation to reflect v2.0.0 breaking changes.

The "Available Tools" section still references the old get-library-docs tool name and deprecated parameters (context7CompatibleLibraryID, page, topic). According to the changeset, these have been replaced in v2.0.0:

  • Tool renamed: get-library-docsquery-docs
  • Parameter renamed: context7CompatibleLibraryIDlibraryId
  • Parameters removed: page, topic, mode, limit

This inconsistency will cause user-facing failures when following the documentation.

🔎 Suggested documentation update
-- `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
-  - `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
-  - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
-  - `page` (optional, default 1): Page number for pagination (1-10). If the context is not sufficient, try page=2, page=3, etc. with the same topic.
+- `query-docs`: Retrieves and queries up-to-date documentation and code examples from Context7.
+  - `libraryId` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
+  - `query` (required): The specific question or context you need documentation for

961-961: Update Copilot configuration examples with new tool name.

These configuration examples still reference the old get-library-docs tool name, which has been renamed to query-docs in v2.0.0.

🔎 Suggested fix
-      "tools": ["get-library-docs", "resolve-library-id"]
+      "tools": ["query-docs", "resolve-library-id"]

Also applies to: 986-986, 1000-1000


1138-1138: Update BoltAI example with new tool name.

The BoltAI example still references get-library-docs, which has been renamed to query-docs in v2.0.0.

🔎 Suggested fix
-Once saved, enter in the chat `get-library-docs` followed by your Context7 documentation ID (e.g., `get-library-docs /nuxt/ui`).
+Once saved, enter in the chat `query-docs` followed by your Context7 documentation ID (e.g., `query-docs /nuxt/ui`).
🧹 Nitpick comments (1)
packages/mcp/package.json (1)

16-16: LGTM: pack-mcpb script refactored for clarity.

The simplified script maintains the same packaging workflow with cleaner syntax and explicit steps.

Note: Consider adding error handling (e.g., set -e in bash or chaining with &&) to ensure the script fails fast if any step encounters an error.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8284bf and 73f8c68.

📒 Files selected for processing (5)
  • .changeset/some-suns-turn.md
  • README.md
  • packages/mcp/mcpb/context7.mcpb
  • packages/mcp/mcpb/manifest.json
  • packages/mcp/package.json
🔇 Additional comments (4)
README.md (1)

1347-1379: LGTM: Development commands updated correctly.

The migration from bun to pnpm/node commands is consistent and appropriate for the project's tooling updates.

packages/mcp/package.json (1)

3-3: LGTM: Major version bump appropriate for breaking changes.

The version bump to 2.0.0 correctly reflects the breaking API changes documented in the changeset (tool rename, parameter changes, API surface updates).

.changeset/some-suns-turn.md (1)

1-27: LGTM: Comprehensive breaking change documentation.

The changeset clearly documents the v2.0.0 breaking changes, new features, and improvements. This provides essential context for users upgrading from v1.x.

packages/mcp/mcpb/manifest.json (1)

5-5: LGTM: Manifest updated to reflect v2.0.0 changes.

The version bump and tool naming/description updates correctly reflect the new query-based architecture and breaking changes documented in the changeset.

Also applies to: 28-28, 31-32

@enesgules enesgules merged commit 66ea0d6 into master Dec 29, 2025
3 checks passed
@enesgules enesgules deleted the just-ranking branch December 29, 2025 10: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

Comments