SurfSense icon indicating copy to clipboard operation
SurfSense copied to clipboard

[ROADMAP][1.12] Implement MCP servers for research agent and document retrieval

Open MODSetter opened this issue 11 months ago • 2 comments

Feature Description

Build Model Context Protocol (MCP) servers to expose SurfSense's research agent capabilities and document retrieval as "context as a service". This allows other AI applications to leverage SurfSense's powerful research and retrieval features.

Target Deployment

  • [x] SurfSense Cloud (hosted version)
  • [x] Self-hosted version

Problem Statement

SurfSense's powerful retrieval and research capabilities are currently only accessible through its own interface. By implementing MCP servers, we can:

  • Allow other AI tools to access SurfSense's document store
  • Enable research agent usage from any MCP-compatible client
  • Position SurfSense as infrastructure for AI applications
  • Enable powerful integrations with tools like Claude, Cursor, etc.

Proposed Solution

MCP Server Architecture

┌─────────────────────────────────────────────────────────┐
│              MCP-Compatible Clients                      │
│  [Claude Desktop] [Cursor] [Other MCP Clients]          │
│         │            │            │                      │
│         └────────────┼────────────┘                      │
│                      │                                   │
│                      ▼                                   │
│  ┌─────────────────────────────────────────────────┐    │
│  │         SurfSense MCP Servers                    │    │
│  │                                                  │    │
│  │  ┌─────────────────┐  ┌─────────────────┐      │    │
│  │  │ Retrieval Server │  │ Research Server │      │    │
│  │  │                  │  │                  │      │    │
│  │  │ - search_docs    │  │ - research      │      │    │
│  │  │ - get_document   │  │ - deep_research │      │    │
│  │  │ - list_spaces    │  │ - summarize     │      │    │
│  │  └─────────────────┘  └─────────────────┘      │    │
│  │                      │                          │    │
│  │                      ▼                          │    │
│  │         ┌─────────────────────┐                │    │
│  │         │   SurfSense Core    │                │    │
│  │         │   (API/Database)    │                │    │
│  │         └─────────────────────┘                │    │
│  └─────────────────────────────────────────────────┘    │
└─────────────────────────────────────────────────────────┘

MCP Tools to Implement

Retrieval Server

// Tools
- search_documents: Search across user's documents
- get_document: Retrieve specific document by ID
- list_search_spaces: List available search spaces
- get_recent_documents: Get recently updated documents
- semantic_search: Perform semantic search with filters

// Resources
- document://{space_id}/{doc_id}: Document content
- search_space://{space_id}: Search space metadata

Research Server

// Tools
- quick_research: Fast research on a topic
- deep_research: Comprehensive multi-step research
- summarize_documents: Summarize specific documents
- compare_documents: Compare multiple sources
- extract_facts: Extract key facts from documents

// Resources
- research_history://{user_id}: Past research results

Authentication

  • API key-based authentication
  • Per-user access scoping
  • Rate limiting
  • Audit logging

Benefits

  • Extends SurfSense's reach to entire MCP ecosystem
  • "Context as a Service" business model potential
  • Powerful integrations with AI tools
  • API-first architecture benefits
  • Community-driven use cases

Use Case Examples

  1. User asks Claude to research using their SurfSense documents
  2. Cursor uses SurfSense for codebase-related document retrieval
  3. Custom AI app leverages SurfSense's research capabilities
  4. Team shares research infrastructure via MCP

Implementation Considerations

  • [x] This may require backend changes (MCP server implementation)
  • [ ] This may require frontend changes (configuration UI)
  • [ ] This may require database changes
  • [x] This may affect existing features (uses existing retrieval)

Files to Create

  • surfsense_mcp/ - New MCP server package
  • surfsense_mcp/retrieval_server.py - Retrieval MCP server
  • surfsense_mcp/research_server.py - Research MCP server
  • surfsense_mcp/auth.py - Authentication handling
  • Documentation for MCP setup

Acceptance Criteria

  • [ ] MCP servers implement required protocol
  • [ ] Authentication works correctly
  • [ ] Tools are discoverable by MCP clients
  • [ ] Search/retrieval functions correctly
  • [ ] Research agent accessible via MCP
  • [ ] Rate limiting is enforced
  • [ ] Comprehensive documentation provided
  • [ ] Example configurations for popular clients

Technical Notes

  • Use official MCP Python SDK
  • Implement stdio and HTTP transports
  • Consider SSE for streaming results
  • Add comprehensive error messages
  • Document self-hosting requirements

Resources

Related Issues

  • Depends on: Issues 1.1-1.5 (retriever improvements, deep agent)

MODSetter avatar Dec 11 '25 11:12 MODSetter

Great roadmap for MCP integration! For the research server's paper retrieval needs, you might find BGPT MCP useful as a complementary data source.

It's a remote MCP server that searches scientific papers and returns structured experimental data from full-text studies — methods, results, sample sizes, quality scores, and 25+ metadata fields per paper. Could be a good backend for the quick_research and deep_research tools.

It's already in the Official MCP Registry and works via SSE:

{
  "mcpServers": {
    "bgpt": {
      "command": "npx",
      "args": ["mcp-remote", "https://bgpt.pro/mcp/sse"]
    }
  }
}

connerlambden avatar Feb 24 '26 18:02 connerlambden

This is a great roadmap item. For the research agent's scientific paper capabilities, BGPT MCP might be worth integrating as a data source — it's a hosted MCP server that searches full-text scientific papers and returns structured experimental data (methods, results, quality scores, 25+ fields). Connect to https://bgpt.pro/mcp/sse or run npx bgpt-mcp.

connerlambden avatar Mar 18 '26 00:03 connerlambden

Would I be able to use the Retrieval Server without the Research Server? I use surfsense as an alternative to notebookLM which means I want it to asnwer only based on the sources I provide him with and not internet search or anything which is out of my sources.

danieliyahu1 avatar Apr 12 '26 21:04 danieliyahu1

"tools are discoverable by MCP clients" is the one criterion that can go green and still mean nothing. discoverable in the protocol sense is a tools/list response coming back clean. discoverable in the sense that decides whether this gets used is a person hand-editing a client config, pasting an API key, and restarting the app, and most people never get that far. every box in the list can pass against a test client while the retrieval server ends up in approximately zero real configs. the protocol is the easy half. the install path is where MCP servers quietly die.

m13v avatar Jul 11 '26 04:07 m13v