nodebb-plugin-integration 0.3.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.
@@ -0,0 +1,324 @@
1
+ "use strict";
2
+
3
+ /*
4
+
5
+ NodeBB Integration Layer
6
+
7
+
8
+ NodeBB Events
9
+
10
+
11
+
12
+ */
13
+
14
+
15
+
16
+
17
+ const Indexer =
18
+ require("../ai/indexer");
19
+
20
+
21
+
22
+
23
+ let initialized = false;
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+
32
+
33
+
34
+
35
+
36
+
37
+ async function init() {
38
+
39
+
40
+
41
+
42
+ if(initialized) {
43
+
44
+
45
+ return;
46
+
47
+
48
+ }
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+ initialized = true;
57
+
58
+
59
+
60
+
61
+
62
+ console.log(
63
+
64
+ "[Events] initialized"
65
+
66
+ );
67
+
68
+
69
+
70
+
71
+
72
+ console.log(
73
+
74
+ "[Events] AI provider:",
75
+
76
+ process.env.AI_PROVIDER || "fake"
77
+
78
+ );
79
+
80
+
81
+
82
+
83
+ }
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ /*
98
+
99
+ New post handler
100
+
101
+
102
+ NodeBB hook:
103
+
104
+
105
+ filter.save
106
+
107
+
108
+
109
+ */
110
+
111
+ async function postSave(post) {
112
+
113
+
114
+
115
+
116
+ try {
117
+
118
+
119
+
120
+ if(!post) {
121
+
122
+
123
+ return post;
124
+
125
+
126
+ }
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+ console.log(
135
+
136
+ "[Events] post saved:",
137
+
138
+ post.pid
139
+
140
+ );
141
+
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+ if(Indexer && typeof Indexer.indexPost === "function") {
150
+
151
+
152
+ await Indexer.indexPost(
153
+
154
+ post
155
+
156
+ );
157
+
158
+
159
+ }
160
+
161
+
162
+
163
+ }
164
+
165
+
166
+ catch(error) {
167
+
168
+
169
+
170
+ console.error(
171
+
172
+ "[Events] postSave error",
173
+
174
+ error.message
175
+
176
+ );
177
+
178
+
179
+
180
+ }
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+ return post;
189
+
190
+ }
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ /*
205
+
206
+ New topic handler
207
+
208
+
209
+ NodeBB hook:
210
+
211
+
212
+ filter.create
213
+
214
+
215
+
216
+ */
217
+
218
+ async function topicCreate(topic) {
219
+
220
+
221
+
222
+
223
+ try {
224
+
225
+
226
+
227
+ if(!topic) {
228
+
229
+
230
+ return topic;
231
+
232
+
233
+ }
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+ console.log(
242
+
243
+ "[Events] topic created:",
244
+
245
+ topic.tid
246
+
247
+ );
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ if(Indexer && typeof Indexer.indexTopic === "function") {
257
+
258
+
259
+ await Indexer.indexTopic(
260
+
261
+ topic
262
+
263
+ );
264
+
265
+
266
+ }
267
+
268
+
269
+
270
+ }
271
+
272
+
273
+ catch(error) {
274
+
275
+
276
+
277
+ console.error(
278
+
279
+ "[Events] topicCreate error",
280
+
281
+ error.message
282
+
283
+ );
284
+
285
+
286
+
287
+ }
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+ return topic;
296
+
297
+ }
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+ module.exports = {
312
+
313
+ init,
314
+
315
+
316
+ postSave,
317
+
318
+
319
+ topicCreate
320
+
321
+
322
+
323
+
324
+ };
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+
3
+ /*
4
+
5
+ NodeBB Integration Layer
6
+
7
+
8
+ MCP Server
9
+
10
+
11
+
12
+ */
13
+
14
+
15
+
16
+
17
+ const {
18
+
19
+ Server
20
+
21
+ } = require("@modelcontextprotocol/sdk/server/index.js");
22
+
23
+
24
+
25
+
26
+ const {
27
+
28
+ StdioServerTransport
29
+
30
+ } = require("@modelcontextprotocol/sdk/server/stdio.js");
31
+
32
+
33
+
34
+
35
+ const Tools =
36
+ require("./tools");
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ let server = null;
51
+
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+
60
+
61
+
62
+
63
+
64
+ function createServer() {
65
+
66
+
67
+
68
+
69
+ if(server) {
70
+
71
+
72
+ return server;
73
+
74
+
75
+ }
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+ server = new Server(
85
+
86
+
87
+ {
88
+
89
+ name:
90
+
91
+ "nodebb-integration-mcp",
92
+
93
+
94
+ version:
95
+
96
+ "0.2.0"
97
+
98
+
99
+ },
100
+
101
+
102
+ {
103
+
104
+
105
+ capabilities:
106
+
107
+
108
+ {
109
+
110
+
111
+ tools: {}
112
+
113
+ }
114
+
115
+
116
+ }
117
+
118
+
119
+ );
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+ Tools.register(
129
+
130
+ server
131
+
132
+ );
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ return server;
142
+
143
+
144
+
145
+
146
+ }
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ async function start() {
161
+
162
+
163
+
164
+
165
+ const mcpServer =
166
+
167
+ createServer();
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+ const transport =
176
+
177
+ new StdioServerTransport();
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+ await mcpServer.connect(
187
+
188
+ transport
189
+
190
+ );
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ console.log(
200
+
201
+ "[MCP] server started"
202
+
203
+ );
204
+
205
+
206
+
207
+
208
+ }
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+ module.exports = {
223
+
224
+ createServer,
225
+
226
+
227
+ start
228
+
229
+
230
+
231
+
232
+ };