Rag Node
Simple MCP RAG server using @modelcontextprotocol/sdk
Ask AI about Rag Node
Powered by Claude Β· Grounded in docs
I know everything about Rag Node. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
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
| Tool | Description |
|---|---|
save_to_rag | Chunk text, create embeddings, and save to Pinecone. |
search_document_on_rag | Search documents by keyword using semantic similarity. |
Installation
npm i @laskarks/mcp-rag-node
Environment Variables
Required
| Variable | Description | Example |
|---|---|---|
APIKEY | OpenAI or OpenRouter API key for embeddings | sk-... |
EMBEDDING_MODEL | Embedding model ID | text-embedding-3-small, openai/text-embedding-3-small |
PINECONE_API_KEY | Pinecone API key | ... |
PINECONE_INDEX | Pinecone index name (dimension must match embedding model) | rag-index |
PROVIDER | AI provider (allowed values: openai, openrouter) | openai or openrouter |
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.
| Model | Dimension | Provider |
|---|---|---|
text-embedding-3-small | 1536 | OpenAI, OpenRouter |
text-embedding-3-large | 3072 | OpenAI, OpenRouter |
text-embedding-ada-002 | 1536 | OpenAI, OpenRouter |
text-embedding-3-small (with dimensions param) | 512β1536 | OpenAI |
voyage-3 | 1024 | Voyage (via OpenRouter) |
nomic-embed-text-v1.5 | 768 | Nomic (via OpenRouter) |
mistral-embed | 1024 | Mistral (via OpenRouter) |
cohere/embed-english-v3.0 | 1024 | Cohere (via OpenRouter) |
For OpenRouter, use the model ID format, e.g. openai/text-embedding-3-small or voyage/voyage-3.
Optional
| Variable | Description | Default |
|---|---|---|
RAG_CHUNK_MAX_TOKENS | Max tokens per chunk before embedding | 1536 |
RAG_CHUNK_OVERLAP | Overlap tokens between chunks | 50 |
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
