purmemo-mcp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +32 -0
- package/README.md +260 -0
- package/bin/purmemo-mcp +2 -0
- package/package.json +48 -0
- package/src/index.js +5 -0
- package/src/server.js +236 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Purmemo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIGNED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
IMPORTANT NOTICE:
|
|
26
|
+
|
|
27
|
+
This license applies ONLY to the MCP server implementation in this repository.
|
|
28
|
+
The Purmemo core platform, algorithms, and API service are proprietary and
|
|
29
|
+
protected by separate commercial licenses and patents.
|
|
30
|
+
|
|
31
|
+
For more information about Purmemo's proprietary components, see:
|
|
32
|
+
https://purmemo.ai/terms
|
package/README.md
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# Purmemo MCP Server
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/purmemo-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/purmemo-mcp)
|
|
5
|
+
[](https://github.com/coladapo/purmemo-mcp/stargazers)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://modelcontextprotocol.io)
|
|
8
|
+
|
|
9
|
+
**Official Model Context Protocol (MCP) server for Purmemo** - Your AI-powered second brain with 94% memory retrieval accuracy.
|
|
10
|
+
|
|
11
|
+
π **Never lose a thought again - Purmemo remembers everything so you can focus on what matters.**
|
|
12
|
+
|
|
13
|
+
## ποΈ Architecture: Open Protocol, Protected Innovation
|
|
14
|
+
|
|
15
|
+
This repository contains the **open-source MCP protocol wrapper** that connects to Purmemo's proprietary API:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
|
|
19
|
+
β Claude/Client ββββββΆβ MCP Server ββββββΆβ Purmemo API ββββββΆβ Proprietary β
|
|
20
|
+
β β MCP β (This Repo) β RESTβ (Documented) β β Core Engine β
|
|
21
|
+
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ ββββββββββββββββββββ
|
|
22
|
+
Open Protocol MIT Licensed Terms of Service Trade Secrets
|
|
23
|
+
You Fork You Use Protected IP
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### What's Open Source (This Repository)
|
|
27
|
+
β
MCP protocol implementation
|
|
28
|
+
β
OAuth 2.1 authentication flow
|
|
29
|
+
β
Tool interface definitions
|
|
30
|
+
β
API client wrapper
|
|
31
|
+
β
Documentation and examples
|
|
32
|
+
|
|
33
|
+
### What's Proprietary (Our Secret Sauce)
|
|
34
|
+
π 94% accuracy memory algorithms
|
|
35
|
+
π AI-powered entity extraction
|
|
36
|
+
π <50ms retrieval optimization
|
|
37
|
+
π Workflow intelligence engine
|
|
38
|
+
π Consciousness gradient system
|
|
39
|
+
|
|
40
|
+
## β¨ Features
|
|
41
|
+
|
|
42
|
+
- π§ **Smart Memory Storage** - AI understands context, not just keywords
|
|
43
|
+
- π **Natural Language Search** - "What did I learn about React hooks last month?"
|
|
44
|
+
- π **Rich Attachments** - Files, images, links with automatic metadata
|
|
45
|
+
- π·οΈ **Automatic Entity Extraction** - People, places, topics, dates without manual tagging
|
|
46
|
+
- β‘ **Lightning Fast** - <50ms average retrieval time
|
|
47
|
+
- π **Enterprise Security** - OAuth 2.1 + PKCE, end-to-end encryption
|
|
48
|
+
|
|
49
|
+
## π Quick Start
|
|
50
|
+
|
|
51
|
+
### 1. Get Your API Key
|
|
52
|
+
|
|
53
|
+
Sign up at [app.purmemo.ai](https://app.purmemo.ai) to get your free API key.
|
|
54
|
+
|
|
55
|
+
### 2. Install the MCP Server
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install -g purmemo-mcp
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. Configure Claude Desktop
|
|
62
|
+
|
|
63
|
+
Add to your Claude Desktop configuration:
|
|
64
|
+
|
|
65
|
+
**macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
66
|
+
**Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
67
|
+
**Linux**: `~/.config/Claude/claude_desktop_config.json`
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"mcpServers": {
|
|
72
|
+
"purmemo": {
|
|
73
|
+
"command": "npx",
|
|
74
|
+
"args": ["purmemo-mcp"],
|
|
75
|
+
"env": {
|
|
76
|
+
"PURMEMO_API_KEY": "your-api-key-here"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### 4. Start Using in Claude
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
You: "Remember that the meeting with Sarah is at 3pm tomorrow about the API redesign"
|
|
87
|
+
Claude: "I've stored that memory with entities: Sarah (person), 3pm tomorrow (time), API redesign (topic)"
|
|
88
|
+
|
|
89
|
+
You: "What meetings do I have with Sarah?"
|
|
90
|
+
Claude: "Based on your memories: Tomorrow at 3pm - API redesign discussion"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## π οΈ Available MCP Tools
|
|
94
|
+
|
|
95
|
+
### `memory`
|
|
96
|
+
Store new memories with automatic enhancement
|
|
97
|
+
```typescript
|
|
98
|
+
memory(content: string, metadata?: object): MemoryResponse
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### `recall`
|
|
102
|
+
Retrieve memories using natural language
|
|
103
|
+
```typescript
|
|
104
|
+
recall(query: string, limit?: number): Memory[]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### `entities`
|
|
108
|
+
Explore your automatically extracted knowledge graph
|
|
109
|
+
```typescript
|
|
110
|
+
entities(type?: string, memory_id?: string): Entity[]
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### `attach`
|
|
114
|
+
Add rich media attachments to memories
|
|
115
|
+
```typescript
|
|
116
|
+
attach(memory_id: string, attachment: Attachment): Response
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `correction`
|
|
120
|
+
Update or refine existing memories
|
|
121
|
+
```typescript
|
|
122
|
+
correction(memory_id: string, updates: object): Response
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## π― Real-World Use Cases
|
|
126
|
+
|
|
127
|
+
### For Developers
|
|
128
|
+
```
|
|
129
|
+
"Remember the Redis cache config: max-memory 2gb, eviction policy LRU, persistence AOF"
|
|
130
|
+
"What were those PostgreSQL optimization tips from last week's debugging session?"
|
|
131
|
+
"Show me all the API endpoints I've documented this month"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### For Researchers
|
|
135
|
+
```
|
|
136
|
+
"Store this paper: [arxiv link] - key insight about transformer attention mechanisms"
|
|
137
|
+
"What connections exist between my notes on neural networks and optimization?"
|
|
138
|
+
"Find all memories related to machine learning from Q3 2024"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### For Project Managers
|
|
142
|
+
```
|
|
143
|
+
"Remember stakeholder feedback: John wants faster load times, prioritize performance"
|
|
144
|
+
"What were the action items from yesterday's standup?"
|
|
145
|
+
"Show me all decisions made about the Q4 roadmap"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## π Security & Privacy
|
|
149
|
+
|
|
150
|
+
- **OAuth 2.1 + PKCE**: Industry-standard secure authentication
|
|
151
|
+
- **End-to-end encryption**: Your memories are encrypted in transit and at rest
|
|
152
|
+
- **SOC 2 Type II**: Compliance in progress
|
|
153
|
+
- **GDPR compliant**: Full data control and right to deletion
|
|
154
|
+
- **Zero-knowledge option**: Available for enterprise customers
|
|
155
|
+
|
|
156
|
+
## π° Pricing
|
|
157
|
+
|
|
158
|
+
### Free Tier
|
|
159
|
+
- 100 memories/month
|
|
160
|
+
- Basic search
|
|
161
|
+
- Full MCP integration
|
|
162
|
+
- Community support
|
|
163
|
+
|
|
164
|
+
### Pro ($9/month)
|
|
165
|
+
- Unlimited memories
|
|
166
|
+
- Advanced AI features
|
|
167
|
+
- Priority support
|
|
168
|
+
- API access
|
|
169
|
+
|
|
170
|
+
### Enterprise (Custom)
|
|
171
|
+
- Self-hosted option
|
|
172
|
+
- Custom AI training
|
|
173
|
+
- White-label MCP
|
|
174
|
+
- SLA guarantees
|
|
175
|
+
|
|
176
|
+
## π§ Development
|
|
177
|
+
|
|
178
|
+
### Local Development
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
# Clone the repository
|
|
182
|
+
git clone https://github.com/coladapo/purmemo-mcp.git
|
|
183
|
+
cd purmemo-mcp
|
|
184
|
+
|
|
185
|
+
# Install dependencies
|
|
186
|
+
npm install
|
|
187
|
+
|
|
188
|
+
# Run tests
|
|
189
|
+
npm test
|
|
190
|
+
|
|
191
|
+
# Start local server
|
|
192
|
+
PURMEMO_API_KEY=your-key npm start
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Contributing
|
|
196
|
+
|
|
197
|
+
We welcome contributions to the MCP protocol implementation! Please note:
|
|
198
|
+
- This repository contains only the open-source MCP wrapper
|
|
199
|
+
- Core memory algorithms remain proprietary
|
|
200
|
+
- See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines
|
|
201
|
+
|
|
202
|
+
## π Documentation
|
|
203
|
+
|
|
204
|
+
- [API Documentation](https://api.purmemo.ai/docs)
|
|
205
|
+
- [MCP Integration Guide](https://docs.purmemo.ai/mcp)
|
|
206
|
+
- [Security Whitepaper](https://purmemo.ai/security)
|
|
207
|
+
- [Terms of Service](https://purmemo.ai/terms)
|
|
208
|
+
|
|
209
|
+
## ποΈ Recognition
|
|
210
|
+
|
|
211
|
+
Purmemo MCP is pursuing official recognition in the [Model Context Protocol servers repository](https://github.com/modelcontextprotocol/servers).
|
|
212
|
+
|
|
213
|
+
## π License
|
|
214
|
+
|
|
215
|
+
### Open Source Components (This Repository)
|
|
216
|
+
**MIT License** - See [LICENSE](LICENSE) file
|
|
217
|
+
|
|
218
|
+
You are free to:
|
|
219
|
+
- Use this MCP server commercially
|
|
220
|
+
- Modify and distribute
|
|
221
|
+
- Create your own implementations
|
|
222
|
+
|
|
223
|
+
### Proprietary Components (Purmemo Core)
|
|
224
|
+
**Proprietary License** - Protected by trade secrets and pending patents
|
|
225
|
+
|
|
226
|
+
The following remain proprietary:
|
|
227
|
+
- Memory retrieval algorithms
|
|
228
|
+
- Entity extraction engine
|
|
229
|
+
- Workflow intelligence system
|
|
230
|
+
- Performance optimization techniques
|
|
231
|
+
|
|
232
|
+
## π Support
|
|
233
|
+
|
|
234
|
+
- π§ Email: support@purmemo.ai
|
|
235
|
+
- π¬ Discord: [discord.gg/purmemo](https://discord.gg/purmemo)
|
|
236
|
+
- π Issues: [GitHub Issues](https://github.com/coladapo/purmemo-mcp/issues)
|
|
237
|
+
- π Status: [status.purmemo.ai](https://status.purmemo.ai)
|
|
238
|
+
|
|
239
|
+
## πΊοΈ Roadmap
|
|
240
|
+
|
|
241
|
+
- [x] Core MCP implementation
|
|
242
|
+
- [x] OAuth 2.1 authentication
|
|
243
|
+
- [x] 5 essential tools
|
|
244
|
+
- [ ] WebSocket support for real-time
|
|
245
|
+
- [ ] Batch operations
|
|
246
|
+
- [ ] Memory sharing between users
|
|
247
|
+
- [ ] Voice memory capture
|
|
248
|
+
- [ ] Official MCP recognition
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
<div align="center">
|
|
253
|
+
|
|
254
|
+
**Built with β€οΈ for the AI community**
|
|
255
|
+
|
|
256
|
+
*"Open the door, protect the house"* - Hybrid open-core model for sustainable innovation
|
|
257
|
+
|
|
258
|
+
[Website](https://purmemo.ai) Β· [Dashboard](https://app.purmemo.ai) Β· [API Docs](https://api.purmemo.ai/docs) Β· [NPM](https://www.npmjs.com/package/purmemo-mcp)
|
|
259
|
+
|
|
260
|
+
</div>
|
package/bin/purmemo-mcp
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "purmemo-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official Model Context Protocol (MCP) server for Purmemo - Your AI-powered second brain with 94% memory retrieval accuracy",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"purmemo-mcp": "./bin/purmemo-mcp"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src/",
|
|
12
|
+
"bin/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"start": "node src/index.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"mcp",
|
|
21
|
+
"memory",
|
|
22
|
+
"ai",
|
|
23
|
+
"claude",
|
|
24
|
+
"purmemo"
|
|
25
|
+
],
|
|
26
|
+
"author": "Christopher Coladapo <support@purmemo.ai>",
|
|
27
|
+
"license": "MIT",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "git+https://github.com/coladapo/purmemo-mcp.git"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/coladapo/puo-memo-mcp/issues",
|
|
34
|
+
"email": "support@purmemo.ai"
|
|
35
|
+
},
|
|
36
|
+
"funding": {
|
|
37
|
+
"type": "github",
|
|
38
|
+
"url": "https://github.com/sponsors/coladapo"
|
|
39
|
+
},
|
|
40
|
+
"support": "https://github.com/coladapo/puo-memo-mcp/discussions",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@modelcontextprotocol/sdk": "^1.16.0",
|
|
43
|
+
"node-fetch": "^3.3.2"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/index.js
ADDED
package/src/server.js
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* pΕ«rmemo MCP Server - Secure Thin Client v1.1.2
|
|
4
|
+
* All processing happens on pΕ«rmemo servers
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
8
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
9
|
+
import {
|
|
10
|
+
CallToolRequestSchema,
|
|
11
|
+
ListToolsRequestSchema,
|
|
12
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
+
import fetch from 'node-fetch';
|
|
14
|
+
|
|
15
|
+
// Check for required environment variables
|
|
16
|
+
const API_KEY = process.env.PUO_MEMO_API_KEY;
|
|
17
|
+
const API_URL = process.env.PUO_MEMO_API_URL || 'https://api.puo-memo.com';
|
|
18
|
+
|
|
19
|
+
if (!API_KEY) {
|
|
20
|
+
console.error('β PUO_MEMO_API_KEY environment variable is required');
|
|
21
|
+
console.error('Get your API key at https://app.purmemo.ai');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Tool definitions - just schemas, no implementation
|
|
26
|
+
const TOOLS = [
|
|
27
|
+
{
|
|
28
|
+
name: 'memory',
|
|
29
|
+
description: 'πΎ Save anything to memory',
|
|
30
|
+
inputSchema: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
properties: {
|
|
33
|
+
content: { type: 'string', description: 'What to remember' },
|
|
34
|
+
title: { type: 'string', description: 'Optional: Title for the memory' },
|
|
35
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'Optional: Tags' },
|
|
36
|
+
attachments: { type: 'array', items: { type: 'string' }, description: 'Optional: File paths or URLs' }
|
|
37
|
+
},
|
|
38
|
+
required: ['content']
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'recall',
|
|
43
|
+
description: 'π Search your memories',
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: 'object',
|
|
46
|
+
properties: {
|
|
47
|
+
query: { type: 'string', description: 'What to search for' },
|
|
48
|
+
limit: { type: 'integer', description: 'How many results (default: 10)', default: 10 },
|
|
49
|
+
search_type: { type: 'string', enum: ['keyword', 'semantic', 'hybrid'], default: 'hybrid' }
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: 'entities',
|
|
55
|
+
description: 'π§ List entities or get entity graph',
|
|
56
|
+
inputSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
entity_name: { type: 'string', description: 'Entity to get graph for' },
|
|
60
|
+
entity_type: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
enum: ['person', 'organization', 'location', 'event', 'project'],
|
|
63
|
+
description: 'Filter by entity type'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'attach',
|
|
70
|
+
description: 'π Attach files to an existing memory',
|
|
71
|
+
inputSchema: {
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
memory_id: { type: 'string', description: 'Memory ID to attach files to' },
|
|
75
|
+
file_paths: { type: 'array', items: { type: 'string' }, description: 'File paths or URLs' }
|
|
76
|
+
},
|
|
77
|
+
required: ['memory_id', 'file_paths']
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'correction',
|
|
82
|
+
description: 'βοΈ Add a correction to an existing memory',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
memory_id: { type: 'string', description: 'ID of the memory to correct' },
|
|
87
|
+
correction: { type: 'string', description: 'The corrected content' },
|
|
88
|
+
reason: { type: 'string', description: 'Optional: Reason for the correction' }
|
|
89
|
+
},
|
|
90
|
+
required: ['memory_id', 'correction']
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
|
|
95
|
+
// Create MCP server
|
|
96
|
+
const server = new Server(
|
|
97
|
+
{
|
|
98
|
+
name: 'purmemo',
|
|
99
|
+
vendor: 'pΕ«rmemo',
|
|
100
|
+
version: '1.1.2'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
capabilities: {
|
|
104
|
+
tools: {}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// Handle tool listing
|
|
110
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
111
|
+
tools: TOOLS
|
|
112
|
+
}));
|
|
113
|
+
|
|
114
|
+
// Handle tool execution - forward all to API
|
|
115
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
116
|
+
const { name, arguments: args } = request.params;
|
|
117
|
+
|
|
118
|
+
try {
|
|
119
|
+
let response;
|
|
120
|
+
|
|
121
|
+
switch (name) {
|
|
122
|
+
case 'memory':
|
|
123
|
+
// POST request for creating memory
|
|
124
|
+
response = await fetch(`${API_URL}/api/v5/memories`, {
|
|
125
|
+
method: 'POST',
|
|
126
|
+
headers: {
|
|
127
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
128
|
+
'Content-Type': 'application/json',
|
|
129
|
+
'User-Agent': 'purmemo-mcp/1.1.2'
|
|
130
|
+
},
|
|
131
|
+
body: JSON.stringify(args)
|
|
132
|
+
});
|
|
133
|
+
break;
|
|
134
|
+
|
|
135
|
+
case 'recall':
|
|
136
|
+
// GET request for search
|
|
137
|
+
const searchParams = new URLSearchParams({
|
|
138
|
+
q: args.query || '',
|
|
139
|
+
limit: args.limit || 10,
|
|
140
|
+
search_type: args.search_type || 'hybrid'
|
|
141
|
+
});
|
|
142
|
+
response = await fetch(`${API_URL}/api/v5/memories/search?${searchParams}`, {
|
|
143
|
+
headers: {
|
|
144
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
145
|
+
'User-Agent': 'purmemo-mcp/1.1.2'
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
break;
|
|
149
|
+
|
|
150
|
+
case 'entities':
|
|
151
|
+
// GET request for entities
|
|
152
|
+
const entityParams = new URLSearchParams();
|
|
153
|
+
if (args.entity_name) entityParams.append('name', args.entity_name);
|
|
154
|
+
if (args.entity_type) entityParams.append('type', args.entity_type);
|
|
155
|
+
|
|
156
|
+
response = await fetch(`${API_URL}/api/v5/entities?${entityParams}`, {
|
|
157
|
+
headers: {
|
|
158
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
159
|
+
'User-Agent': 'purmemo-mcp/1.1.2'
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
case 'attach':
|
|
165
|
+
// POST request for attachments
|
|
166
|
+
response = await fetch(`${API_URL}/api/v5/memories/${args.memory_id}/attachments`, {
|
|
167
|
+
method: 'POST',
|
|
168
|
+
headers: {
|
|
169
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
170
|
+
'Content-Type': 'application/json',
|
|
171
|
+
'User-Agent': 'purmemo-mcp/1.1.2'
|
|
172
|
+
},
|
|
173
|
+
body: JSON.stringify({ file_paths: args.file_paths })
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
case 'correction':
|
|
178
|
+
// POST request for corrections
|
|
179
|
+
response = await fetch(`${API_URL}/api/v5/memories/${args.memory_id}/corrections`, {
|
|
180
|
+
method: 'POST',
|
|
181
|
+
headers: {
|
|
182
|
+
'Authorization': `Bearer ${API_KEY}`,
|
|
183
|
+
'Content-Type': 'application/json',
|
|
184
|
+
'User-Agent': 'purmemo-mcp/1.1.2'
|
|
185
|
+
},
|
|
186
|
+
body: JSON.stringify({
|
|
187
|
+
correction: args.correction,
|
|
188
|
+
reason: args.reason
|
|
189
|
+
})
|
|
190
|
+
});
|
|
191
|
+
break;
|
|
192
|
+
|
|
193
|
+
default:
|
|
194
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!response.ok) {
|
|
198
|
+
const error = await response.text();
|
|
199
|
+
throw new Error(`API error: ${error}`);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const result = await response.json();
|
|
203
|
+
|
|
204
|
+
return {
|
|
205
|
+
content: [{
|
|
206
|
+
type: 'text',
|
|
207
|
+
text: JSON.stringify(result, null, 2)
|
|
208
|
+
}]
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
} catch (error) {
|
|
212
|
+
console.error('Tool execution error:', error);
|
|
213
|
+
return {
|
|
214
|
+
content: [{
|
|
215
|
+
type: 'text',
|
|
216
|
+
text: JSON.stringify({ error: error.message }, null, 2)
|
|
217
|
+
}]
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Start the server
|
|
223
|
+
async function main() {
|
|
224
|
+
console.error('π pΕ«rmemo MCP Server v1.1.2 - Hybrid Open-Core Model');
|
|
225
|
+
console.error('π‘ Connected to:', API_URL);
|
|
226
|
+
console.error('π OAuth 2.1 + API key authentication');
|
|
227
|
+
console.error('π‘ 94% accuracy with <50ms retrieval');
|
|
228
|
+
|
|
229
|
+
const transport = new StdioServerTransport();
|
|
230
|
+
await server.connect(transport);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
main().catch((error) => {
|
|
234
|
+
console.error('Server error:', error);
|
|
235
|
+
process.exit(1);
|
|
236
|
+
});
|