lotus-wisdom-mcp 0.1.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/dist/cli.js ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+
3
+ import '../dist/bundle.js';
package/dist/index.js ADDED
@@ -0,0 +1,283 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
5
+ // Fixed chalk import for ESM
6
+ import chalk from 'chalk';
7
+ // Lotus Sutra framework tags
8
+ const CORE_TAGS = [
9
+ // Skillful Means
10
+ 'upaya', 'expedient', 'direct', 'gradual', 'sudden',
11
+ // Non-Dual Recognition
12
+ 'recognize', 'transform', 'integrate', 'transcend', 'embody',
13
+ // Meta-Cognitive
14
+ 'examine', 'reflect', 'verify', 'refine', 'complete',
15
+ // Process Steps
16
+ 'open', 'engage', 'transform', 'express', 'meditate',
17
+ // Output
18
+ 'OUTPUT'
19
+ ];
20
+ class LotusWisdomServer {
21
+ thoughtProcess = [];
22
+ finalOutput = '';
23
+ validateThoughtData(input) {
24
+ const data = input;
25
+ if (!data.tag || typeof data.tag !== 'string') {
26
+ throw new Error('Invalid tag: must be a string');
27
+ }
28
+ if (!CORE_TAGS.includes(data.tag)) {
29
+ throw new Error(`Invalid tag: ${data.tag}. Must be one of: ${CORE_TAGS.join(', ')}`);
30
+ }
31
+ if (!data.content || typeof data.content !== 'string') {
32
+ throw new Error('Invalid content: must be a string');
33
+ }
34
+ if (!data.stepNumber || typeof data.stepNumber !== 'number') {
35
+ throw new Error('Invalid stepNumber: must be a number');
36
+ }
37
+ if (!data.totalSteps || typeof data.totalSteps !== 'number') {
38
+ throw new Error('Invalid totalSteps: must be a number');
39
+ }
40
+ if (typeof data.nextStepNeeded !== 'boolean') {
41
+ throw new Error('Invalid nextStepNeeded: must be a boolean');
42
+ }
43
+ // If this is a final output, store it
44
+ if (data.tag === 'OUTPUT') {
45
+ this.finalOutput = data.content;
46
+ }
47
+ return {
48
+ tag: data.tag,
49
+ content: data.content,
50
+ stepNumber: data.stepNumber,
51
+ totalSteps: data.totalSteps,
52
+ nextStepNeeded: data.nextStepNeeded,
53
+ isMeditation: data.isMeditation,
54
+ meditationDuration: data.meditationDuration,
55
+ };
56
+ }
57
+ formatThought(thoughtData) {
58
+ const { tag, stepNumber, totalSteps, content, isMeditation } = thoughtData;
59
+ // Color coding for different tag types
60
+ let tagColor;
61
+ let tagSymbol;
62
+ // Skillful Means
63
+ if (['upaya', 'expedient', 'direct', 'gradual', 'sudden'].includes(tag)) {
64
+ tagColor = chalk.yellow;
65
+ tagSymbol = '🔆';
66
+ }
67
+ // Non-Dual Recognition
68
+ else if (['recognize', 'transform', 'integrate', 'transcend', 'embody'].includes(tag)) {
69
+ tagColor = chalk.green;
70
+ tagSymbol = '☯️';
71
+ }
72
+ // Meta-Cognitive
73
+ else if (['examine', 'reflect', 'verify', 'refine', 'complete'].includes(tag)) {
74
+ tagColor = chalk.blue;
75
+ tagSymbol = '🧠';
76
+ }
77
+ // Process Steps
78
+ else if (['open', 'engage', 'express'].includes(tag)) {
79
+ tagColor = chalk.magenta;
80
+ tagSymbol = '🌊';
81
+ }
82
+ // Meditation
83
+ else if (tag === 'meditate') {
84
+ tagColor = chalk.cyan;
85
+ tagSymbol = '🧘';
86
+ }
87
+ // Output
88
+ else if (tag === 'OUTPUT') {
89
+ tagColor = chalk.white.bold;
90
+ tagSymbol = '🌸';
91
+ }
92
+ // Transform (special case since it appears in multiple categories)
93
+ else if (tag === 'transform') {
94
+ tagColor = chalk.green;
95
+ tagSymbol = '🔄';
96
+ }
97
+ else {
98
+ tagColor = chalk.white;
99
+ tagSymbol = '💭';
100
+ }
101
+ const header = `${tagSymbol} <${tag}> Step ${stepNumber}/${totalSteps}`;
102
+ const formattedHeader = tagColor(header);
103
+ let formattedContent;
104
+ // Special formatting for meditation
105
+ if (isMeditation) {
106
+ formattedContent = chalk.cyan(`..........................
107
+ [letting thoughts settle into clarity]
108
+ ..........................
109
+ [wisdom naturally emerging]
110
+ ..........................`);
111
+ }
112
+ else {
113
+ formattedContent = content;
114
+ }
115
+ // Special formatting for output
116
+ if (tag === 'OUTPUT') {
117
+ const border = '═'.repeat(Math.max(header.length, content.length) + 4);
118
+ return `
119
+ ╔${border}╗
120
+ ║ ${formattedHeader} ║
121
+ ╠${border}╣
122
+ ║ ${content.padEnd(border.length - 2)} ║
123
+ ╚${border}╝
124
+ <<<END>>>`;
125
+ }
126
+ const border = '─'.repeat(Math.max(header.length, content.length) + 4);
127
+ return `
128
+ ┌${border}┐
129
+ │ ${formattedHeader} │
130
+ ├${border}┤
131
+ │ ${formattedContent.padEnd(border.length - 2)} │
132
+ └${border}┘`;
133
+ }
134
+ processThought(input) {
135
+ try {
136
+ const validatedInput = this.validateThoughtData(input);
137
+ if (validatedInput.stepNumber > validatedInput.totalSteps) {
138
+ validatedInput.totalSteps = validatedInput.stepNumber;
139
+ }
140
+ this.thoughtProcess.push(validatedInput);
141
+ const formattedThought = this.formatThought(validatedInput);
142
+ console.error(formattedThought);
143
+ // Include final output in the response if we're at the end
144
+ const includeOutput = !validatedInput.nextStepNeeded && validatedInput.tag === 'OUTPUT';
145
+ return {
146
+ content: [{
147
+ type: "text",
148
+ text: JSON.stringify({
149
+ stepNumber: validatedInput.stepNumber,
150
+ totalSteps: validatedInput.totalSteps,
151
+ nextStepNeeded: validatedInput.nextStepNeeded,
152
+ tag: validatedInput.tag,
153
+ processLength: this.thoughtProcess.length,
154
+ finalOutput: includeOutput ? this.finalOutput : undefined
155
+ }, null, 2)
156
+ }]
157
+ };
158
+ }
159
+ catch (error) {
160
+ return {
161
+ content: [{
162
+ type: "text",
163
+ text: JSON.stringify({
164
+ error: error instanceof Error ? error.message : String(error),
165
+ status: 'failed'
166
+ }, null, 2)
167
+ }],
168
+ isError: true
169
+ };
170
+ }
171
+ }
172
+ }
173
+ const LOTUS_WISDOM_TOOL = {
174
+ name: "lotuswisdom",
175
+ description: `A tool for problem-solving using the Lotus Sutra's wisdom framework.
176
+ This tool helps analyze problems through multiple approaches while recognizing inherent wisdom.
177
+ Each step can utilize different techniques for understanding and expression.
178
+
179
+ When to use this tool:
180
+ - Breaking down complex problems requiring multi-faceted understanding
181
+ - Questions that benefit from both direct and gradual approaches
182
+ - Problems where apparent contradictions need integration
183
+ - Situations requiring both analytical and intuitive understanding
184
+ - Tasks that benefit from meditative pauses to allow insight
185
+ - Questions containing their own inherent wisdom
186
+
187
+ Key features:
188
+ - Multiple approaches through Skillful Means (upaya, expedient, direct, gradual, sudden)
189
+ - Non-Dual Recognition (recognize, transform, integrate, transcend, embody)
190
+ - Meta-Cognitive Awareness (examine, reflect, verify, refine, complete)
191
+ - Process Steps (open, engage, transform, express)
192
+ - Meditative Space (meditate)
193
+ - Final Output (OUTPUT)
194
+
195
+ Process methodology:
196
+ 1. Initial Opening <open> - Recognize the question's nature
197
+ 2. Skillful Engagement <engage> - Choose appropriate methods
198
+ 3. Transformation <transform> - Convert confusion to clarity
199
+ 4. Natural Expression <express> - Allow understanding to flow
200
+ 5. Final Integration <OUTPUT> - Present clear, beneficial response
201
+
202
+ Parameters explained:
203
+ - tag: The current processing technique (must be one of the core tags)
204
+ - content: The content of the current processing step
205
+ - stepNumber: Current number in sequence
206
+ - totalSteps: Current estimate of steps needed
207
+ - nextStepNeeded: Whether another step is needed
208
+ - isMeditation: Whether this step is a meditative pause
209
+ - meditationDuration: Optional duration for meditation
210
+
211
+ Every inquiry concludes with a final <OUTPUT> tag containing the complete response.`,
212
+ inputSchema: {
213
+ type: "object",
214
+ properties: {
215
+ tag: {
216
+ type: "string",
217
+ description: "Current processing technique",
218
+ enum: CORE_TAGS
219
+ },
220
+ content: {
221
+ type: "string",
222
+ description: "Content of the current processing step"
223
+ },
224
+ stepNumber: {
225
+ type: "integer",
226
+ description: "Current step number",
227
+ minimum: 1
228
+ },
229
+ totalSteps: {
230
+ type: "integer",
231
+ description: "Estimated total steps needed",
232
+ minimum: 1
233
+ },
234
+ nextStepNeeded: {
235
+ type: "boolean",
236
+ description: "Whether another step is needed"
237
+ },
238
+ isMeditation: {
239
+ type: "boolean",
240
+ description: "Whether this step is a meditative pause"
241
+ },
242
+ meditationDuration: {
243
+ type: "integer",
244
+ description: "Duration for meditation in seconds",
245
+ minimum: 1
246
+ }
247
+ },
248
+ required: ["tag", "content", "stepNumber", "totalSteps", "nextStepNeeded"]
249
+ }
250
+ };
251
+ const server = new Server({
252
+ name: "lotus-wisdom-server",
253
+ version: "0.1.0",
254
+ }, {
255
+ capabilities: {
256
+ tools: {},
257
+ },
258
+ });
259
+ const wisdomServer = new LotusWisdomServer();
260
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({
261
+ tools: [LOTUS_WISDOM_TOOL],
262
+ }));
263
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
264
+ if (request.params.name === "lotuswisdom") {
265
+ return wisdomServer.processThought(request.params.arguments);
266
+ }
267
+ return {
268
+ content: [{
269
+ type: "text",
270
+ text: `Unknown tool: ${request.params.name}`
271
+ }],
272
+ isError: true
273
+ };
274
+ });
275
+ async function runServer() {
276
+ const transport = new StdioServerTransport();
277
+ await server.connect(transport);
278
+ console.error("Lotus Wisdom MCP Server running on stdio");
279
+ }
280
+ runServer().catch((error) => {
281
+ console.error("Fatal error running server:", error);
282
+ process.exit(1);
283
+ });
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "lotus-wisdom-mcp",
3
+ "version": "0.1.0",
4
+ "description": "A Model Context Protocol server implementing the Lotus Wisdom framework",
5
+ "main": "dist/bundle.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "lotus-wisdom": "cli.js"
9
+ },
10
+ "files": [
11
+ "dist/",
12
+ "cli.js",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc && npx esbuild index.ts --bundle --platform=node --format=esm --outfile=dist/bundle.js",
18
+ "start": "node dist/bundle.js",
19
+ "dev": "tsc && node dist/index.js",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/linxule/lotus-wisdom-mcp.git"
25
+ },
26
+ "keywords": [
27
+ "mcp",
28
+ "model-context-protocol",
29
+ "lotus-sutra",
30
+ "wisdom",
31
+ "claude",
32
+ "ai-tools"
33
+ ],
34
+ "author": "Xule Lin",
35
+ "license": "MIT",
36
+ "bugs": {
37
+ "url": "https://github.com/linxule/lotus-wisdom-mcp/issues"
38
+ },
39
+ "homepage": "https://github.com/linxule/lotus-wisdom-mcp#readme",
40
+ "dependencies": {
41
+ "@modelcontextprotocol/sdk": "^1.8.0",
42
+ "chalk": "^5.3.0"
43
+ },
44
+ "devDependencies": {
45
+ "@types/node": "^20.11.5",
46
+ "typescript": "^5.3.3"
47
+ },
48
+ "engines": {
49
+ "node": ">=18.0.0"
50
+ }
51
+ }