@thoughtfree/mcp-server 0.1.0 → 0.2.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/bin/thoughtfree-mcp.mjs +0 -0
- package/dist/client.d.ts +10 -0
- package/dist/client.js +12 -0
- package/dist/index.js +3 -27
- package/dist/register.d.ts +9 -0
- package/dist/register.js +36 -0
- package/dist/tools/delete.d.ts +3 -0
- package/dist/tools/delete.js +23 -0
- package/dist/tools/list.js +4 -3
- package/dist/tools/restore.d.ts +3 -0
- package/dist/tools/restore.js +23 -0
- package/dist/types.d.ts +1 -0
- package/package.json +6 -1
package/bin/thoughtfree-mcp.mjs
CHANGED
|
File without changes
|
package/dist/client.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export declare class ThoughtFreeClient {
|
|
|
16
16
|
type?: string;
|
|
17
17
|
isStarred?: boolean;
|
|
18
18
|
isArchived?: boolean;
|
|
19
|
+
deleted?: boolean;
|
|
19
20
|
}): Promise<ListResponse<Thought>>;
|
|
20
21
|
getThought(id: string): Promise<Thought>;
|
|
21
22
|
createThought(data: {
|
|
@@ -39,6 +40,15 @@ export declare class ThoughtFreeClient {
|
|
|
39
40
|
dueDate?: string;
|
|
40
41
|
priority?: string;
|
|
41
42
|
}): Promise<Thought>;
|
|
43
|
+
deleteThought(id: string): Promise<{
|
|
44
|
+
id: string;
|
|
45
|
+
deleted: boolean;
|
|
46
|
+
deletedAt: string;
|
|
47
|
+
}>;
|
|
48
|
+
restoreThought(id: string): Promise<{
|
|
49
|
+
id: string;
|
|
50
|
+
restored: boolean;
|
|
51
|
+
}>;
|
|
42
52
|
searchThoughts(query: string, params?: {
|
|
43
53
|
mode?: 'semantic' | 'fulltext' | 'hybrid';
|
|
44
54
|
limit?: number;
|
package/dist/client.js
CHANGED
|
@@ -42,6 +42,8 @@ export class ThoughtFreeClient {
|
|
|
42
42
|
searchParams.set('isStarred', 'true');
|
|
43
43
|
if (params?.isArchived)
|
|
44
44
|
searchParams.set('isArchived', 'true');
|
|
45
|
+
if (params?.deleted)
|
|
46
|
+
searchParams.set('deleted', 'true');
|
|
45
47
|
const qs = searchParams.toString();
|
|
46
48
|
return this.request(`/api/v1/thoughts${qs ? `?${qs}` : ''}`);
|
|
47
49
|
}
|
|
@@ -60,6 +62,16 @@ export class ThoughtFreeClient {
|
|
|
60
62
|
body: JSON.stringify(data)
|
|
61
63
|
});
|
|
62
64
|
}
|
|
65
|
+
async deleteThought(id) {
|
|
66
|
+
return this.request(`/api/v1/thoughts/${id}`, {
|
|
67
|
+
method: 'DELETE'
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async restoreThought(id) {
|
|
71
|
+
return this.request(`/api/v1/thoughts/${id}?restore=true`, {
|
|
72
|
+
method: 'DELETE'
|
|
73
|
+
});
|
|
74
|
+
}
|
|
63
75
|
// ─── Search ──────────────────────────────────────────────
|
|
64
76
|
async searchThoughts(query, params) {
|
|
65
77
|
const searchParams = new URLSearchParams({ q: query });
|
package/dist/index.js
CHANGED
|
@@ -7,19 +7,7 @@
|
|
|
7
7
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
8
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
9
9
|
import { ThoughtFreeClient } from './client.js';
|
|
10
|
-
|
|
11
|
-
import { registerSearchTool } from './tools/search.js';
|
|
12
|
-
import { registerCreateTool } from './tools/create.js';
|
|
13
|
-
import { registerListTool } from './tools/list.js';
|
|
14
|
-
import { registerGetTool } from './tools/get.js';
|
|
15
|
-
import { registerUpdateTool } from './tools/update.js';
|
|
16
|
-
import { registerQueryBrainTool } from './tools/query-brain.js';
|
|
17
|
-
import { registerCategoriesTool } from './tools/categories.js';
|
|
18
|
-
import { registerStatsTool } from './tools/stats.js';
|
|
19
|
-
// Resources
|
|
20
|
-
import { registerRecentResource } from './resources/recent.js';
|
|
21
|
-
import { registerStarredResource } from './resources/starred.js';
|
|
22
|
-
import { registerByCategoryResource } from './resources/by-category.js';
|
|
10
|
+
import { registerAllMcpCapabilities } from './register.js';
|
|
23
11
|
export async function main() {
|
|
24
12
|
const apiKey = process.env.THOUGHTFREE_API_KEY;
|
|
25
13
|
const apiUrl = process.env.THOUGHTFREE_API_URL || 'https://thoughtfree.io';
|
|
@@ -33,25 +21,13 @@ export async function main() {
|
|
|
33
21
|
name: 'thoughtfree',
|
|
34
22
|
version: '0.1.0'
|
|
35
23
|
});
|
|
36
|
-
|
|
37
|
-
registerSearchTool(server, client);
|
|
38
|
-
registerCreateTool(server, client);
|
|
39
|
-
registerListTool(server, client);
|
|
40
|
-
registerGetTool(server, client);
|
|
41
|
-
registerUpdateTool(server, client);
|
|
42
|
-
registerQueryBrainTool(server, client);
|
|
43
|
-
registerCategoriesTool(server, client);
|
|
44
|
-
registerStatsTool(server, client);
|
|
45
|
-
// Register all resources
|
|
46
|
-
registerRecentResource(server, client);
|
|
47
|
-
registerStarredResource(server, client);
|
|
48
|
-
registerByCategoryResource(server, client);
|
|
24
|
+
registerAllMcpCapabilities(server, client);
|
|
49
25
|
// Connect via stdio transport
|
|
50
26
|
const transport = new StdioServerTransport();
|
|
51
27
|
await server.connect(transport);
|
|
52
28
|
console.error('ThoughtFree MCP Server running on stdio');
|
|
53
29
|
console.error(` API URL: ${apiUrl}`);
|
|
54
|
-
console.error(` Tools:
|
|
30
|
+
console.error(` Tools: 10 | Resources: 3`);
|
|
55
31
|
}
|
|
56
32
|
main().catch((err) => {
|
|
57
33
|
console.error('Fatal error:', err);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool/resource registration.
|
|
3
|
+
*
|
|
4
|
+
* Used by both the stdio server (index.ts) and the SvelteKit
|
|
5
|
+
* remote HTTP endpoint (src/routes/api/mcp/+server.ts).
|
|
6
|
+
*/
|
|
7
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
8
|
+
import type { ThoughtFreeClient } from './client.js';
|
|
9
|
+
export declare function registerAllMcpCapabilities(server: McpServer, client: ThoughtFreeClient): void;
|
package/dist/register.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared MCP tool/resource registration.
|
|
3
|
+
*
|
|
4
|
+
* Used by both the stdio server (index.ts) and the SvelteKit
|
|
5
|
+
* remote HTTP endpoint (src/routes/api/mcp/+server.ts).
|
|
6
|
+
*/
|
|
7
|
+
// Tools
|
|
8
|
+
import { registerSearchTool } from './tools/search.js';
|
|
9
|
+
import { registerCreateTool } from './tools/create.js';
|
|
10
|
+
import { registerListTool } from './tools/list.js';
|
|
11
|
+
import { registerGetTool } from './tools/get.js';
|
|
12
|
+
import { registerUpdateTool } from './tools/update.js';
|
|
13
|
+
import { registerDeleteTool } from './tools/delete.js';
|
|
14
|
+
import { registerRestoreTool } from './tools/restore.js';
|
|
15
|
+
import { registerQueryBrainTool } from './tools/query-brain.js';
|
|
16
|
+
import { registerCategoriesTool } from './tools/categories.js';
|
|
17
|
+
import { registerStatsTool } from './tools/stats.js';
|
|
18
|
+
// Resources
|
|
19
|
+
import { registerRecentResource } from './resources/recent.js';
|
|
20
|
+
import { registerStarredResource } from './resources/starred.js';
|
|
21
|
+
import { registerByCategoryResource } from './resources/by-category.js';
|
|
22
|
+
export function registerAllMcpCapabilities(server, client) {
|
|
23
|
+
registerSearchTool(server, client);
|
|
24
|
+
registerCreateTool(server, client);
|
|
25
|
+
registerListTool(server, client);
|
|
26
|
+
registerGetTool(server, client);
|
|
27
|
+
registerUpdateTool(server, client);
|
|
28
|
+
registerDeleteTool(server, client);
|
|
29
|
+
registerRestoreTool(server, client);
|
|
30
|
+
registerQueryBrainTool(server, client);
|
|
31
|
+
registerCategoriesTool(server, client);
|
|
32
|
+
registerStatsTool(server, client);
|
|
33
|
+
registerRecentResource(server, client);
|
|
34
|
+
registerStarredResource(server, client);
|
|
35
|
+
registerByCategoryResource(server, client);
|
|
36
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function registerDeleteTool(server, client) {
|
|
3
|
+
server.registerTool('delete_thought', {
|
|
4
|
+
title: 'Delete Thought',
|
|
5
|
+
description: 'Soft-delete a thought by ID. The thought can be restored later with restore_thought.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
id: z.string().describe('The thought\'s server UUID')
|
|
8
|
+
})
|
|
9
|
+
}, async ({ id }) => {
|
|
10
|
+
try {
|
|
11
|
+
const result = await client.deleteThought(id);
|
|
12
|
+
return {
|
|
13
|
+
content: [{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: `Thought deleted successfully.\nID: ${result.id}\nDeleted at: ${result.deletedAt}\n\nUse restore_thought to undo this deletion.`
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return { content: [{ type: 'text', text: `Failed to delete thought: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/tools/list.js
CHANGED
|
@@ -8,16 +8,17 @@ export function registerListTool(server, client) {
|
|
|
8
8
|
type: z.string().optional().describe('Filter by type (text, voice, image, file, link)'),
|
|
9
9
|
isStarred: z.boolean().optional().describe('Only show starred thoughts'),
|
|
10
10
|
isArchived: z.boolean().optional().describe('Only show archived thoughts'),
|
|
11
|
+
deleted: z.boolean().optional().describe('Show deleted thoughts instead of active ones'),
|
|
11
12
|
limit: z.number().min(1).max(100).default(20).describe('Number of thoughts to return'),
|
|
12
13
|
cursor: z.string().optional().describe('Pagination cursor from previous response')
|
|
13
14
|
})
|
|
14
|
-
}, async ({ category, type, isStarred, isArchived, limit, cursor }) => {
|
|
15
|
+
}, async ({ category, type, isStarred, isArchived, deleted, limit, cursor }) => {
|
|
15
16
|
try {
|
|
16
|
-
const result = await client.listThoughts({ category, type, isStarred, isArchived, limit, cursor });
|
|
17
|
+
const result = await client.listThoughts({ category, type, isStarred, isArchived, deleted, limit, cursor });
|
|
17
18
|
if (result.data.length === 0) {
|
|
18
19
|
return { content: [{ type: 'text', text: 'No thoughts found matching the filters.' }] };
|
|
19
20
|
}
|
|
20
|
-
const formatted = result.data.map((t, i) => `${i + 1}. ${t.category ? `[${t.category}] ` : ''}${t.isStarred ? '★ ' : ''}${t.content.slice(0, 200)}${t.content.length > 200 ? '...' : ''}\n ID: ${t.id} | Type: ${t.type} | Created: ${t.createdAt}${t.userTags.length ? ` | Tags: ${t.userTags.join(', ')}` : ''}`).join('\n\n');
|
|
21
|
+
const formatted = result.data.map((t, i) => `${i + 1}. ${t.category ? `[${t.category}] ` : ''}${t.isStarred ? '★ ' : ''}${t.content.slice(0, 200)}${t.content.length > 200 ? '...' : ''}\n ID: ${t.id} | Type: ${t.type} | Created: ${t.createdAt}${t.deletedAt ? ` | Deleted: ${t.deletedAt}` : ''}${t.userTags.length ? ` | Tags: ${t.userTags.join(', ')}` : ''}`).join('\n\n');
|
|
21
22
|
let text = `Showing ${result.data.length} thoughts:\n\n${formatted}`;
|
|
22
23
|
if (result.hasMore && result.cursor) {
|
|
23
24
|
text += `\n\n--- More results available. Use cursor: "${result.cursor}" ---`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export function registerRestoreTool(server, client) {
|
|
3
|
+
server.registerTool('restore_thought', {
|
|
4
|
+
title: 'Restore Thought',
|
|
5
|
+
description: 'Restore a previously deleted thought. Use list_thoughts with deleted=true to find deleted thoughts first.',
|
|
6
|
+
inputSchema: z.object({
|
|
7
|
+
id: z.string().describe('The deleted thought\'s server UUID')
|
|
8
|
+
})
|
|
9
|
+
}, async ({ id }) => {
|
|
10
|
+
try {
|
|
11
|
+
const result = await client.restoreThought(id);
|
|
12
|
+
return {
|
|
13
|
+
content: [{
|
|
14
|
+
type: 'text',
|
|
15
|
+
text: `Thought restored successfully.\nID: ${result.id}\n\nThe thought is now visible again in your thought list.`
|
|
16
|
+
}]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
return { content: [{ type: 'text', text: `Failed to restore thought: ${err instanceof Error ? err.message : String(err)}` }], isError: true };
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thoughtfree/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "MCP server for ThoughtFree — access your thought database from any AI agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"thoughtfree-mcp": "./bin/thoughtfree-mcp.mjs"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": "./dist/index.js",
|
|
12
|
+
"./register": "./dist/register.js",
|
|
13
|
+
"./client": "./dist/client.js"
|
|
14
|
+
},
|
|
10
15
|
"files": [
|
|
11
16
|
"dist",
|
|
12
17
|
"bin"
|