Stage AI MCP

Stage AI MCP

This MCP server replicates how a creative strategist gathers context by expanding queries and performing hybrid search against a Google Drive knowledge base, delivering structured, role-categorized context for ad copy and creative briefs.

Category
访问服务器

README

Stage AI MCP

A Model Context Protocol (MCP) server that replicates how a creative strategist gathers and structures context before writing ad copy, scripts, or briefs. Built with FastMCP, it connects an agency's Google Drive knowledge base directly to LLMs and delivers structured, role-categorized context through an advanced RAG pipeline.

The Problem

Creative strategists spend significant time gathering context before producing work: reviewing brand guidelines, studying top-performing ads, referencing proven frameworks. This context gathering is what separates good creative output from generic content. Most RAG implementations treat retrieval as a flat keyword lookup, missing the structured thinking that makes strategists effective.

How It Works

Stage AI MCP models the context-gathering workflow of a creative strategist through a multi-stage retrieval pipeline:

┌─────────────┐  Query   ┌─────────────────┐  Expanded   ┌─────────────┐
│   FastMCP    │────────>│ Claude 3.5 Haiku │  Queries   >│  ChromaDB   │
│   Server     │         │ Query Expansion  │             │   Search    │
└─────────────┘          └─────────────────┘             └─────────────┘
                                                                │
                                                       Semantic Results
                                                                v
┌─────────────┐ Ranked   ┌─────────────────────────────────────────┐
│   Response   │<─────────│  Hybrid BM25 + Semantic Fusion          │
│ (Structured) │          │  with RRF (Reciprocal Rank Fusion)      │
└─────────────┘          └─────────────────────────────────────────┘

1. Query Expansion (Thinking Like a Strategist)

A single query like "write a testimonial script for a recovery product" gets expanded by Claude 3.5 Haiku into multiple semantically related queries that cover the angles a strategist would naturally consider: brand voice guidelines, high-performing testimonial examples, audience pain points, product benefit frameworks.

2. Hybrid Search (Comprehensive Retrieval)

Each expanded query runs against ChromaDB using OpenAI text-embedding-3-large embeddings. Results are then re-ranked using a hybrid approach:

  • Semantic similarity via vector search for conceptual matches
  • BM25 keyword matching via MiniSearch for exact terminology
  • Reciprocal Rank Fusion (RRF) to combine both ranking signals into a single score

3. MECE Categorization (Structured Context Delivery)

Retrieved documents are classified into mutually exclusive, collectively exhaustive (MECE) categories that mirror how strategists organize their thinking:

Category Purpose Example Documents
Context & Constraints Brand voice, audience, restrictions Brand guidelines, audience profiles
Task Decomposition Frameworks, processes, how-tos Copywriting playbooks, ad format guides
Examples & Patterns Proven high-performers to reference Top-performing ad analyses, case studies

This structured delivery means the LLM receives context organized by its role in the creative process, not as a flat list of search results.

4. Contextual Embeddings (Document Understanding)

During ingestion, each document chunk is enriched with contextual metadata generated by Claude. This means the embedding captures not just the chunk's content, but its role within the broader document, improving retrieval accuracy for nuanced queries.

Technology Stack

Component Technology Role
Server Framework FastMCP MCP protocol implementation
Vector Database ChromaDB Cloud Semantic similarity search
Embeddings OpenAI text-embedding-3-large High-dimensional vector representations
Query Expansion Claude 3.5 Haiku Multi-angle query generation
Keyword Search MiniSearch BM25 ranking for hybrid fusion
Document Source Google Drive API Knowledge base sync
Validation Zod Type-safe parameter schemas
Transport stdio / HTTP Local MCP clients or cloud deployment

MCP Tool

The server exposes a single tool, find_context:

{
  "name": "find_context",
  "arguments": {
    "query": "write a before/after testimonial script for a freeze roll-on with marathon runner showing immediate relief post-run",
    "limit": 5
  }
}

Returns structured context organized by MECE categories:

Found the 5 most relevant documents:

CONTEXT & CONSTRAINTS (2 documents)
├── Brand_Voice_Guidelines.pdf
└── Target_Audience_Profile.md

EXAMPLES & PATTERNS (3 documents)
├── High_Converting_Ads.md
├── Successful_Campaign_Case_Study.pdf
└── Best_Practice_Templates.md

---

### CONTEXT & CONSTRAINTS
#### Brand_Voice_Guidelines.pdf
*brand strategy*

[Document content...]

### EXAMPLES & PATTERNS
#### High_Converting_Ads.md
*winning examples*

[High-performing examples...]

Project Structure

stage-ai-mcp/
├── src/
│   ├── index.ts                     # FastMCP server entry point
│   └── types/
│       └── fastmcp.d.ts             # Type declarations
├── core/
│   ├── chroma-client.ts             # ChromaDB integration + hybrid search + RRF
│   └── lib/
│       ├── query-expander.ts        # Claude 3.5 Haiku query expansion
│       ├── google-drive.ts          # Google Drive document sync
│       ├── semantic-chunker.ts      # Document chunking for embeddings
│       ├── contextual-embeddings.ts # Contextual embedding generation
│       └── document-processor.ts    # Document processing utilities
├── data/
│   └── scripts/
│       └── sync-drive.ts            # Google Drive -> ChromaDB sync pipeline
├── manifest.json                    # MCP manifest
├── .env.example                     # Required environment variables
└── tsconfig.json                    # TypeScript ES2022 config

Setup

Prerequisites

  • Node.js 18+
  • ChromaDB Cloud account
  • OpenAI API key (for embeddings)
  • Anthropic API key (for query expansion)
  • Google Service Account (for Drive sync)

Installation

npm install
cp .env.example .env.local
# Fill in your API keys in .env.local

Build & Run

# Build TypeScript
npm run build

# Run MCP server (stdio - for local MCP clients)
npm start

# Run in development mode
npm run mcp:dev

# Run with HTTP transport (for development/testing)
npm run mcp:http

# Sync Google Drive documents to ChromaDB
npm run sync-drive

MCP Client Configuration

Add to your MCP client config (e.g., Claude Desktop):

{
  "mcpServers": {
    "stage-ai": {
      "command": "node",
      "args": ["path/to/stage-ai-mcp/dist/src/index.js"],
      "env": {
        "CHROMA_API_KEY": "your_key",
        "CHROMA_TENANT": "your_tenant",
        "CHROMA_DATABASE": "your_database",
        "OPENAI_API_KEY": "your_key",
        "ANTHROPIC_API_KEY": "your_key",
        "AGENCY_ID": "your_agency_id"
      }
    }
  }
}

Search Pipeline Details

Query Expansion: Claude 3.5 Haiku generates 5 additional semantically related queries for each user query, covering complementary angles (brand context, examples, frameworks). Total of 6 queries run per search.

Multi-Query Retrieval: Each of the 6 queries retrieves up to 5 results from ChromaDB, yielding up to 30 candidate documents before deduplication.

Deduplication: Simple set-based deduplication using content as the unique key, preserving discovery order. Typical yield: 10-15 unique documents from 30 candidates.

Hybrid Ranking: RRF fusion with configurable weights (default 0.8 semantic / 0.2 BM25) combines both ranking signals. Final results are sorted by fused score and trimmed to the requested limit.

Related Projects

This is part of the Stage AI suite:

  • Stage AI MCP (this repo) - Context engineering / advanced RAG for creative strategy
  • Stage AI Editor - AI-powered image editing tool

License

ISC

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选