PI

Pinecone MCP Server for RAG and Inference

Enable RAG and inference with an MCP server to search and upload records while leveraging Pinecone's Inference API for fast contextual retrieval

Quick Install
npx -y @sirmews/mcp-pinecone

Overview

This MCP (Model Context Protocol) server provides a lightweight bridge between your application and Pinecone for fast contextual retrieval and inference-driven RAG (Retrieval-Augmented Generation) workflows. It exposes simple HTTP endpoints to upload/search records (vectors + metadata) in Pinecone and to leverage Pinecone’s Inference API to generate context-aware responses or to produce embeddings when needed.

The server is useful when you want a minimal, developer-friendly service that implements the common MCP pattern: store documents in a vector database, retrieve relevant context for a user query, and run a model against that context. It removes boilerplate for integrating Pinecone’s vector index and Inference API so you can focus on prompt logic and application-level behavior.

Features

  • Upload and upsert records (id, text, metadata, vector) into a Pinecone index
  • Query/semantic search over stored records with top-K results
  • Optional embedding generation to populate vectors before upsert
  • Proxy/invoke Pinecone Inference API for generative or embedding models
  • Simple HTTP API adhering to common MCP patterns, suitable for RAG pipelines
  • Configurable by environment variables; runs locally or in containers

Installation / Configuration

Clone, install dependencies, and run:

# Clone the repo
git clone https://github.com/sirmews/mcp-pinecone.git
cd mcp-pinecone

# Install (Node.js example)
npm install

# Run locally
npm run start

Or use Docker:

# Build and run container
docker build -t mcp-pinecone .
docker run -p 8080:8080 \
  -e PINECONE_API_KEY=your_key \
  -e PINECONE_ENVIRONMENT=us-west1-gcp \
  -e PINECONE_INDEX=your-index \
  -e PINECONE_PROJECT=your-project \
  mcp-pinecone

Required environment variables:

VariableDescription
PINECONE_API_KEYYour Pinecone API key
PINECONE_ENVIRONMENTPinecone environment name (region)
PINECONE_INDEXName of the Pinecone vector index to use
PORTPort for the MCP server (default 8080)
MODEL(Optional) Pinecone Inference model identifier for generation/embeddings

Example .env (local development):

PINECONE_API_KEY=xxxxxxxxxxxxxxxxxxxx
PINECONE_ENVIRONMENT=us-west1-gcp
PINECONE_INDEX=mcp-example
PORT=8080
MODEL=local/generative-model

Available Resources

Common HTTP endpoints (example; check the repo for exact route names and payload schemas):

  • POST /records
    • Upsert one or more records into Pinecone
    • Payload: { records: [{ id, text, metadata?, vector? }] }
  • POST /search
    • Semantic query against the index
    • Payload: { query, topK, includeMetadata? }
    • Response: list of matching records with scores
  • POST /inference
    • Invoke Pinecone Inference API with retrieved context or prompt
    • Payload: { model, prompt, maxTokens?, context? }
  • GET /health
    • Basic healthcheck for the MCP server

Example record schema:

{
  "id": "doc-123",
  "text": "Short passage or document text...",
  "metadata": { "source": "manual", "tags": ["faq"] },
  "vector": [0.01, -0.23, 0.45] // optional if server can compute embeddings
}

Use Cases

  1. RAG for customer support

    • Upload product manuals and support articles as records.
    • A user asks a question; call /search with the question text to retrieve the top-K relevant passages.
    • Send the retrieved passages as context to /inference together with a prompt template. The Inference API generates a concise, context-grounded response.
  2. Document search with fallback embedding generation

    • If a record lacks vectors, the server can call Pinecone’s embedding model (via Inference API) to compute embeddings before upsert.
    • This enables bulk ingestion where only raw text is provided.
  3. Semantic filtering and metadata-aware retrieval

    • Use metadata fields (e.g., language, version, source) to filter or re-rank search results returned by /search.
    • Combine with prompt engineering in /inference to produce answers constrained to the desired subset.

Concrete examples

Upload a record:

curl -X POST http://localhost:8080/records \
  -H "Content-Type: application/json" \
  -d '{
    "records":[{"id":"r1","text":"How to reset your password","metadata":{"topic":"auth"}}]
  }'

Search and generate an answer:

# Step 1: semantic search
curl -s -X POST http://localhost:8080/search \
  -H "Content-Type: application/json" \
  -d '{"query":"How do I reset my password?","topK":3}' \
  | tee results.json

# Step 2: call inference with retrieved context
curl -X POST http://localhost:8080/inference \
  -H "Content-Type: application/json" \
  -d '{
    "model":"your-inference-model",
    "prompt":"Use the context to answer briefly",
    "context":'"$(jq -c . results.json)"',
    "maxTokens": 200
  }'

Notes and Next Steps

  • Inspect the repository for configuration hooks, middleware, and exact request/response formats.
  • Secure your deployment: restrict access to the MCP server, rotate keys, and enable logging/monitoring.
  • The server is intentionally minimal to be extended: add authentication, batching, or custom prompt templates to fit your RAG pipeline.