Context-Store-LLM / mcp-server-setup.md
BarisT
Clean Context Store for HuggingFace deployment
5b12974
|
Raw History Blame Contribute Delete
5.53 kB
# Context Store MCP Server Setup
## Cloud MCP Server Configuration
Once Context Store is deployed to HuggingFace, you can access it from any device using the MCP protocol.
### Add to Claude Code
```bash
# Add Context Store MCP server
claude mcp add context-store https://your-username-context-store.hf.space
# Verify connection
claude mcp list
```
### MCP Configuration File
Create or update `~/.claude/mcp.json`:
```json
{
"servers": {
"context-store": {
"command": "node",
"args": ["-e", "
const https = require('https');
const readline = require('readline');
const baseUrl = 'https://your-username-context-store.hf.space';
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('line', async (input) => {
try {
const request = JSON.parse(input);
if (request.method === 'tools/list') {
console.log(JSON.stringify({
jsonrpc: '2.0',
id: request.id,
result: {
tools: [
{
name: 'add_memory',
description: 'Add content to Context Store memory',
inputSchema: {
type: 'object',
properties: {
content: { type: 'string', description: 'Content to store' },
source: { type: 'string', description: 'Source identifier' }
},
required: ['content']
}
},
{
name: 'search_memory',
description: 'Search Context Store memory',
inputSchema: {
type: 'object',
properties: {
query: { type: 'string', description: 'Search query' },
limit: { type: 'number', description: 'Max results' }
},
required: ['query']
}
}
]
}
}));
}
else if (request.method === 'tools/call') {
const { name, arguments: args } = request.params;
if (name === 'add_memory') {
const response = await fetch(`${baseUrl}/api/v1/add`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
episodeBody: args.content,
source: args.source || 'mcp'
})
});
const data = await response.json();
console.log(JSON.stringify({
jsonrpc: '2.0',
id: request.id,
result: { content: [{ type: 'text', text: JSON.stringify(data) }] }
}));
}
else if (name === 'search_memory') {
const response = await fetch(`${baseUrl}/api/v1/search?q=${encodeURIComponent(args.query)}&limit=${args.limit || 10}`);
const data = await response.json();
console.log(JSON.stringify({
jsonrpc: '2.0',
id: request.id,
result: { content: [{ type: 'text', text: JSON.stringify(data) }] }
}));
}
}
} catch (error) {
console.log(JSON.stringify({
jsonrpc: '2.0',
id: request.id,
error: { code: -1, message: error.message }
}));
}
});
"]
}
}
}
```
### Alternative: Use Claude Code Built-in MCP
If using Claude Code's MCP capabilities:
```bash
# Direct HTTP MCP connection
claude config set mcp.context-store.url "https://your-username-context-store.hf.space"
claude config set mcp.context-store.type "http"
# Test connection
claude mcp test context-store
```
## Usage Examples
### Add Memory
```bash
claude -m "Add this conversation to my Context Store" --mcp context-store
```
### Search Memory
```bash
claude -m "Search my Context Store for React patterns" --mcp context-store
```
### Automatic Memory
```bash
# Configure auto-save to Context Store
claude config set memory.provider "context-store"
claude config set memory.auto-save true
```
## Device Setup
### Windows
```cmd
# Install Claude Code
npm install -g @anthropic/claude-code
# Add MCP server
claude mcp add context-store https://your-space.hf.space
```
### macOS/Linux
```bash
# Install Claude Code
curl -fsSL https://claude.ai/install.sh | sh
# Add MCP server
claude mcp add context-store https://your-space.hf.space
```
### Mobile (Termux/iSH)
```bash
# Install Node.js and Claude Code
pkg install nodejs-lts
npm install -g @anthropic/claude-code
# Configure MCP
claude mcp add context-store https://your-space.hf.space
```
## Benefits
✅ **Universal Access**: Same memory on all devices
✅ **No Local Setup**: No Docker, databases, or services needed
✅ **Always Available**: HuggingFace handles uptime and scaling
✅ **Free Tier**: No hosting costs for development usage
✅ **MCP Protocol**: Standard AI tool integration
✅ **Real-time Sync**: Changes available immediately everywhere