RAG MCP Server
MCP (Model Context Protocol) server for RAG (Retrieval-Augmented Generation) using Pinecone, OpenAI-compatible embedding APIs, and the official MCP SDK. Save documents and search by semantic similarity via MCP tools.
Add to MCP clients
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"rag": {
"command": "npx",
"args": ["-y", "@laskarks/mcp-rag-node"],
"env": {
"APIKEY": "sk-...",
"EMBEDDING_MODEL": "text-embedding-3-small",
"RAG_CHUNK_MAX_TOKENS": 1536,
"PINECONE_API_KEY": "...",
"PINECONE_INDEX": "rag-index",
"PROVIDER": "openai | openrouter"
}
}
}
}
Cursor (.cursor/mcp.json or MCP settings):
{
"mcpServers": {
"rag": {
"command": "npx",
"args": ["-y", "@laskarks/mcp-rag-node"],
"env": {
"APIKEY": "sk-...",
"EMBEDDING_MODEL": "text-embedding-3-small",
"RAG_CHUNK_MAX_TOKENS": 1536,
"PINECONE_API_KEY": "...",
"PINECONE_INDEX": "rag-index",
"PROVIDER": "openai | openrouter"
}
}
}
}
Tools
Installation
npm i @laskarks/mcp-rag-node
Environment Variables
Required
Important: Create your Pinecone index with the same dimension as your embedding model.
Embedding models and vector dimensions
Use the Dimension column when creating your Pinecone index.
For OpenRouter, use the model ID format, e.g. openai/text-embedding-3-small or voyage/voyage-3.
Optional
Usage
Run the server
npm run build
npm start
Or with env file:
# .env
APIKEY=sk-...
EMBEDDING_MODEL=text-embedding-3-small
PINECONE_API_KEY=...
PINECONE_INDEX=rag-index
PROVIDER=openai
npm start
Development
# Install dependencies
npm install
# Build
npm run build
# Run server (from compiled JS)
npm start
# Run server (dev, from TypeScript)
npm run dev
# Run sample client
npm run client
Project structure
src/
├── index.ts # MCP server entry, tools registration
├── ai.ts # AI controller (chunking, embeddings, Pinecone)
├── env.ts # Environment loading
└── client.ts # Example MCP client for testing
dist/ # Compiled output (after npm run build)
Publish to npm
Before publishing:
- Add
filestopackage.jsonto include onlydist/and docs:
"files": ["dist", "README.md"]
- Ensure
npm run buildsucceeds anddist/is committed or built on publish. - Add
binentry fornpx rag-mcp-nodejs(optional):
"bin": { "rag-mcp-nodejs": "dist/index.js" }
Note: MCP servers are usually run via node dist/index.js; a bin is optional. 4. Set a unique package name (npm may require scoped name, e.g. @yourname/rag-mcp-nodejs). 5. Add repository, homepage, and engines.node in package.json (optional but recommended).
Requirements
- Node.js >= 18
- Pinecone account
- OpenAI or OpenRouter API key
License
ISC