Skip to content

feat: Temporal MCP tool selection for agentic search #714

@manavgup

Description

@manavgup

Summary

Enable users to select MCP tools at search time to generate artifacts (PowerPoint, charts, PDFs, etc.) from search results. This uses a temporal/per-request selection model - no database persistence required.

Key Design Decision: Tools are selected per-search request, not configured per-collection. This simplifies implementation and provides maximum flexibility.

Background

This issue implements a simplified approach to agentic RAG that builds on the recently merged MCP Context Forge integration (PR #684). Instead of the database-backed agent configuration described in #697, we start with temporal tool selection and can add persistence later if needed.

Why Temporal First?

Approach Pros Cons
Temporal (this issue) Simple, no DB changes, maximum flexibility Users re-select tools each time
Persistent (#697) "Remember my preferences" Complex, requires DB schema, migrations

We can add optional persistence in a future phase once the core flow is validated.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                      Search Interface                            │
│  ┌───────────────────────────────────────────────────────────┐  │
│  │ 🔍 What were Q4 revenue projections?           [Search]   │  │
│  └───────────────────────────────────────────────────────────┘  │
│                                                                  │
│  Available Tools: (live from MCP Context Forge)                 │
│  ┌────────────┐ ┌────────────┐ ┌────────────┐                  │
│  │ ☑️ PPT Gen │ │ ☑️ Chart   │ │ ☐ PDF      │                  │
│  └────────────┘ └────────────┘ └────────────┘                  │
└──────────────────────────┬──────────────────────────────────────┘
                           │
         POST /api/search  │  { question, collection_id,
                           │    selected_tools: ["ppt-gen", "chart-gen"] }
                           ▼
┌─────────────────────────────────────────────────────────────────┐
│                      SearchService                               │
│  1. Core RAG pipeline → answer + sources                        │
│  2. Execute selected tools (parallel) → artifacts               │
│  3. Return answer + artifacts                                   │
└──────────────────────────┬──────────────────────────────────────┘
                           │
                           ▼
┌─────────────────────────────────────────────────────────────────┐
│              MCP Context Forge (already integrated)              │
│              Tools: ppt-generator, chart-generator, etc.        │
└─────────────────────────────────────────────────────────────────┘

Implementation Tasks

Phase 1: Backend (3-4 days)

  • Update SearchInput schema to accept selected_tools: list[str]
  • Create ToolArtifact and ToolExecution schemas
  • Update SearchResponse to include artifacts and tool_executions
  • Create ToolExecutorService for parallel tool execution
  • Integrate tool execution into SearchService (after answer generation)
  • Add GET /api/mcp/tools/available endpoint for tool discovery
  • Unit tests for ToolExecutorService (80%+ coverage)
  • Integration tests with mock MCP tools

Phase 2: Frontend (2-3 days)

  • Create ToolPicker component (fetches available tools, toggle selection)
  • Create ArtifactPanel component (display generated artifacts)
  • Create ArtifactCard component (preview + download button)
  • Integrate ToolPicker into search interface
  • Integrate ArtifactPanel into search results
  • Handle loading states and errors gracefully
  • Responsive design (mobile-friendly)

Phase 3: Sample Tools (2-3 days)

  • Create ppt-generator MCP tool for PowerPoint generation
  • Create chart-generator MCP tool for data visualization
  • Deploy sample tools to MCP Context Forge
  • End-to-end testing with real tool invocation
  • Documentation for creating custom tools

Dependencies

Related Issues

Acceptance Criteria

  • User can see available MCP tools in search interface
  • User can select one or more tools before searching
  • Search executes normally, then runs selected tools
  • Generated artifacts appear in search results
  • User can download artifacts (PowerPoint, charts, etc.)
  • Tool failures don't break search (graceful degradation)
  • Tool execution is parallel (performance)
  • Works on desktop and mobile

Future Enhancements (Not in Scope)

These can be added in future issues:

References

  • Planning doc: docs/planning/agentic-rag-implementation-plan.md
  • MCP integration: docs/features/mcp-integration.md
  • Architecture: docs/architecture/search-agent-hooks-architecture.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    agenticAgentic AI featuresbackendBackend/API relatedenhancementNew feature or requestfrontendFrontend/UI relatedpriority:highHigh priority - important for releaseragRAG pipeline and search

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions