LibreChat/packages/api/src
Atef Bellaaj 95a69df70e
🔒 feat: Add MCP server domain restrictions for remote transports (#11013)
* 🔒 feat: Add MCP server domain restrictions for remote transports

* 🔒 feat: Implement comprehensive MCP error handling and domain validation

- Added `handleMCPError` function to centralize error responses for domain restrictions and inspection failures.
- Introduced custom error classes: `MCPDomainNotAllowedError` and `MCPInspectionFailedError` for better error management.
- Updated MCP server controllers to utilize the new error handling mechanism.
- Enhanced domain validation logic in `createMCPTools` and `createMCPTool` functions to prevent operations on disallowed domains.
- Added tests for runtime domain validation scenarios to ensure correct behavior.

* chore: import order

* 🔒 feat: Enhance domain validation in MCP tools with user role-based restrictions

- Integrated `getAppConfig` to fetch allowed domains based on user roles in `createMCPTools` and `createMCPTool` functions.
- Removed the deprecated `getAllowedDomains` method from `MCPServersRegistry`.
- Updated tests to verify domain restrictions are applied correctly based on user roles.
- Ensured that domain validation logic is consistent and efficient across tool creation processes.

* 🔒 test: Refactor MCP tests to utilize configurable app settings

- Introduced a mock for `getAppConfig` to enhance test flexibility.
- Removed redundant mock definition to streamline test setup.
- Ensured tests are aligned with the latest domain validation logic.

---------

Co-authored-by: Atef Bellaaj <slalom.bellaaj@external.daimlertruck.com>
Co-authored-by: Danny Avila <danny@librechat.ai>
2025-12-18 13:57:49 -05:00
..
acl 🏗️ feat: Dynamic MCP Server Infrastructure with Access Control (#10787) 2025-12-11 16:38:37 -05:00
agents 🔧 chore: Update ESLint Config & Run Linter (#10986) 2025-12-15 17:55:25 -05:00
app 🏗️ feat: Dynamic MCP Server Infrastructure with Access Control (#10787) 2025-12-11 16:38:37 -05:00
auth 🔒 feat: Add MCP server domain restrictions for remote transports (#11013) 2025-12-18 13:57:49 -05:00
cache 📡 refactor: MCP Runtime Config Sync with Redis Distributed Locking (#10352) 2025-12-11 16:36:15 -05:00
cdn 🔃 refactor: Decouple Effects from AppService, move to data-schemas (#9974) 2025-10-05 06:37:57 -04:00
cluster 🐛 fix: Redis Cluster Bug + 🧪 Enhance Test Coverage (#10518) 2025-11-16 11:58:52 -05:00
crypto 🧵 refactor: Migrate Endpoint Initialization to TypeScript (#10794) 2025-12-11 16:37:16 -05:00
db 🔧 refactor: Centralize Collection Checks for Permissions Migration (#9565) 2025-09-10 20:40:58 -04:00
endpoints 📦 chore: Bump MCP SDK: Fix Types and MCP OAuth due to Update (#10811) 2025-12-11 16:38:40 -05:00
files ⏱️ fix: Increase RAG API Text Parsing Timeout (#10562) 2025-11-25 14:54:53 -05:00
flow ⚠️ fix: OAuth Error and Token Expiry Detection and Reporting Improvements (#10922) 2025-12-12 13:51:28 -05:00
mcp 🔒 feat: Add MCP server domain restrictions for remote transports (#11013) 2025-12-18 13:57:49 -05:00
memory 🛂 feat: Payload limits and Validation for User-created Memories (#8974) 2025-08-10 14:46:16 -04:00
middleware 🛡️ feat: Add Middleware for JSON Parsing and Prompt Group Updates (#10757) 2025-12-02 00:10:30 -05:00
oauth 🧵 refactor: Migrate Endpoint Initialization to TypeScript (#10794) 2025-12-11 16:37:16 -05:00
prompts 🧵 refactor: Migrate Endpoint Initialization to TypeScript (#10794) 2025-12-11 16:37:16 -05:00
tools 🧬 refactor: Optimize MCP Tool Queries with Server-Centric Architecture 2025-09-21 20:40:14 -04:00
types 📦 chore: Bump MCP SDK: Fix Types and MCP OAuth due to Update (#10811) 2025-12-11 16:38:40 -05:00
utils 🔧 chore: Update ESLint Config & Run Linter (#10986) 2025-12-15 17:55:25 -05:00
web 🔍 feat: Add Serper as Scraper Provider and Firecrawl Version Support (#9984) 2025-10-05 20:34:05 -04:00
index.ts 🔒 feat: Add MCP server domain restrictions for remote transports (#11013) 2025-12-18 13:57:49 -05:00