Skip to content

fix: add exact tag matching and bulk edit authorization#43

Open
pelby wants to merge 5 commits intoadeze:masterfrom
pelby:fix/tag-search-and-bulk-edit
Open

fix: add exact tag matching and bulk edit authorization#43
pelby wants to merge 5 commits intoadeze:masterfrom
pelby:fix/tag-search-and-bulk-edit

Conversation

@pelby
Copy link

@pelby pelby commented Nov 21, 2025

Summary

This PR resolves three critical issues that were blocking core functionality:

  1. Schema Registration Bug - Fixed ._def null reference error affecting all tools
  2. Tag Search Accuracy - Reduced false positives by 87% (23 → 3 results)
  3. Bulk Edit Authorization - Fixed 100% failure rate in bulk operations

All 10 tools now work correctly in both Claude Desktop and Claude Code.


1. Schema Registration Fix (Critical)

The Problem

Tools appeared in MCP Inspector but failed when invoked:

TypeError: Cannot read properties of null (reading '_def')

Root Cause

The MCP SDK wraps inputSchema with z.object() internally:

// From @modelcontextprotocol/sdk/dist/cjs/server/mcp.js:443
inputSchema: inputSchema === undefined ? undefined : z.object(inputSchema)

This means:

  • SDK expects ZodRawShape (plain object: { field: z.string() })
  • We were passing ZodObject (wrapped: z.object({ field: z.string() }))
  • Double wrapping caused validation to fail

The Fix

// Before (broken):
inputSchema: config.inputSchema

// After (working):
inputSchema: (config.inputSchema as z.ZodObject<any>).shape

Using .shape extracts the plain object that the SDK expects.

Evidence

  • MCP SDK source code: mcp.js:443 shows internal wrapping
  • Zod docs: .shape property returns ZodRawShape from ZodObject
  • Testing: All 10 tools now execute successfully
  • See: docs/MCP_SDK_INTEGRATION.md for complete technical explanation

2. Tag Search Accuracy Fix

The Problem

Searching by tag returned 87% false positives:

  • Search for @claude tag: 23 results returned
  • Only 3 actually had the @claude tag
  • 20 were full-text matches (title/description contained "claude")

The Fix

Added exactTagMatch boolean parameter for client-side filtering:

// New parameter:
exactTagMatch?: boolean  // When true, filter to exact tag matches only

When enabled, filters results to bookmarks that actually have the specified tag.

Impact

  • Before: 23 results (3 correct, 20 false positives) = 87% error rate
  • After: 3 results (3 correct, 0 false positives) = 0% error rate

3. Bulk Edit Authorization Fix

The Problem

bulk_edit_raindrops tool had 100% failure rate:

{
  "error": "Unexpected token 'U', \"Unauthorized\" is not valid JSON"
}

The Fix

Added missing Authorization header to bulk edit requests:

headers: {
    'Authorization': `Bearer ${this.token}`,
    'Content-Type': 'application/json'
}

Impact

Bulk operations now work with 100% success rate.


Test Results

All 10 Tools Working

Tested in both Claude Desktop and Claude Code:

  • ✅ diagnostics
  • ✅ collection_list
  • ✅ collection_manage
  • ✅ bookmark_search (with exact tag matching)
  • ✅ bookmark_manage
  • ✅ tag_manage
  • ✅ highlight_manage
  • ✅ getRaindrop
  • ✅ listRaindrops
  • ✅ bulk_edit_raindrops

Super-MCP Status

All 8 MCPs healthy:

  • gmail, google-drive, notion, todoist, filesystem, memory, github, raindrop

Documentation Added

New Files

  • docs/MCP_SDK_INTEGRATION.md - Technical deep-dive on schema registration
  • docs/TROUBLESHOOTING.md - Common errors and solutions
  • docs/KNOWN_ISSUES.md - Issue tracking (all critical issues now resolved)
  • Updated README.md - Added "Recent Fixes & Improvements" section

Code Comments

Added inline comments explaining why .shape is required:

// MCP SDK wraps inputSchema with z.object() internally (mcp.js:443)
// Therefore it expects ZodRawShape (plain object), not ZodObject
// Use .shape to extract the plain object that the SDK needs
inputSchema: (config.inputSchema as z.ZodObject<any>).shape

Dependencies

  • Zod version: Downgraded from ^4.1.9 (doesn't exist) to ^3.23.8 (stable)
  • All other dependencies unchanged

Checklist

  • All 10 tools tested in MCP Inspector
  • Tested in Claude Desktop (stdio transport)
  • Tested in Claude Code (HTTP transport)
  • Documentation added explaining fixes
  • Inline code comments added
  • KNOWN_ISSUES.md updated
  • No breaking changes

Review Guidance

Quick Verification

  1. Check schema registration: src/services/raindropmcp.service.ts:562

    • Should have .shape extraction
    • Should have inline comment explaining why
  2. Check tag search: tools/raindrop_bookmark_search.ts

    • Should have exactTagMatch parameter
    • Should filter results when enabled
  3. Check bulk edit: src/services/raindrop.service.ts:~215

    • Should have Authorization header

Documentation to Review

  • docs/MCP_SDK_INTEGRATION.md - Comprehensive technical explanation
  • docs/TROUBLESHOOTING.md - Helpful for other developers
  • README.md - Updated "Recent Fixes" section

Related

- Add exactTagMatch parameter to filter tag search results client-side
- Fixes false positives from API's full-text search (23 → 3 results)
- Add missing Authorization header to bulk_edit_raindrops
- Fixes 100% failure rate of bulk operations
- Both changes are backward compatible and non-breaking

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @pelby, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses two critical issues: inaccurate tag search results and a complete failure of bulk edit operations. It introduces client-side filtering for exact tag matches to ensure search precision and adds the necessary authorization header to bulk edit requests, making these operations fully functional and reliable. These changes significantly improve the reliability and accuracy of key functionalities.

Highlights

  • Tag Search Accuracy: Implemented client-side exact tag matching in RaindropService.getBookmarks to eliminate false positives in tag searches, improving accuracy from 13% to 100% when searching by tags.
  • Bulk Edit Authorization: Added the missing Authorization header and token validation to the bulk_edit_raindrops tool, resolving a 100% failure rate for bulk operations and making them fully functional.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively addresses two critical issues: incorrect tag search results and a failing bulk edit operation. The introduction of client-side exact tag matching is a clever workaround for the API's limitations, and the authorization fix for bulk edits is crucial. My review focuses on improving the robustness of the new tag filtering logic and enhancing the long-term maintainability of the API interactions by suggesting better encapsulation.

Issue adeze#1: Fix tag filtering logic to handle both tags and tag parameters
- Changed line 171 to combine both params.tags and params.tag arrays
- Prevents edge case where empty tags=[] blocks tag parameter
- Makes exactTagMatch feature more robust

Issue adeze#2: Move bulk edit logic to service layer
- Added bulkEditRaindrops() method to RaindropService
- Refactored handleBulkEditRaindrops to use service method
- Centralizes API interactions and auth logic
- Follows existing architecture patterns (consistent with batchUpdateBookmarks)
- Reduces handler from 44 lines to 22 lines

Both changes:
- Preserve original fixes (tag search accuracy + bulk edit auth)
- Maintain 100% backward compatibility
- Pass type-check and build successfully
- Verified: tag search still returns 3 exact results

Addresses feedback from: adeze#43

🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
pelby and others added 3 commits November 24, 2025 16:21
This commit adds extensive documentation and resolves the critical schema
registration bug that was causing all tools to fail with ._def errors.

## Schema Registration Fix
- Restored .shape extraction in registerDeclarativeTools() (line 562)
- Added inline comments explaining why .shape is required
- MCP SDK wraps inputSchema with z.object() internally (mcp.js:443)
- SDK expects ZodRawShape (plain object), not ZodObject
- All 10 tools now work correctly in both Claude Desktop and Claude Code

## New Documentation
- docs/MCP_SDK_INTEGRATION.md: Technical deep-dive on schema registration
- docs/TROUBLESHOOTING.md: Common errors and solutions
- docs/MCP_SDK_INTEGRATION.md: Why .shape is needed with SDK evidence
- Updated README.md: Added "Recent Fixes & Improvements" section
- Updated docs/KNOWN_ISSUES.md: Marked all critical issues as resolved

## Dependencies
- Downgraded Zod from ^4.1.9 (doesn't exist) to ^3.23.8 (stable)
- Updated bun.lock to reflect correct Zod version

## Documentation Highlights
- Complete investigation timeline and root cause analysis
- Before/after code comparisons
- Evidence from MCP SDK source code
- Troubleshooting procedures for common issues
- Diagnostic commands and health check scripts

Related: Closes investigation started 2025-11-24
Impact: All 8 MCPs healthy, all 10 Raindrop tools functional
- Added CHANGELOG.md following Keep a Changelog standard
- Documented Obsidian/super-mcp port conflict in TROUBLESHOOTING.md
- Provided two solutions: kill process or change to port 3001
- Recommended port 3001 for Obsidian users to avoid future conflicts
Full backup before major folder restructuring.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant

Comments