MCP API Setup Guide
Connect AI agents like Claude to your Napatam documents using the Model Context Protocol (MCP).
Quick Start
1. Create an API Key
- Go to Settings → AI tab
- Click "Create API Key"
- Enter a name (e.g., "Claude Desktop")
- Copy and save the generated key immediately
2. Configure Your MCP Client
🚀 Option A: NPX (Easiest - No Download Required)
✨ Recommended: Uses NPX to run the MCP client directly from URL - always up-to-date, no local files needed!
For Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json
on macOS or %APPDATA%/Claude/claude_desktop_config.json
on
Windows):
{
"mcpServers": {
"napatam": {
"command": "npx",
"args": ["https://napatam.ru/napatam-mcp-standalone.tgz"],
"env": {
"NAPATAM_BASE_URL": "https://napatam.ru",
"NAPATAM_API_KEY": "YOUR_API_KEY"
}
}
}
}
For Warp AI (in your Warp MCP settings):
{
"napatam": {
"command": "npx",
"args": ["https://napatam.ru/napatam-mcp-standalone.tgz"],
"env": {
"NAPATAM_BASE_URL": "https://napatam.ru",
"NAPATAM_API_KEY": "YOUR_API_KEY"
}
}
}
📥 Option B: Local Installation
Step 1: Download the Napatam MCP client script
curl -o napatam-mcp-standalone.js https://napatam.ru/napatam-mcp-standalone.js
chmod +x napatam-mcp-standalone.js
Step 2: Add to your MCP configuration
For Claude Desktop:
{
"mcpServers": {
"napatam": {
"command": "node",
"args": ["path/to/napatam-mcp-standalone.js"],
"env": {
"NAPATAM_BASE_URL": "https://napatam.ru",
"NAPATAM_API_KEY": "YOUR_API_KEY"
}
}
}
}
For Warp AI:
{
"napatam": {
"command": "node",
"args": ["path/to/napatam-mcp-standalone.js"],
"env": {
"NAPATAM_BASE_URL": "https://napatam.ru",
"NAPATAM_API_KEY": "YOUR_API_KEY"
}
}
}
Manual Setup (If Download Doesn't Work)
Create napatam-mcp.js manually
Create a file called napatam-mcp.js
with this content:
#!/usr/bin/env node
// Napatam MCP Client Bridge
// Connects Napatam's HTTP MCP API to MCP clients like Claude Desktop
const http = require('http');
const https = require('https');
const { URL } = require('url');
const baseUrl = process.env.NAPATAM_BASE_URL;
const apiKey = process.env.NAPATAM_API_KEY;
if (!baseUrl || !apiKey) {
console.error('NAPATAM_BASE_URL and NAPATAM_API_KEY environment variables required');
process.exit(1);
}
// HTTP client selection
const client = baseUrl.startsWith('https:') ? https : http;
// Make HTTP request to Napatam API
function makeRequest(path, options = {}) {
return new Promise((resolve, reject) => {
const url = new URL(path, baseUrl);
const req = client.request(url, {
method: options.method || 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json',
...options.headers
}
}, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
try {
resolve({ statusCode: res.statusCode, data: JSON.parse(data) });
} catch (e) {
resolve({ statusCode: res.statusCode, data: { error: 'Invalid JSON response' } });
}
});
});
req.on('error', reject);
if (options.body) {
req.write(JSON.stringify(options.body));
}
req.end();
});
}
// MCP JSON-RPC handler
process.stdin.on('data', async (chunk) => {
try {
const lines = chunk.toString().trim().split('\n');
for (const line of lines) {
if (!line.trim()) continue;
const request = JSON.parse(line);
let response;
switch (request.method) {
case 'initialize':
response = {
jsonrpc: '2.0',
id: request.id,
result: {
protocolVersion: '2024-11-05',
capabilities: {
tools: {},
resources: {}
},
serverInfo: {
name: 'napatam',
version: '1.0.0'
}
}
};
break;
case 'tools/list':
const toolsRes = await makeRequest('/mcp/tools');
response = {
jsonrpc: '2.0',
id: request.id,
result: toolsRes.data
};
break;
case 'tools/call':
const callRes = await makeRequest('/mcp/tools/call', {
method: 'POST',
body: {
name: request.params.name,
arguments: request.params.arguments
}
});
response = {
jsonrpc: '2.0',
id: request.id,
result: callRes.data
};
break;
case 'resources/list':
const resourcesRes = await makeRequest('/mcp/resources');
response = {
jsonrpc: '2.0',
id: request.id,
result: resourcesRes.data
};
break;
case 'resources/read':
const readRes = await makeRequest(`/mcp/resources/content?uri=${encodeURIComponent(request.params.uri)}`);
response = {
jsonrpc: '2.0',
id: request.id,
result: readRes.data
};
break;
default:
response = {
jsonrpc: '2.0',
id: request.id,
error: {
code: -32601,
message: `Method not found: ${request.method}`
}
};
}
console.log(JSON.stringify(response));
}
} catch (error) {
const errorResponse = {
jsonrpc: '2.0',
id: null,
error: {
code: -32700,
message: `Parse error: ${error.message}`
}
};
console.log(JSON.stringify(errorResponse));
}
});
// Handle process termination
process.on('SIGINT', () => process.exit(0));
process.on('SIGTERM', () => process.exit(0));
What You Can Do
Once connected, AI agents can:
- Search your documents by content, title, or tags
- Browse by tags to access specific topic areas
- Read summaries and full content of saved articles
- Access metadata like URLs and creation dates
Usage Examples
Tell Your AI Agent:
- "Search my documents for React tutorials"
- "Show me all my machine-learning articles"
- "Find documents tagged 'work' from this month"
Available Tools:
search_documents
- Search by text or tagsget_documents_by_tag
- Get all docs with specific taglist_available_tags
- See all your tags
API Examples
Search Documents
curl -X POST "https://napatam.ru/mcp/tools/call" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"name": "search_documents",
"arguments": {
"query": "React hooks",
"limit": 10
}
}'
Get Documents by Tag
curl -X POST "https://napatam.ru/mcp/tools/call" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"name": "get_documents_by_tag",
"arguments": {
"tag": "javascript",
"limit": 20
}
}'
List Available Tags
curl -X POST "https://napatam.ru/mcp/tools/call" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"name": "list_available_tags",
"arguments": {}
}'
Advanced Configuration
Base URL: https://napatam.ru/mcp/
Authentication:
Authorization: Bearer YOUR_API_KEY
Alternative auth methods:
X-API-Key: YOUR_API_KEY
?api_key=YOUR_API_KEY
Troubleshooting
Common Issues:
- 401 Unauthorized: Check your API key is correct and hasn't expired
- 404 Not Found: Tag or resource doesn't exist
- No results: Try broader search terms
- NPX not found: Make sure Node.js and npm are installed
- Connection timeout: Check your internet connection
NPX Benefits:
- ✅ Always up-to-date: Fetches latest version from server
- ✅ No local files: Nothing to download or manage
- ✅ Automatic updates: Changes deploy automatically
- ✅ Cross-platform: Works on macOS, Windows, Linux
- ✅ Proper NPM package: The
.tgz
format ensures npx compatibility - ✅ Auto-dependencies: MCP SDK dependencies install automatically
What's New: We now serve a proper NPM package tarball (.tgz
) instead of raw JavaScript, which fixes compatibility issues and ensures reliable npx execution across all platforms.
If NPX doesn't work:
Use Option B (Local Installation) or check that you have Node.js installed:
node --version
npm --version