refactor: codebase cleanup and consistency improvements#5
Merged
Conversation
Rename src/search/flexsearch-indexer.ts to flexsearch-core.ts to avoid confusion with the provider class in src/providers/indexers/flexsearch-indexer.ts. Also fixes outdated comment that incorrectly stated docs are "keyed by route" when they are actually keyed by full URL. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Replace ~70 lines of hand-rolled HTML serialization with the hast-util-to-html library. This is more maintainable and handles edge cases correctly. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Refactor MCP tool files to be the single source of truth for tool definitions: - Add Zod schemas for input validation in each tool file - Export complete tool definitions (name, description, inputSchema) - Update server.ts to import and use tool definitions from tool files - Keep execution logic and formatters in their respective tool files This makes the tool definitions self-contained and ensures the server always uses the canonical definitions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Create shared CORS utility in src/adapters/cors.ts - Add CORS headers and OPTIONS handling to Vercel adapter - Add CORS headers and OPTIONS handling to Netlify adapter - Update Cloudflare adapter to use shared CORS utility Previously only the Cloudflare adapter had CORS support. Now all platform adapters handle CORS consistently. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix two build warnings: 1. Mixed exports warning: Remove default export from src/index.ts, only use named export 'mcpServerPlugin'. This avoids CJS/ESM interop issues where consumers would need .default access. 2. Unused createServer warning: Export createNodeServer and createNodeHandler from adapters-entry.ts so they're actually used and not tree-shaken away. Also: - Simplify theme/index.ts to only use named exports - Add Node.js built-ins to tsup externals (node:*, http, fs, path) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update README to accurately reflect the current implementation: - Document docs_search and docs_fetch tools (was showing 3 tools) - Update API reference exports section - Fix local development example - Add note about CORS support in adapters Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
Author
Code reviewFound 1 issue:
In return res.status(200).json({ ...status, ...corsHeaders });This is inconsistent with how CORS is handled elsewhere in the same file:
The fix should set CORS headers via docusaurus-plugin-mcp-server/src/adapters/vercel.ts Lines 64 to 69 in 858be80 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Fix bug where CORS headers were incorrectly merged into the JSON response body instead of being set as HTTP headers. This was inconsistent with how CORS is handled elsewhere in the same file. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
A comprehensive cleanup pass addressing code consistency, library usage, and build configuration issues.
Changes
src/providers/indexers/Commits
Each commit is atomic and addresses one logical change:
refactor: rename flexsearch-indexer.ts to flexsearch-core.tsrefactor: use hast-util-to-html for HTML serializationrefactor: make tool definitions complete and import into serverrefactor: unify CORS handling across all adaptersfix: resolve build warnings for exports and externalsdocs: update README with correct 2-tool APITest plan
npm run buildcompletes without warningsnpm run typecheckpassesnpm test- all 51 unit tests passnpm run test:mcp- all 11 MCP integration tests pass🤖 Generated with Claude Code