tiddlywiki-mcp-server 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 +21 -0
- package/README.md +242 -0
- package/dist/embeddings/database.d.ts +53 -0
- package/dist/embeddings/database.d.ts.map +1 -0
- package/dist/embeddings/database.js +212 -0
- package/dist/embeddings/database.js.map +1 -0
- package/dist/embeddings/ollama-client.d.ts +39 -0
- package/dist/embeddings/ollama-client.d.ts.map +1 -0
- package/dist/embeddings/ollama-client.js +190 -0
- package/dist/embeddings/ollama-client.js.map +1 -0
- package/dist/embeddings/sync-worker.d.ts +49 -0
- package/dist/embeddings/sync-worker.d.ts.map +1 -0
- package/dist/embeddings/sync-worker.js +244 -0
- package/dist/embeddings/sync-worker.js.map +1 -0
- package/dist/filter-reference.d.ts +8 -0
- package/dist/filter-reference.d.ts.map +1 -0
- package/dist/filter-reference.js +159 -0
- package/dist/filter-reference.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +450 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +17 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +33 -0
- package/dist/logger.js.map +1 -0
- package/dist/service-discovery.d.ts +24 -0
- package/dist/service-discovery.d.ts.map +1 -0
- package/dist/service-discovery.js +82 -0
- package/dist/service-discovery.js.map +1 -0
- package/dist/tiddlywiki-http.d.ts +55 -0
- package/dist/tiddlywiki-http.d.ts.map +1 -0
- package/dist/tiddlywiki-http.js +253 -0
- package/dist/tiddlywiki-http.js.map +1 -0
- package/dist/tools/create-tiddler.d.ts +15 -0
- package/dist/tools/create-tiddler.d.ts.map +1 -0
- package/dist/tools/create-tiddler.js +61 -0
- package/dist/tools/create-tiddler.js.map +1 -0
- package/dist/tools/delete-tiddler.d.ts +9 -0
- package/dist/tools/delete-tiddler.d.ts.map +1 -0
- package/dist/tools/delete-tiddler.js +40 -0
- package/dist/tools/delete-tiddler.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +7 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/search-tiddlers.d.ts +12 -0
- package/dist/tools/search-tiddlers.d.ts.map +1 -0
- package/dist/tools/search-tiddlers.js +189 -0
- package/dist/tools/search-tiddlers.js.map +1 -0
- package/dist/tools/types.d.ts +101 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +55 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/update-tiddler.d.ts +9 -0
- package/dist/tools/update-tiddler.d.ts.map +1 -0
- package/dist/tools/update-tiddler.js +90 -0
- package/dist/tools/update-tiddler.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// ABOUTME: TiddlyWiki filter syntax reference documentation
|
|
2
|
+
// ABOUTME: Exposed as an MCP resource to help LLMs understand filter queries
|
|
3
|
+
export const FILTER_REFERENCE = `# TiddlyWiki Filter Reference
|
|
4
|
+
|
|
5
|
+
## Syntax Basics
|
|
6
|
+
|
|
7
|
+
Filters are composed of **runs** enclosed in square brackets: \`[operator[parameter]]\`
|
|
8
|
+
Multiple operators can be chained within a run.
|
|
9
|
+
Multiple runs can be combined with different logic.
|
|
10
|
+
|
|
11
|
+
## Logic Operators
|
|
12
|
+
|
|
13
|
+
- **AND (implicit)**: Space between runs → \`[run1] [run2]\` (intersection)
|
|
14
|
+
- **OR**: Comma + prefix → \`[run1],[run2]\` (union)
|
|
15
|
+
- **NOT**: ! prefix → \`[all[tiddlers]!tag[Exclude]]\` (exclusion)
|
|
16
|
+
|
|
17
|
+
## Selection Operators
|
|
18
|
+
|
|
19
|
+
### all[]
|
|
20
|
+
Select tiddlers by type:
|
|
21
|
+
- \`[all[tiddlers]]\` - all non-shadow tiddlers
|
|
22
|
+
- \`[all[shadows]]\` - all shadow tiddlers
|
|
23
|
+
- \`[all[]]]\` - all tiddlers (including shadows)
|
|
24
|
+
|
|
25
|
+
### tag[]
|
|
26
|
+
Select by tag:
|
|
27
|
+
- \`[tag[Journal]]\` - tiddlers tagged "Journal"
|
|
28
|
+
- \`[tag[OYS]tag[Planning]]\` - tiddlers with BOTH tags (AND)
|
|
29
|
+
- \`[tag[OYS]],[tag[Planning]]\` - tiddlers with EITHER tag (OR)
|
|
30
|
+
- \`[all[tiddlers]!tag[System]]\` - exclude tagged tiddlers
|
|
31
|
+
|
|
32
|
+
### prefix[] / suffix[]
|
|
33
|
+
String matching on title:
|
|
34
|
+
- \`[prefix[2025-11]]\` - titles starting with "2025-11"
|
|
35
|
+
- \`[suffix[.md]]\` - titles ending with ".md"
|
|
36
|
+
- \`[prefix[OYS ]]\` - OYS posts (note the space!)
|
|
37
|
+
|
|
38
|
+
### search[]
|
|
39
|
+
Full-text search:
|
|
40
|
+
- \`[search[keyword]]\` - search title and text
|
|
41
|
+
- \`[search:title[keyword]]\` - search title only
|
|
42
|
+
- \`[search:text[keyword]]\` - search text only
|
|
43
|
+
- \`[search:tags[keyword]]\` - search tags
|
|
44
|
+
- \`[search[Inês]]\` - find all mentions
|
|
45
|
+
|
|
46
|
+
### field matching
|
|
47
|
+
Match by field value:
|
|
48
|
+
- \`[field:fieldname[value]]\` - exact match
|
|
49
|
+
- \`[type[text/markdown]]\` - tiddlers of specific type
|
|
50
|
+
- \`[creator[username]]\` - created by user
|
|
51
|
+
|
|
52
|
+
## Date Operators
|
|
53
|
+
|
|
54
|
+
### days[]
|
|
55
|
+
Relative date filtering:
|
|
56
|
+
- \`[!days:created[-7]]\` - created in last 7 days
|
|
57
|
+
- \`[!days:modified[-30]]\` - modified in last 30 days
|
|
58
|
+
- \`[days:created[1]]\` - created tomorrow or before (future + past)
|
|
59
|
+
- \`[days:modified[0]]\` - modified today only
|
|
60
|
+
|
|
61
|
+
**Parameter D**: number of days from today
|
|
62
|
+
- D=0: today only
|
|
63
|
+
- D=1: tomorrow and everything before
|
|
64
|
+
- D=-1: yesterday and everything after
|
|
65
|
+
- D=-7: last week and everything after
|
|
66
|
+
|
|
67
|
+
### sameday[]
|
|
68
|
+
Match specific date:
|
|
69
|
+
- \`[sameday:created[20251112]]\` - created on Nov 12, 2025
|
|
70
|
+
- \`[sameday:modified[20251112]]\` - modified on Nov 12, 2025
|
|
71
|
+
|
|
72
|
+
**Date format**: YYYYMMDD or YYYYMMDDHHmmSSsss
|
|
73
|
+
|
|
74
|
+
## Sorting Operators
|
|
75
|
+
|
|
76
|
+
### sort[] / !sort[]
|
|
77
|
+
Sort results:
|
|
78
|
+
- \`[tag[Journal]sort[title]]\` - alphabetical by title
|
|
79
|
+
- \`[tag[Journal]!sort[created]]\` - newest first (! = descending)
|
|
80
|
+
- \`[tag[Journal]!sort[modified]]\` - most recently modified first
|
|
81
|
+
- \`[all[tiddlers]nsort[title]]\` - natural sort (handles numbers)
|
|
82
|
+
|
|
83
|
+
### limit[]
|
|
84
|
+
Limit results:
|
|
85
|
+
- \`[tag[Journal]!sort[modified]limit[10]]\` - 10 most recent
|
|
86
|
+
- \`[tag[Journal]limit[5]]\` - first 5 matches
|
|
87
|
+
|
|
88
|
+
## Practical Examples
|
|
89
|
+
|
|
90
|
+
### Recent journal entries
|
|
91
|
+
\`\`\`
|
|
92
|
+
[tag[Journal]!days:modified[-7]!sort[modified]]
|
|
93
|
+
\`\`\`
|
|
94
|
+
Journal entries modified in last 7 days, newest first
|
|
95
|
+
|
|
96
|
+
### November 2025 entries
|
|
97
|
+
\`\`\`
|
|
98
|
+
[tag[Journal]prefix[2025-11]sort[title]]
|
|
99
|
+
\`\`\`
|
|
100
|
+
All November 2025 journal entries, chronological
|
|
101
|
+
|
|
102
|
+
### Search with context
|
|
103
|
+
\`\`\`
|
|
104
|
+
[tag[Journal]search[Inês]!sort[modified]limit[10]]
|
|
105
|
+
\`\`\`
|
|
106
|
+
10 most recent journal entries mentioning Inês
|
|
107
|
+
|
|
108
|
+
### OYS posts
|
|
109
|
+
\`\`\`
|
|
110
|
+
[tag[OYS]!sort[created]]
|
|
111
|
+
\`\`\`
|
|
112
|
+
All OYS posts, newest first
|
|
113
|
+
|
|
114
|
+
### Entries without a tag
|
|
115
|
+
\`\`\`
|
|
116
|
+
[tag[Journal]!tag[agent-generated]]
|
|
117
|
+
\`\`\`
|
|
118
|
+
Human-written journal entries only
|
|
119
|
+
|
|
120
|
+
### Date range (last 30 days)
|
|
121
|
+
\`\`\`
|
|
122
|
+
[tag[Journal]!days:created[-30]!sort[created]]
|
|
123
|
+
\`\`\`
|
|
124
|
+
Journal entries created in last 30 days
|
|
125
|
+
|
|
126
|
+
### Complex query
|
|
127
|
+
\`\`\`
|
|
128
|
+
[tag[Journal]!days:modified[-14]search[exercise]!tag[Draft]!sort[modified]limit[5]]
|
|
129
|
+
\`\`\`
|
|
130
|
+
Last 5 non-draft journal entries mentioning "exercise" from the past 2 weeks
|
|
131
|
+
|
|
132
|
+
## Tips
|
|
133
|
+
|
|
134
|
+
1. **Testing**: Test filters incrementally. Start with broad selection, then add constraints.
|
|
135
|
+
2. **Performance**: More specific filters (prefix, tag) are faster than full-text search.
|
|
136
|
+
3. **Case sensitivity**: Search is case-insensitive by default.
|
|
137
|
+
4. **Timestamps**: TiddlyWiki uses milliseconds since epoch for created/modified fields.
|
|
138
|
+
5. **Empty results**: Invalid syntax may return empty results rather than errors.
|
|
139
|
+
|
|
140
|
+
## Common Patterns
|
|
141
|
+
|
|
142
|
+
| Goal | Filter |
|
|
143
|
+
|------|--------|
|
|
144
|
+
| Last 7 days | \`[!days:modified[-7]]\` |
|
|
145
|
+
| This month | \`[prefix[2025-11]]\` |
|
|
146
|
+
| Last 10 entries | \`[tag[Journal]!sort[modified]limit[10]]\` |
|
|
147
|
+
| Find keyword | \`[search[keyword]]\` |
|
|
148
|
+
| Exclude system | \`[all[tiddlers]!prefix[$:]]\` |
|
|
149
|
+
| By date | \`[sameday:created[20251112]]\` |
|
|
150
|
+
`;
|
|
151
|
+
/**
|
|
152
|
+
* Get the filter reference as a structured object
|
|
153
|
+
*/
|
|
154
|
+
export function getFilterReference() {
|
|
155
|
+
return {
|
|
156
|
+
content: FILTER_REFERENCE,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=filter-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-reference.js","sourceRoot":"","sources":["../src/filter-reference.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,6EAA6E;AAE7E,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmJ/B,CAAC;AAEF;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,OAAO,EAAE,gBAAgB;KAC1B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// ABOUTME: TiddlyWiki MCP Server - main entry point
|
|
3
|
+
// ABOUTME: Handles stdio and HTTP transports, server lifecycle, and tool routing
|
|
4
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
6
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
7
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import express from 'express';
|
|
10
|
+
import { initTiddlyWiki } from './tiddlywiki-http.js';
|
|
11
|
+
import { getFilterReference } from './filter-reference.js';
|
|
12
|
+
import { EmbeddingsDB } from './embeddings/database.js';
|
|
13
|
+
import { OllamaClient } from './embeddings/ollama-client.js';
|
|
14
|
+
import { SyncWorker } from './embeddings/sync-worker.js';
|
|
15
|
+
import * as logger from './logger.js';
|
|
16
|
+
import { handleSearchTiddlers, handleUpdateTiddler, handleCreateTiddler, handleDeleteTiddler, } from './tools/index.js';
|
|
17
|
+
// Global embeddings infrastructure (singletons - shared across requests)
|
|
18
|
+
let embeddingsDB = null;
|
|
19
|
+
let ollamaClient = null;
|
|
20
|
+
let syncWorker = null;
|
|
21
|
+
// Server for stdio transport (created once, used for the lifetime of the process)
|
|
22
|
+
let stdioServer = null;
|
|
23
|
+
/**
|
|
24
|
+
* Get the current tool dependencies for handlers that need embeddings.
|
|
25
|
+
*/
|
|
26
|
+
function getToolDependencies() {
|
|
27
|
+
return {
|
|
28
|
+
embeddingsDB,
|
|
29
|
+
ollamaClient,
|
|
30
|
+
syncWorker,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new MCP server instance with all handlers registered.
|
|
35
|
+
* Used for stateless mode where each request gets its own server.
|
|
36
|
+
*/
|
|
37
|
+
function createServer() {
|
|
38
|
+
const server = new Server({
|
|
39
|
+
name: 'tiddlywiki-http-mcp-server',
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
}, {
|
|
42
|
+
capabilities: {
|
|
43
|
+
tools: {},
|
|
44
|
+
resources: {},
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
registerHandlers(server);
|
|
48
|
+
return server;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Register all MCP handlers on a server instance.
|
|
52
|
+
* Separated from server creation to allow reuse with different transports.
|
|
53
|
+
*/
|
|
54
|
+
function registerHandlers(server) {
|
|
55
|
+
// List available resources
|
|
56
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => {
|
|
57
|
+
return {
|
|
58
|
+
resources: [
|
|
59
|
+
{
|
|
60
|
+
uri: 'filter-reference://syntax',
|
|
61
|
+
name: 'TiddlyWiki Filter Syntax Reference',
|
|
62
|
+
description: 'Complete reference documentation for TiddlyWiki filter operators and syntax',
|
|
63
|
+
mimeType: 'text/markdown',
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
// Read resource content
|
|
69
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
70
|
+
const { uri } = request.params;
|
|
71
|
+
if (uri === 'filter-reference://syntax') {
|
|
72
|
+
const reference = getFilterReference();
|
|
73
|
+
return {
|
|
74
|
+
contents: [
|
|
75
|
+
{
|
|
76
|
+
uri,
|
|
77
|
+
mimeType: 'text/markdown',
|
|
78
|
+
text: reference.content,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
84
|
+
});
|
|
85
|
+
// List available tools
|
|
86
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
87
|
+
return {
|
|
88
|
+
tools: [
|
|
89
|
+
{
|
|
90
|
+
name: 'search_tiddlers',
|
|
91
|
+
description: 'Search tiddlers using filter syntax, semantic similarity, or both. Supports filter-based queries (e.g., by tag, date, title), semantic/conceptual search, and hybrid combinations. Returns matching tiddlers with metadata and optionally text content.',
|
|
92
|
+
inputSchema: {
|
|
93
|
+
type: 'object',
|
|
94
|
+
properties: {
|
|
95
|
+
semantic: {
|
|
96
|
+
type: 'string',
|
|
97
|
+
description: 'Natural language semantic search query (e.g., "times I felt anxious about parenting", "entries about work stress"). Finds conceptually related entries even without exact keyword matches.',
|
|
98
|
+
},
|
|
99
|
+
filter: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: 'TiddlyWiki filter expression (e.g., "[tag[Journal]prefix[2025-11]]" for November 2025 journal entries, "[title[2025-11-12]]" for specific entry). Can be used alone for filter-based search, or combined with semantic for hybrid search.',
|
|
102
|
+
},
|
|
103
|
+
includeText: {
|
|
104
|
+
type: 'boolean',
|
|
105
|
+
description: 'Include text content in results (default: false). Set to true to get full tiddler content.',
|
|
106
|
+
default: false,
|
|
107
|
+
},
|
|
108
|
+
offset: {
|
|
109
|
+
type: 'number',
|
|
110
|
+
description: 'Number of results to skip for pagination (default: 0). Only applies to filter-based search.',
|
|
111
|
+
default: 0,
|
|
112
|
+
},
|
|
113
|
+
limit: {
|
|
114
|
+
type: 'number',
|
|
115
|
+
description: 'Maximum number of results to return (default: 10 for semantic search, unlimited for filter-only, max: 100). Use for pagination to avoid response size limits.',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
name: 'update_tiddler',
|
|
122
|
+
description: 'Update an existing tiddler. Shows a diff of changes and requests approval before applying. Preserves metadata like created timestamp. Supports arbitrary custom fields beyond the standard ones (e.g., caption, summary, author, or any TiddlyWiki field).',
|
|
123
|
+
inputSchema: {
|
|
124
|
+
type: 'object',
|
|
125
|
+
properties: {
|
|
126
|
+
title: {
|
|
127
|
+
type: 'string',
|
|
128
|
+
description: 'Title of the tiddler to update',
|
|
129
|
+
},
|
|
130
|
+
text: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'New text content (optional)',
|
|
133
|
+
},
|
|
134
|
+
tags: {
|
|
135
|
+
type: 'string',
|
|
136
|
+
description: 'New tags as space-separated string (optional)',
|
|
137
|
+
},
|
|
138
|
+
type: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
description: 'Content type like "text/markdown" or "text/vnd.tiddlywiki" (optional)',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
additionalProperties: {
|
|
144
|
+
type: 'string',
|
|
145
|
+
description: 'Any additional TiddlyWiki field (e.g., caption, summary, author)',
|
|
146
|
+
},
|
|
147
|
+
required: ['title'],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
name: 'create_tiddler',
|
|
152
|
+
description: 'Create a new tiddler. Shows a preview and requests approval before creating. Supports arbitrary custom fields beyond the standard ones (e.g., caption, summary, author, or any TiddlyWiki field).',
|
|
153
|
+
inputSchema: {
|
|
154
|
+
type: 'object',
|
|
155
|
+
properties: {
|
|
156
|
+
title: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
description: 'Title of the new tiddler',
|
|
159
|
+
},
|
|
160
|
+
text: {
|
|
161
|
+
type: 'string',
|
|
162
|
+
description: 'Text content',
|
|
163
|
+
},
|
|
164
|
+
tags: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Tags as space-separated string (optional, e.g., "Journal" or "Journal OYS")',
|
|
167
|
+
default: '',
|
|
168
|
+
},
|
|
169
|
+
type: {
|
|
170
|
+
type: 'string',
|
|
171
|
+
description: 'Content type (default: text/markdown)',
|
|
172
|
+
default: 'text/markdown',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
additionalProperties: {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description: 'Any additional TiddlyWiki field (e.g., caption, summary, author)',
|
|
178
|
+
},
|
|
179
|
+
required: ['title', 'text'],
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'delete_tiddler',
|
|
184
|
+
description: 'Delete a tiddler. Shows current content and requests approval before deleting.',
|
|
185
|
+
inputSchema: {
|
|
186
|
+
type: 'object',
|
|
187
|
+
properties: {
|
|
188
|
+
title: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Title of the tiddler to delete',
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
required: ['title'],
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
],
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
// Tool implementation handler
|
|
200
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
201
|
+
const { name, arguments: args } = request.params;
|
|
202
|
+
try {
|
|
203
|
+
switch (name) {
|
|
204
|
+
case 'search_tiddlers':
|
|
205
|
+
return await handleSearchTiddlers(args, getToolDependencies());
|
|
206
|
+
case 'update_tiddler':
|
|
207
|
+
return await handleUpdateTiddler(args);
|
|
208
|
+
case 'create_tiddler':
|
|
209
|
+
return await handleCreateTiddler(args);
|
|
210
|
+
case 'delete_tiddler':
|
|
211
|
+
return await handleDeleteTiddler(args);
|
|
212
|
+
default:
|
|
213
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
const err = error;
|
|
218
|
+
logger.error(`[MCP Server] Error executing tool ${name}:`, err.message);
|
|
219
|
+
return {
|
|
220
|
+
content: [
|
|
221
|
+
{
|
|
222
|
+
type: 'text',
|
|
223
|
+
text: JSON.stringify({
|
|
224
|
+
error: err.message,
|
|
225
|
+
tool: name,
|
|
226
|
+
}, null, 2),
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
isError: true,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Start MCP server with stdio transport
|
|
236
|
+
*/
|
|
237
|
+
async function startStdioTransport() {
|
|
238
|
+
stdioServer = createServer();
|
|
239
|
+
const transport = new StdioServerTransport();
|
|
240
|
+
await stdioServer.connect(transport);
|
|
241
|
+
logger.log(`[MCP Server] Server running on stdio`);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Start MCP server with HTTP transport using stateless mode.
|
|
245
|
+
*
|
|
246
|
+
* In stateless mode, each request gets its own Server and Transport instance.
|
|
247
|
+
* This prevents request ID collisions when multiple clients connect concurrently.
|
|
248
|
+
* The MCP specification notes: "A single instance would cause request ID collisions
|
|
249
|
+
* when multiple clients connect concurrently."
|
|
250
|
+
*
|
|
251
|
+
* Note: Stateless mode does not support server-initiated messages (SSE streams).
|
|
252
|
+
* This is acceptable for our use case since we only respond to client requests.
|
|
253
|
+
*/
|
|
254
|
+
async function startHttpTransport() {
|
|
255
|
+
const app = express();
|
|
256
|
+
const port = parseInt(process.env.MCP_PORT || process.env.PORT || '3000', 10);
|
|
257
|
+
app.use(express.json());
|
|
258
|
+
// Health check endpoint for Nomad
|
|
259
|
+
app.get('/health', (_req, res) => {
|
|
260
|
+
res.status(200).json({ status: 'healthy', service: 'tiddlywiki-mcp-server' });
|
|
261
|
+
});
|
|
262
|
+
// Request timeout (90 seconds) as safety net against any blocking operations
|
|
263
|
+
const REQUEST_TIMEOUT_MS = 90000;
|
|
264
|
+
// MCP POST endpoint - handles JSON-RPC requests in stateless mode
|
|
265
|
+
app.post('/mcp', async (req, res) => {
|
|
266
|
+
const requestId = randomUUID().slice(0, 8);
|
|
267
|
+
logger.debug(`[MCP Server] [${requestId}] Handling request`);
|
|
268
|
+
// Create timeout promise
|
|
269
|
+
let timeoutId = null;
|
|
270
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
271
|
+
timeoutId = setTimeout(() => {
|
|
272
|
+
reject(new Error(`Request timed out after ${REQUEST_TIMEOUT_MS}ms`));
|
|
273
|
+
}, REQUEST_TIMEOUT_MS);
|
|
274
|
+
});
|
|
275
|
+
try {
|
|
276
|
+
// Create fresh server and transport for this request
|
|
277
|
+
const server = createServer();
|
|
278
|
+
const transport = new StreamableHTTPServerTransport({
|
|
279
|
+
sessionIdGenerator: undefined,
|
|
280
|
+
});
|
|
281
|
+
// Connect and handle the request with timeout
|
|
282
|
+
const handlePromise = (async () => {
|
|
283
|
+
await server.connect(transport);
|
|
284
|
+
await transport.handleRequest(req, res, req.body);
|
|
285
|
+
})();
|
|
286
|
+
await Promise.race([handlePromise, timeoutPromise]);
|
|
287
|
+
logger.debug(`[MCP Server] [${requestId}] Request completed`);
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
const err = error;
|
|
291
|
+
const isTimeout = err.message.includes('timed out');
|
|
292
|
+
logger.error(`[MCP Server] [${requestId}] ${isTimeout ? 'Request timeout' : 'Error handling request'}:`, err.message);
|
|
293
|
+
if (!res.headersSent) {
|
|
294
|
+
res.status(isTimeout ? 504 : 500).json({
|
|
295
|
+
jsonrpc: '2.0',
|
|
296
|
+
error: {
|
|
297
|
+
code: isTimeout ? -32001 : -32603,
|
|
298
|
+
message: isTimeout ? 'Request timeout' : 'Internal server error',
|
|
299
|
+
},
|
|
300
|
+
id: null,
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
finally {
|
|
305
|
+
if (timeoutId) {
|
|
306
|
+
clearTimeout(timeoutId);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
// SSE streams not supported in stateless mode - return helpful error
|
|
311
|
+
app.get('/mcp', async (_req, res) => {
|
|
312
|
+
res.status(400).json({
|
|
313
|
+
jsonrpc: '2.0',
|
|
314
|
+
error: {
|
|
315
|
+
code: -32000,
|
|
316
|
+
message: 'SSE streams not supported in stateless mode. Use POST for all requests.',
|
|
317
|
+
},
|
|
318
|
+
id: null,
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
// DELETE not needed in stateless mode - return helpful error
|
|
322
|
+
app.delete('/mcp', async (_req, res) => {
|
|
323
|
+
res.status(400).json({
|
|
324
|
+
jsonrpc: '2.0',
|
|
325
|
+
error: {
|
|
326
|
+
code: -32000,
|
|
327
|
+
message: 'Session termination not needed in stateless mode.',
|
|
328
|
+
},
|
|
329
|
+
id: null,
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
// Start HTTP server
|
|
333
|
+
app.listen(port, () => {
|
|
334
|
+
logger.log(`[MCP Server] HTTP server listening on port ${port}`);
|
|
335
|
+
logger.debug(`[MCP Server] Health: http://localhost:${port}/health | MCP: http://localhost:${port}/mcp`);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
// Main startup function
|
|
339
|
+
async function main() {
|
|
340
|
+
const tiddlywikiUrl = process.env.TIDDLYWIKI_URL;
|
|
341
|
+
if (!tiddlywikiUrl) {
|
|
342
|
+
logger.error('[MCP Server] TIDDLYWIKI_URL environment variable is required');
|
|
343
|
+
logger.error('[MCP Server] Example: TIDDLYWIKI_URL=http://localhost:8080');
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
const authHeader = process.env.AUTH_HEADER || 'X-Oidc-Username';
|
|
347
|
+
const authUser = process.env.AUTH_USER || 'mcp-user';
|
|
348
|
+
const transport = process.env.MCP_TRANSPORT || 'stdio';
|
|
349
|
+
const ollamaUrl = process.env.OLLAMA_URL || 'http://localhost:11434';
|
|
350
|
+
const embeddingsEnabled = process.env.EMBEDDINGS_ENABLED !== 'false'; // Enabled by default
|
|
351
|
+
const embeddingsDbPath = process.env.EMBEDDINGS_DB_PATH || './embeddings.db';
|
|
352
|
+
logger.log(`[MCP Server] Starting TiddlyWiki MCP Server...`);
|
|
353
|
+
logger.debug(`[MCP Server] Transport: ${transport}`);
|
|
354
|
+
logger.debug(`[MCP Server] TiddlyWiki URL: ${tiddlywikiUrl}`);
|
|
355
|
+
logger.debug(`[MCP Server] Auth: ${authHeader}=${authUser}`);
|
|
356
|
+
logger.debug(`[MCP Server] Embeddings: ${embeddingsEnabled ? embeddingsDbPath : 'disabled'}`);
|
|
357
|
+
if (embeddingsEnabled) {
|
|
358
|
+
logger.debug(`[MCP Server] Ollama URL: ${ollamaUrl}`);
|
|
359
|
+
}
|
|
360
|
+
try {
|
|
361
|
+
// Initialize TiddlyWiki HTTP client
|
|
362
|
+
initTiddlyWiki({
|
|
363
|
+
tiddlywikiUrl,
|
|
364
|
+
authHeader,
|
|
365
|
+
authUser,
|
|
366
|
+
});
|
|
367
|
+
logger.debug(`[MCP Server] TiddlyWiki client initialized`);
|
|
368
|
+
// Initialize embeddings infrastructure (if enabled)
|
|
369
|
+
if (embeddingsEnabled) {
|
|
370
|
+
try {
|
|
371
|
+
logger.debug(`[MCP Server] Initializing embeddings infrastructure...`);
|
|
372
|
+
// Initialize database
|
|
373
|
+
embeddingsDB = new EmbeddingsDB(embeddingsDbPath);
|
|
374
|
+
logger.debug(`[MCP Server] Embeddings database initialized`);
|
|
375
|
+
// Initialize Ollama client
|
|
376
|
+
ollamaClient = new OllamaClient(ollamaUrl);
|
|
377
|
+
// Check Ollama health
|
|
378
|
+
const healthy = await ollamaClient.healthCheck();
|
|
379
|
+
if (healthy) {
|
|
380
|
+
logger.debug(`[MCP Server] Ollama is healthy`);
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
logger.warn(`[MCP Server] WARNING: Ollama is not responding at ${ollamaUrl}`);
|
|
384
|
+
logger.warn(`[MCP Server] Semantic search will not be available until Ollama is running`);
|
|
385
|
+
}
|
|
386
|
+
// Initialize and start sync worker
|
|
387
|
+
syncWorker = new SyncWorker(embeddingsDB, ollamaClient, {
|
|
388
|
+
syncIntervalMs: 5 * 60 * 1000, // 5 minutes
|
|
389
|
+
batchSize: 5,
|
|
390
|
+
enabled: true,
|
|
391
|
+
});
|
|
392
|
+
await syncWorker.start();
|
|
393
|
+
logger.debug(`[MCP Server] Sync worker started`);
|
|
394
|
+
const status = syncWorker.getStatus();
|
|
395
|
+
logger.log(`[MCP Server] Embeddings ready (${status.indexedTiddlers} tiddlers, ${status.totalEmbeddings} chunks)`);
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
const err = error;
|
|
399
|
+
logger.warn(`[MCP Server] WARNING: Failed to initialize embeddings: ${err.message}`);
|
|
400
|
+
logger.warn(`[MCP Server] Semantic search will not be available`);
|
|
401
|
+
// Don't fail startup, just disable embeddings
|
|
402
|
+
embeddingsDB = null;
|
|
403
|
+
ollamaClient = null;
|
|
404
|
+
syncWorker = null;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
// Start appropriate transport
|
|
408
|
+
if (transport === 'http') {
|
|
409
|
+
await startHttpTransport();
|
|
410
|
+
}
|
|
411
|
+
else if (transport === 'stdio') {
|
|
412
|
+
await startStdioTransport();
|
|
413
|
+
}
|
|
414
|
+
else {
|
|
415
|
+
throw new Error(`Invalid transport: ${transport}. Use 'stdio' or 'http'`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
catch (error) {
|
|
419
|
+
const err = error;
|
|
420
|
+
logger.error(`[MCP Server] Failed to start: ${err.message}`);
|
|
421
|
+
process.exit(1);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
// Graceful shutdown
|
|
425
|
+
process.on('SIGINT', () => {
|
|
426
|
+
logger.log(`[MCP Server] Shutting down...`);
|
|
427
|
+
if (syncWorker) {
|
|
428
|
+
syncWorker.stop();
|
|
429
|
+
}
|
|
430
|
+
if (embeddingsDB) {
|
|
431
|
+
embeddingsDB.close();
|
|
432
|
+
}
|
|
433
|
+
process.exit(0);
|
|
434
|
+
});
|
|
435
|
+
process.on('SIGTERM', () => {
|
|
436
|
+
logger.log(`[MCP Server] Shutting down...`);
|
|
437
|
+
if (syncWorker) {
|
|
438
|
+
syncWorker.stop();
|
|
439
|
+
}
|
|
440
|
+
if (embeddingsDB) {
|
|
441
|
+
embeddingsDB.close();
|
|
442
|
+
}
|
|
443
|
+
process.exit(0);
|
|
444
|
+
});
|
|
445
|
+
// Start the server
|
|
446
|
+
main().catch((error) => {
|
|
447
|
+
logger.error(`[MCP Server] Fatal error:`, error);
|
|
448
|
+
process.exit(1);
|
|
449
|
+
});
|
|
450
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,oDAAoD;AACpD,iFAAiF;AAEjF,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAC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EAAE;IACxB,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;IAC5C,IAAI,UAAU,EAAE,CAAC;QACf,UAAU,CAAC,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;IACjD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Log informational messages (always shown)
|
|
3
|
+
*/
|
|
4
|
+
export declare function log(message: string, ...args: unknown[]): void;
|
|
5
|
+
/**
|
|
6
|
+
* Log error messages (always shown)
|
|
7
|
+
*/
|
|
8
|
+
export declare function error(message: string, ...args: unknown[]): void;
|
|
9
|
+
/**
|
|
10
|
+
* Log warning messages (always shown)
|
|
11
|
+
*/
|
|
12
|
+
export declare function warn(message: string, ...args: unknown[]): void;
|
|
13
|
+
/**
|
|
14
|
+
* Log debug messages (only shown when LOG_DEBUG=true)
|
|
15
|
+
*/
|
|
16
|
+
export declare function debug(message: string, ...args: unknown[]): void;
|
|
17
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AASA;;GAEG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE7D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE/D;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAI/D"}
|