Skip to content

Conversation

@manojag115
Copy link
Contributor

@manojag115 manojag115 commented Jan 12, 2026

Description

Backend:

  • Database migration (revision 60) for MCP_CONNECTOR type
  • CRUD endpoints for MCP
  • Dynamic tool loading - converts JSON configs to LangChain tools
  • Supports all HTTP methods (GET, POST, PUT, PATCH, DELETE)

Frontend:

  • Connect form - create multi-tool connectors

Key Details:

  • Tools load on every chat session from database
  • Permission-based access control
  • Added SSL verification checkbox for users to disable if they want for specific MCPs

Motivation and Context

FIX #625

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR introduces a Model Context Protocol (MCP) connector feature that allows users to define custom API endpoints as tools that the AI agent can invoke during conversations. The implementation includes a database migration to add the MCP_CONNECTOR type, backend CRUD endpoints for managing MCP connectors with dynamic LangChain tool generation from JSON configurations, and a frontend UI for creating multi-tool connectors with support for multiple HTTP methods (GET, POST, PUT, PATCH, DELETE) and authentication types (Bearer, API Key, Basic Auth, None). Tools are loaded dynamically from the database on each chat session with permission-based access control, and the feature includes comprehensive documentation guides for both backend and frontend implementation.

⏱️ Estimated Review Time: 30-90 minutes

💡 Review Order Suggestion
Order File Path
1 MCP_IMPLEMENTATION.md
2 MCP_FRONTEND_GUIDE.md
3 surfsense_backend/alembic/versions/60_add_mcp_connector_type.py
4 surfsense_backend/app/db.py
5 surfsense_backend/app/schemas/search_source_connector.py
6 surfsense_backend/app/schemas/__init__.py
7 surfsense_web/contracts/enums/connector.ts
8 surfsense_web/contracts/enums/connectorIcons.tsx
9 surfsense_web/contracts/types/connector.types.ts
10 surfsense_web/contracts/types/mcp.types.ts
11 surfsense_backend/app/agents/new_chat/tools/mcp_tool.py
12 surfsense_backend/app/agents/new_chat/tools/registry.py
13 surfsense_backend/app/routes/search_source_connectors_routes.py
14 surfsense_web/lib/apis/connectors-api.service.ts
15 surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx
16 surfsense_web/components/assistant-ui/connector-popup/connector-configs/components/mcp-config.tsx
17 surfsense_web/components/assistant-ui/connector-popup/connect-forms/index.tsx
18 surfsense_web/components/assistant-ui/connector-popup/connector-configs/index.tsx
19 surfsense_web/components/assistant-ui/connector-popup/connector-configs/views/connector-connect-view.tsx
20 surfsense_web/components/assistant-ui/connector-popup/constants/connector-constants.ts
21 surfsense_backend/app/agents/new_chat/chat_deepagent.py
22 surfsense_backend/app/tasks/chat/stream_new_chat.py
23 surfsense_backend/app/utils/connector_naming.py
24 surfsense_web/components/assistant-ui/connector-popup/components/connector-card.tsx
25 surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx
26 surfsense_web/components/assistant-ui/connector-popup/views/connector-accounts-list-view.tsx

Need help? Join our Discord

Analyze latest changes

@vercel
Copy link

vercel bot commented Jan 12, 2026

@manojag115 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

@recurseml recurseml bot left a comment

Choose a reason for hiding this comment

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

Review by RecurseML

🔍 Review performed on 7ac7cd5..cd83a59

  Severity     Location     Issue     Delete  
High surfsense_web/components/assistant-ui/connector-popup/connect-forms/components/mcp-connect-form.tsx:265 API key auth field mismatch
High surfsense_backend/app/agents/new_chat/tools/mcp_tool.py:169 SSL verification disabled
✅ Files analyzed, no issues (24)

MCP_FRONTEND_GUIDE.md
MCP_IMPLEMENTATION.md
surfsense_backend/alembic/versions/60_add_mcp_connector_type.py
surfsense_backend/app/agents/new_chat/chat_deepagent.py
surfsense_backend/app/agents/new_chat/tools/registry.py
surfsense_backend/app/db.py
surfsense_backend/app/routes/search_source_connectors_routes.py
surfsense_backend/app/schemas/__init__.py
surfsense_backend/app/schemas/search_source_connector.py
surfsense_backend/app/tasks/chat/stream_new_chat.py
surfsense_backend/app/utils/connector_naming.py
surfsense_web/components/assistant-ui/connector-popup/components/connector-card.tsx
surfsense_web/components/assistant-ui/connector-popup/connect-forms/index.tsx
surfsense_web/components/assistant-ui/connector-popup/connector-configs/components/mcp-config.tsx
surfsense_web/components/assistant-ui/connector-popup/connector-configs/index.tsx
surfsense_web/components/assistant-ui/connector-popup/connector-configs/views/connector-connect-view.tsx
surfsense_web/components/assistant-ui/connector-popup/constants/connector-constants.ts
surfsense_web/components/assistant-ui/connector-popup/tabs/active-connectors-tab.tsx
surfsense_web/components/assistant-ui/connector-popup/views/connector-accounts-list-view.tsx
surfsense_web/contracts/enums/connector.ts
surfsense_web/contracts/enums/connectorIcons.tsx
surfsense_web/contracts/types/connector.types.ts
surfsense_web/contracts/types/mcp.types.ts
surfsense_web/lib/apis/connectors-api.service.ts

<div className="space-y-2">
<Label>API Key Value *</Label>
<Input
value={tool.auth_config.key_value || ""}
Copy link

Choose a reason for hiding this comment

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

Frontend-backend field name mismatch in MCP connector API key authentication. The connect form uses 'key_value' for the API key value (line 265), but the backend expects 'api_key' (mcp_tool.py line 56). When a user creates an MCP connector with API key authentication through the connect form, the auth config will be saved with 'key_value' instead of 'api_key'. At runtime, when the agent tries to call the MCP tool, _build_auth_headers() will not find the 'api_key' field (it'll be an empty string), resulting in API requests being sent without the API key in headers. This will cause 401 Unauthorized errors from the remote API. The edit form (mcp-config.tsx line 266) correctly uses 'api_key', showing this is an inconsistency bug.


React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

logger.info(f"Making {method} request to {endpoint}")

# Make HTTP request (disable SSL verification for user-provided endpoints)
async with httpx.AsyncClient(timeout=30.0, verify=False) as client:
Copy link

Choose a reason for hiding this comment

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

SSL certificate verification is disabled (verify=False) for all HTTP requests to user-provided MCP tool endpoints. This makes the application vulnerable to man-in-the-middle (MITM) attacks. An attacker on the network could intercept HTTPS requests to MCP endpoints, read sensitive data (API keys, request/response payloads), and modify responses. Since MCP tools are user-defined and can call any API (including APIs handling sensitive data), this could lead to credential theft, data exfiltration, or injection of malicious responses into the agent's context. While the PR description mentions this is intentional for 'user endpoints', this is a critical security vulnerability that should not be in production code. Best practice: SSL verification should be enabled by default, with an optional per-tool configuration flag if users need to disable it for specific self-signed certificate scenarios.


React with 👍 to tell me that this comment was useful, or 👎 if not (and I'll stop posting more comments like this in the future)

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