Skip to content

Conversation

@Valiunia
Copy link
Contributor

@Valiunia Valiunia commented Jan 5, 2026

Summary

This PR fixes some installation issues todo with npx. Additionally:

  1. ETA schema fix - mention the SearchAndGeocodeTool.output.schema.ts change:
    Fixed eta field schema to accept both number (seconds) and object formats, matching actual API response

  2. Dual-context postinstall - clarify the postinstall now handles both scenarios:
    Postinstall script now works in both development (npm install in repo) and as a dependency (installed in user projects)

  3. updating MCP sdk version (this required updating the patch)

Issues Fixed

When users tried to run npx @mapbox/mcp-server, they encountered the error:

sh: mcp-server: command not found

This was caused by multiple installation script failures that prevented npm from properly setting up the binary.

Changes

1. Fixed patch-package Dependency Issue

Problem: The postinstall script runs patch-package, but it was only in devDependencies. When end users installed the package, they didn't get dev dependencies, causing the postinstall to fail.

Solution:

  • Moved patch-package from devDependencies to dependencies (package.json)
  • Added patches/ directory to the files array to ensure patches are included in published package

2. Updated MCP SDK and Regenerated Patches

Problem: The patch was for @modelcontextprotocol/[email protected], but the ^ version allowed 1.25.1 to be installed, causing patch application to fail.

Solution:

  • Updated SDK dependency to ^1.25.1 (package.json)
  • Regenerated patches for the new SDK version (patches/@modelcontextprotocol+sdk+1.25.1.patch)
  • Removed old patch file (patches/@modelcontextprotocol+sdk+1.21.1.patch)
  • Updated src/tools/BaseTool.ts to add type annotations required by new SDK version

3. Fixed prepare Script for End Users

Problem: The prepare script checked for .git directory to decide whether to run husky setup. However, when users installed the package in THEIR git repository, it found their .git and tried to run husky (which wasn't installed), causing the script to fail.

Solution: Changed the check from .git to .husky/setup-hooks.js (package.json):

// Before: Checks .git (exists in any git repo)
"prepare": "... require('fs').accessSync('.git') ..."

// After: Checks for the actual setup file (only in dev environment)
"prepare": "... require('fs').accessSync('.husky/setup-hooks.js') ..."

This ensures the prepare script only runs in the actual development environment of this package, not when installed as a dependency.

Testing

Verified that the package works correctly using MCP inspector:

Details

shows the correct dev version that I published for testing:
image

handling missing access token as expected:
image

Testing MCP functionality:
image
image
image
image

@mattpodwysocki mattpodwysocki marked this pull request as ready for review January 5, 2026 18:50
@mattpodwysocki mattpodwysocki requested a review from a team as a code owner January 5, 2026 18:50
@mattpodwysocki mattpodwysocki force-pushed the valentin_temp branch 2 times, most recently from c7a6f41 to bdd21ff Compare January 5, 2026 18:59
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot left a comment

Choose a reason for hiding this comment

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

Prisma Cloud has found errors in this PR ⬇️

"dependencies": {
"@mcp-ui/server": "^5.13.1",
"@modelcontextprotocol/sdk": "^1.21.1",
"@modelcontextprotocol/sdk": "^1.25.1",
Copy link

@prisma-cloud-devsecops prisma-cloud-devsecops bot Jan 5, 2026

Choose a reason for hiding this comment

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

@modelcontextprotocol/sdk / package.json

🎉   All vulnerabilities were fixed

Total vulnerabilities: 1

Critical: 0 High: 1 Medium: 0 Low: 0
Vulnerability IDSeverityCVSSFixed inStatus
CVE-2025-15284 HIGH HIGH - - Fixed
Vulnerabilities scan results were updated by commit 0096a0c

This commit resolves critical installation failures that prevented users
from running the package via `npx @mapbox/mcp-server`.

When users ran `npx @mapbox/mcp-server`, they encountered:
```
sh: mcp-server: command not found
```

This was caused by multiple installation script failures that prevented
npm from properly setting up the binary.

**Problem:** The postinstall script runs patch-package, but it was only
in devDependencies. End users don't get dev dependencies, causing
postinstall to fail.

**Solution:**
- Moved patch-package from devDependencies to dependencies
- Removed duplicate patch-package entry in devDependencies (caused by rebase)
- Added patches/ directory to files array in package.json
- Ensures patches are included in published package

**Problem:** Patch was for @modelcontextprotocol/[email protected], but the ^
version allowed 1.25.1 to be installed, causing patch failures.

**Solution:**
- Updated SDK dependency to ^1.25.1
- Regenerated patches for new SDK version
- Removed old 1.21.1 patch file
- Updated src/tools/BaseTool.ts with type annotations required by new SDK

**Problem:** The prepare script checked for .git directory, but when
users installed the package in THEIR git repo, it found their .git and
tried to run husky (which wasn't installed), causing failures.

**Solution:** Changed check from .git to .husky/setup-hooks.js:
```javascript
// Before: Checks .git (exists in any git repo)
"prepare": "... require('fs').accessSync('.git') ..."

// After: Checks for actual setup file (only in dev environment)
"prepare": "... require('fs').accessSync('.husky/setup-hooks.js') ..."
```

This ensures prepare only runs in the development environment of this
package, not when installed as a dependency.

**Problem:** TypeScript "Type instantiation is excessively deep" errors
after rebasing onto PR #73 with SDK 1.25.1.

**Solution:** Added type assertions (`as any`) to break complex type
inference chains in:
- src/tools/BaseTool.ts (registerTool call)
- src/index.ts (setRequestHandler call)

These assertions are necessary workarounds for TypeScript's limitations
with deeply nested generic types in the MCP SDK.

Verified the package works correctly:

```bash
cd /tmp
npx --yes "@mapbox/[email protected]"
```

Integration tests confirm:
- ✅ All dependencies install correctly
- ✅ MCP SDK patches apply successfully
- ✅ mcp-server binary created and executable
- ✅ Server runs without errors
- ✅ All tools (SearchAndGeocode, CategorySearch, ReverseGeocode) working
- ✅ Schema validation working with metadata fields (PR #86)
- ✅ Non-fatal validation working (PR #73)

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

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
mattpodwysocki
mattpodwysocki previously approved these changes Jan 6, 2026
@Valiunia Valiunia merged commit 66acf3d into main Jan 6, 2026
5 checks passed
@Valiunia Valiunia deleted the valentin_temp branch January 6, 2026 15:10
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.

3 participants