Skip to content

MAPLE MCP server creation for RAG workflows#2141

Draft
nesanders wants to merge 11 commits into
codeforboston:mainfrom
nesanders:mcp-server-setup
Draft

MAPLE MCP server creation for RAG workflows#2141
nesanders wants to merge 11 commits into
codeforboston:mainfrom
nesanders:mcp-server-setup

Conversation

@nesanders
Copy link
Copy Markdown
Collaborator

@nesanders nesanders commented May 15, 2026

MAPLE MCP Server & RAG Infrastructure

This PR implements a comprehensive Model Context Protocol (MCP) server for the MAPLE platform and upgrades the platform's vector search infrastructure to support Gemini-based RAG workflows.

Key Components

1. Model Context Protocol (MCP) Server

  • New Package: Introduced a standalone MCP server in the mcp-server/ directory.
  • Unified Search Tools: Implemented semantic search tools for:
    • Bills: Search legislative bills with filters.
    • Testimony: Search published testimony with billId or ballotQuestionId filtering.
    • Ballot Questions: Search ballot questions.
    • Policies: Unified search across multiple policy types.
  • Authentication: Secured the server with a Firestore-based API key layer (agentKeys collection).
  • Deployment Ready: Configured for Google Cloud Run with .env.example and optimized dependencies.

2. Gemini Embedding 2 Migration

  • High-Dimension Vectors: Migrated all vector indexing logic from 768 to 3072 dimensions using gemini-embedding-2.
  • Dynamic Response Handling: Updated all embedding utilities to robustly handle Vertex AI's evolving API response structures (embedding vs embeddings).
  • Instruction-Tuned Prefixing: Implemented the required instruction-tuned prefixes for queries (task: search result | query: ...) and documents (title: ... | text: ...).

3. Backend & Data Infrastructure

  • Real-time Indexing: Updated the Cloud Functions for bills, testimony, and ballot questions to use the new embedding model and dimensions.
  • Composite Vector Indexes: Added the necessary Firestore index configurations in firestore.indexes.json to support filtered vector queries.
  • Administrative Tools:
    • Backfill Script: Created backfill-embeddings.ts for batch migrating existing documents to the 3072-dim format.
    • Sync Utility: Updated syncBallotQuestions.ts for data consistency.

4. Developer Experience & CI/CD

  • Environment Synchronization: Updated package.json and yarn.lock (root and functions) to resolve dependency conflicts.
  • Type Safety: Resolved project-wide TypeScript deprecations and Node.js type mismatches.
  • Coding Standards: Applied Prettier formatting and ESLint fixes across all new and modified files.

Status

✅ Completed

  • MCP Server core implementation and tool registration.
  • Transition to Gemini Embedding 2 (3072 dimensions).
  • Updated Cloud Functions for real-time vector indexing.
  • Firestore Index configurations for DEV.
  • Resolution of all CI/CD blockers.

⏳ Pending Actions (Post-Merge)

  • Index Deployment: Run firebase deploy --only firestore:indexes in the target environment.
  • Data Migration: Execute the backfill script to populate 3072-dim vectors for existing records.
  • Container Deployment: Deploy the MCP server image to Cloud Run.

This PR represents the foundational infrastructure for AI-driven legislative analysis on the MAPLE platform.

@nesanders nesanders self-assigned this May 15, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maple-dev Ready Ready Preview, Comment May 15, 2026 5:27pm

Request Review

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