@rolexjs/mcp-server 0.5.0 → 0.7.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/index.js +97 -38
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -17,9 +17,16 @@ import {
|
|
|
17
17
|
DESC_TODO,
|
|
18
18
|
DESC_ACHIEVE,
|
|
19
19
|
DESC_ABANDON,
|
|
20
|
+
DESC_REFLECT,
|
|
20
21
|
DESC_FINISH,
|
|
21
22
|
renderFeatures,
|
|
22
23
|
renderFeature,
|
|
24
|
+
renderStatusBar,
|
|
25
|
+
renderError,
|
|
26
|
+
next,
|
|
27
|
+
NEXT,
|
|
28
|
+
nextHire,
|
|
29
|
+
nextFinish,
|
|
23
30
|
bootstrap
|
|
24
31
|
} from "rolexjs";
|
|
25
32
|
import { LocalPlatform } from "@rolexjs/local-platform";
|
|
@@ -31,6 +38,7 @@ var platform = new LocalPlatform(rolexDir);
|
|
|
31
38
|
bootstrap(platform);
|
|
32
39
|
var rolex = new Rolex(platform);
|
|
33
40
|
var currentRole = null;
|
|
41
|
+
var currentRoleName = "";
|
|
34
42
|
var server = new FastMCP({
|
|
35
43
|
name: "Rolex MCP Server",
|
|
36
44
|
version: "0.1.0",
|
|
@@ -42,6 +50,15 @@ function requireRole() {
|
|
|
42
50
|
}
|
|
43
51
|
return currentRole;
|
|
44
52
|
}
|
|
53
|
+
function safeTool(toolName, fn) {
|
|
54
|
+
return async (args) => {
|
|
55
|
+
try {
|
|
56
|
+
return await fn(args);
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw new Error(renderError(toolName, error));
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
45
62
|
server.addTool({
|
|
46
63
|
name: "society",
|
|
47
64
|
description: DESC_SOCIETY,
|
|
@@ -53,17 +70,17 @@ server.addTool({
|
|
|
53
70
|
type: z.enum(["knowledge", "experience", "voice"]).optional().describe("Growth dimension for teach operation"),
|
|
54
71
|
dimensionName: z.string().optional().describe("Name for the knowledge being taught (e.g. 'distributed-systems')")
|
|
55
72
|
}),
|
|
56
|
-
execute: async ({ operation, name, source, roleId, type, dimensionName }) => {
|
|
73
|
+
execute: safeTool("society", async ({ operation, name, source, roleId, type, dimensionName }) => {
|
|
57
74
|
switch (operation) {
|
|
58
75
|
case "born": {
|
|
59
76
|
if (!name || !source) throw new Error("born requires: name, source");
|
|
60
77
|
const feature = rolex.born(name, source);
|
|
61
|
-
return `Role born: ${feature.name}
|
|
78
|
+
return next(`Role born: ${feature.name}`, NEXT.born);
|
|
62
79
|
}
|
|
63
80
|
case "found": {
|
|
64
81
|
if (!name) throw new Error("found requires: name");
|
|
65
82
|
rolex.found(name);
|
|
66
|
-
return `Organization founded: ${name}
|
|
83
|
+
return next(`Organization founded: ${name}`, NEXT.found);
|
|
67
84
|
}
|
|
68
85
|
case "directory": {
|
|
69
86
|
const dir = rolex.directory();
|
|
@@ -76,7 +93,15 @@ server.addTool({
|
|
|
76
93
|
lines.push(` - ${role.name} (team: ${role.team})`);
|
|
77
94
|
}
|
|
78
95
|
}
|
|
79
|
-
|
|
96
|
+
const unaffiliated = dir.roles.filter((r) => !r.team);
|
|
97
|
+
if (unaffiliated.length > 0) {
|
|
98
|
+
lines.push("");
|
|
99
|
+
lines.push("Unaffiliated:");
|
|
100
|
+
for (const role of unaffiliated) {
|
|
101
|
+
lines.push(` - ${role.name}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return lines.join("\n") || "No roles or organizations found.";
|
|
80
105
|
}
|
|
81
106
|
case "find": {
|
|
82
107
|
if (!name) throw new Error("find requires: name");
|
|
@@ -92,12 +117,12 @@ server.addTool({
|
|
|
92
117
|
if (!roleId || !type || !dimensionName || !source)
|
|
93
118
|
throw new Error("teach requires: roleId, type, dimensionName, source");
|
|
94
119
|
const feature = rolex.teach(roleId, type, dimensionName, source);
|
|
95
|
-
return `Taught ${type}: ${feature.name}
|
|
120
|
+
return next(`Taught ${type}: ${feature.name}`, NEXT.teach);
|
|
96
121
|
}
|
|
97
122
|
default:
|
|
98
123
|
throw new Error(`Unknown society operation: ${operation}`);
|
|
99
124
|
}
|
|
100
|
-
}
|
|
125
|
+
})
|
|
101
126
|
});
|
|
102
127
|
server.addTool({
|
|
103
128
|
name: "organization",
|
|
@@ -106,22 +131,22 @@ server.addTool({
|
|
|
106
131
|
operation: z.enum(["hire", "fire"]).describe("The organization operation to perform"),
|
|
107
132
|
name: z.string().describe("Role name to hire or fire")
|
|
108
133
|
}),
|
|
109
|
-
execute: async ({ operation, name }) => {
|
|
134
|
+
execute: safeTool("organization", async ({ operation, name }) => {
|
|
110
135
|
const dir = rolex.directory();
|
|
111
136
|
const org = rolex.find(dir.organizations[0].name);
|
|
112
137
|
switch (operation) {
|
|
113
138
|
case "hire": {
|
|
114
139
|
org.hire(name);
|
|
115
|
-
return `Role hired: ${name}
|
|
140
|
+
return next(`Role hired: ${name}`, nextHire(name));
|
|
116
141
|
}
|
|
117
142
|
case "fire": {
|
|
118
143
|
org.fire(name);
|
|
119
|
-
return `Role fired: ${name}
|
|
144
|
+
return next(`Role fired: ${name}`, NEXT.fire);
|
|
120
145
|
}
|
|
121
146
|
default:
|
|
122
147
|
throw new Error(`Unknown organization operation: ${operation}`);
|
|
123
148
|
}
|
|
124
|
-
}
|
|
149
|
+
})
|
|
125
150
|
});
|
|
126
151
|
server.addTool({
|
|
127
152
|
name: "identity",
|
|
@@ -129,11 +154,16 @@ server.addTool({
|
|
|
129
154
|
parameters: z.object({
|
|
130
155
|
roleId: z.string().describe("Role name (e.g. 'sean')")
|
|
131
156
|
}),
|
|
132
|
-
execute: async ({ roleId }) => {
|
|
157
|
+
execute: safeTool("identity", async ({ roleId }) => {
|
|
133
158
|
currentRole = rolex.role(roleId);
|
|
159
|
+
currentRoleName = roleId;
|
|
134
160
|
const features = currentRole.identity();
|
|
135
|
-
|
|
136
|
-
|
|
161
|
+
const { current } = currentRole.focus();
|
|
162
|
+
const statusBar = renderStatusBar(roleId, current);
|
|
163
|
+
return `${statusBar}
|
|
164
|
+
|
|
165
|
+
${renderFeatures(features)}`;
|
|
166
|
+
})
|
|
137
167
|
});
|
|
138
168
|
server.addTool({
|
|
139
169
|
name: "growup",
|
|
@@ -145,11 +175,11 @@ server.addTool({
|
|
|
145
175
|
name: z.string().describe("Name for this growth (used as filename, e.g. 'distributed-systems')"),
|
|
146
176
|
source: z.string().describe("Gherkin feature source text")
|
|
147
177
|
}),
|
|
148
|
-
execute: async ({ type, name, source }) => {
|
|
178
|
+
execute: safeTool("growup", async ({ type, name, source }) => {
|
|
149
179
|
const role = requireRole();
|
|
150
180
|
const feature = role.growup(type, name, source);
|
|
151
|
-
return `Growth added (${type}): ${feature.name}
|
|
152
|
-
}
|
|
181
|
+
return next(`Growth added (${type}): ${feature.name}`, NEXT.growup);
|
|
182
|
+
})
|
|
153
183
|
});
|
|
154
184
|
server.addTool({
|
|
155
185
|
name: "focus",
|
|
@@ -157,11 +187,15 @@ server.addTool({
|
|
|
157
187
|
parameters: z.object({
|
|
158
188
|
name: z.string().optional().describe("Optional goal name to switch focus to")
|
|
159
189
|
}),
|
|
160
|
-
execute: async ({ name }) => {
|
|
190
|
+
execute: safeTool("focus", async ({ name }) => {
|
|
161
191
|
const role = requireRole();
|
|
162
192
|
const { current, otherGoals } = role.focus(name);
|
|
163
|
-
|
|
164
|
-
|
|
193
|
+
const statusBar = renderStatusBar(currentRoleName, current);
|
|
194
|
+
if (!current && otherGoals.length === 0)
|
|
195
|
+
return `${statusBar}
|
|
196
|
+
|
|
197
|
+
No active goal. Use want() to set a new goal.`;
|
|
198
|
+
const parts = [statusBar];
|
|
165
199
|
if (current) {
|
|
166
200
|
parts.push(renderFeature(current));
|
|
167
201
|
if (current.plan) {
|
|
@@ -178,7 +212,7 @@ server.addTool({
|
|
|
178
212
|
}
|
|
179
213
|
}
|
|
180
214
|
return parts.join("\n\n");
|
|
181
|
-
}
|
|
215
|
+
})
|
|
182
216
|
});
|
|
183
217
|
server.addTool({
|
|
184
218
|
name: "want",
|
|
@@ -188,11 +222,11 @@ server.addTool({
|
|
|
188
222
|
source: z.string().describe("Gherkin feature source text for the goal"),
|
|
189
223
|
testable: z.boolean().optional().default(false).describe("Whether this goal's scenarios should become persistent automated verification")
|
|
190
224
|
}),
|
|
191
|
-
execute: async ({ name, source, testable }) => {
|
|
225
|
+
execute: safeTool("want", async ({ name, source, testable }) => {
|
|
192
226
|
const role = requireRole();
|
|
193
227
|
const goal = role.want(name, source, testable);
|
|
194
|
-
return `Goal created: ${goal.name}
|
|
195
|
-
}
|
|
228
|
+
return next(`Goal created: ${goal.name}`, NEXT.want);
|
|
229
|
+
})
|
|
196
230
|
});
|
|
197
231
|
server.addTool({
|
|
198
232
|
name: "plan",
|
|
@@ -200,11 +234,11 @@ server.addTool({
|
|
|
200
234
|
parameters: z.object({
|
|
201
235
|
source: z.string().describe("Gherkin feature source text for the plan")
|
|
202
236
|
}),
|
|
203
|
-
execute: async ({ source }) => {
|
|
237
|
+
execute: safeTool("plan", async ({ source }) => {
|
|
204
238
|
const role = requireRole();
|
|
205
239
|
const p = role.plan(source);
|
|
206
|
-
return `Plan created: ${p.name}
|
|
207
|
-
}
|
|
240
|
+
return next(`Plan created: ${p.name}`, NEXT.plan);
|
|
241
|
+
})
|
|
208
242
|
});
|
|
209
243
|
server.addTool({
|
|
210
244
|
name: "todo",
|
|
@@ -214,11 +248,11 @@ server.addTool({
|
|
|
214
248
|
source: z.string().describe("Gherkin feature source text for the task"),
|
|
215
249
|
testable: z.boolean().optional().default(false).describe("Whether this task's scenarios should become unit or integration tests")
|
|
216
250
|
}),
|
|
217
|
-
execute: async ({ name, source, testable }) => {
|
|
251
|
+
execute: safeTool("todo", async ({ name, source, testable }) => {
|
|
218
252
|
const role = requireRole();
|
|
219
253
|
const task = role.todo(name, source, testable);
|
|
220
|
-
return `Task created: ${task.name}
|
|
221
|
-
}
|
|
254
|
+
return next(`Task created: ${task.name}`, NEXT.todo);
|
|
255
|
+
})
|
|
222
256
|
});
|
|
223
257
|
server.addTool({
|
|
224
258
|
name: "achieve",
|
|
@@ -228,11 +262,12 @@ server.addTool({
|
|
|
228
262
|
"Optional Gherkin feature source capturing what was learned \u2014 auto-saved as experience growup"
|
|
229
263
|
)
|
|
230
264
|
}),
|
|
231
|
-
execute: async ({ experience }) => {
|
|
265
|
+
execute: safeTool("achieve", async ({ experience }) => {
|
|
232
266
|
const role = requireRole();
|
|
233
267
|
role.achieve(experience);
|
|
234
|
-
|
|
235
|
-
|
|
268
|
+
const msg = experience ? "Goal achieved. Experience captured." : "Goal achieved.";
|
|
269
|
+
return next(msg, NEXT.achieve);
|
|
270
|
+
})
|
|
236
271
|
});
|
|
237
272
|
server.addTool({
|
|
238
273
|
name: "abandon",
|
|
@@ -242,11 +277,33 @@ server.addTool({
|
|
|
242
277
|
"Optional Gherkin feature source capturing what was learned \u2014 auto-saved as experience growup"
|
|
243
278
|
)
|
|
244
279
|
}),
|
|
245
|
-
execute: async ({ experience }) => {
|
|
280
|
+
execute: safeTool("abandon", async ({ experience }) => {
|
|
246
281
|
const role = requireRole();
|
|
247
282
|
role.abandon(experience);
|
|
248
|
-
|
|
249
|
-
|
|
283
|
+
const msg = experience ? "Goal abandoned. Experience captured." : "Goal abandoned.";
|
|
284
|
+
return next(msg, NEXT.abandon);
|
|
285
|
+
})
|
|
286
|
+
});
|
|
287
|
+
server.addTool({
|
|
288
|
+
name: "reflect",
|
|
289
|
+
description: DESC_REFLECT,
|
|
290
|
+
parameters: z.object({
|
|
291
|
+
experienceNames: z.array(z.string()).describe(
|
|
292
|
+
"Names of experience files to distill (without .experience.identity.feature suffix)"
|
|
293
|
+
),
|
|
294
|
+
knowledgeName: z.string().describe(
|
|
295
|
+
"Name for the resulting knowledge (used as filename, e.g. 'authentication-principles')"
|
|
296
|
+
),
|
|
297
|
+
knowledgeSource: z.string().describe("Gherkin feature source text for the knowledge")
|
|
298
|
+
}),
|
|
299
|
+
execute: safeTool("reflect", async ({ experienceNames, knowledgeName, knowledgeSource }) => {
|
|
300
|
+
const role = requireRole();
|
|
301
|
+
const feature = role.reflect(experienceNames, knowledgeName, knowledgeSource);
|
|
302
|
+
return next(
|
|
303
|
+
`Reflected: ${experienceNames.length} experience(s) \u2192 knowledge "${feature.name}"`,
|
|
304
|
+
NEXT.reflect
|
|
305
|
+
);
|
|
306
|
+
})
|
|
250
307
|
});
|
|
251
308
|
server.addTool({
|
|
252
309
|
name: "finish",
|
|
@@ -254,11 +311,13 @@ server.addTool({
|
|
|
254
311
|
parameters: z.object({
|
|
255
312
|
name: z.string().describe("Task name to mark as done")
|
|
256
313
|
}),
|
|
257
|
-
execute: async ({ name }) => {
|
|
314
|
+
execute: safeTool("finish", async ({ name }) => {
|
|
258
315
|
const role = requireRole();
|
|
259
316
|
role.finish(name);
|
|
260
|
-
|
|
261
|
-
|
|
317
|
+
const { current } = role.focus();
|
|
318
|
+
const remaining = current ? current.tasks.filter((t) => !t.tags?.some((tag) => tag.name === "@done")).length : -1;
|
|
319
|
+
return next(`Task finished: ${name}`, remaining >= 0 ? nextFinish(remaining) : NEXT.achieve);
|
|
320
|
+
})
|
|
262
321
|
});
|
|
263
322
|
server.start({
|
|
264
323
|
transportType: "stdio"
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @rolexjs/mcp-server\n *\n * MCP server for Rolex — Role-Driven Development.\n *\n * Tools:\n * society — Admin: born, found, directory, find, teach\n * organization — Admin: hire, fire\n * identity — Activate a role\n * growup/focus/want/plan/todo/achieve/abandon/finish — Role lifecycle\n *\n * Usage:\n * rolex-mcp [.rolex-dir]\n */\n\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport {\n Rolex,\n Organization,\n Role,\n INSTRUCTIONS,\n DESC_SOCIETY,\n DESC_ORGANIZATION,\n DESC_GROWUP,\n DESC_IDENTITY,\n DESC_FOCUS,\n DESC_WANT,\n DESC_PLAN,\n DESC_TODO,\n DESC_ACHIEVE,\n DESC_ABANDON,\n DESC_FINISH,\n renderFeatures,\n renderFeature,\n bootstrap,\n} from \"rolexjs\";\nimport { LocalPlatform } from \"@rolexjs/local-platform\";\n\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst DEFAULT_ROLEX_DIR = join(homedir(), \".rolex\");\nconst rolexDir = process.argv[2] || process.env.ROLEX_DIR || DEFAULT_ROLEX_DIR;\nconst platform = new LocalPlatform(rolexDir);\nbootstrap(platform);\nconst rolex = new Rolex(platform);\nlet currentRole: Role | null = null;\n\nconst server = new FastMCP({\n name: \"Rolex MCP Server\",\n version: \"0.1.0\",\n instructions: INSTRUCTIONS,\n});\n\n// ========== Helpers ==========\n\nfunction requireRole(): Role {\n if (!currentRole) {\n throw new Error(\"No active role. Call identity(roleId) first to activate a role.\");\n }\n return currentRole;\n}\n\n// ========== Society (folded) ==========\n\nserver.addTool({\n name: \"society\",\n description: DESC_SOCIETY,\n parameters: z.object({\n operation: z\n .enum([\"born\", \"found\", \"directory\", \"find\", \"teach\"])\n .describe(\"The society operation to perform\"),\n name: z\n .string()\n .optional()\n .describe(\"Role name (born/find/teach) or organization name (found)\"),\n source: z\n .string()\n .optional()\n .describe(\"Gherkin feature source (born: persona, teach: knowledge)\"),\n roleId: z.string().optional().describe(\"Target role name for teach operation\"),\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .optional()\n .describe(\"Growth dimension for teach operation\"),\n dimensionName: z\n .string()\n .optional()\n .describe(\"Name for the knowledge being taught (e.g. 'distributed-systems')\"),\n }),\n execute: async ({ operation, name, source, roleId, type, dimensionName }) => {\n switch (operation) {\n case \"born\": {\n if (!name || !source) throw new Error(\"born requires: name, source\");\n const feature = rolex.born(name, source);\n return `Role born: ${feature.name}`;\n }\n case \"found\": {\n if (!name) throw new Error(\"found requires: name\");\n rolex.found(name);\n return `Organization founded: ${name}`;\n }\n case \"directory\": {\n const dir = rolex.directory();\n const lines: string[] = [];\n for (const entry of dir.organizations) {\n const orgInstance = rolex.find(entry.name) as Organization;\n const info = orgInstance.info();\n lines.push(`Organization: ${info.name}`);\n for (const role of info.roles) {\n lines.push(` - ${role.name} (team: ${role.team})`);\n }\n }\n return lines.join(\"\\n\") || \"No organizations found.\";\n }\n case \"find\": {\n if (!name) throw new Error(\"find requires: name\");\n const result = rolex.find(name);\n if (result instanceof Organization) {\n const info = result.info();\n return `Organization: ${info.name} (${info.roles.length} roles)`;\n }\n const features = (result as Role).identity();\n return renderFeatures(features);\n }\n case \"teach\": {\n if (!roleId || !type || !dimensionName || !source)\n throw new Error(\"teach requires: roleId, type, dimensionName, source\");\n const feature = rolex.teach(roleId, type, dimensionName, source);\n return `Taught ${type}: ${feature.name}`;\n }\n default:\n throw new Error(`Unknown society operation: ${operation}`);\n }\n },\n});\n\n// ========== Organization (folded) ==========\n\nserver.addTool({\n name: \"organization\",\n description: DESC_ORGANIZATION,\n parameters: z.object({\n operation: z.enum([\"hire\", \"fire\"]).describe(\"The organization operation to perform\"),\n name: z.string().describe(\"Role name to hire or fire\"),\n }),\n execute: async ({ operation, name }) => {\n const dir = rolex.directory();\n const org = rolex.find(dir.organizations[0].name) as Organization;\n\n switch (operation) {\n case \"hire\": {\n org.hire(name);\n return `Role hired: ${name}`;\n }\n case \"fire\": {\n org.fire(name);\n return `Role fired: ${name}`;\n }\n default:\n throw new Error(`Unknown organization operation: ${operation}`);\n }\n },\n});\n\n// ========== Role Activation ==========\n\nserver.addTool({\n name: \"identity\",\n description: DESC_IDENTITY,\n parameters: z.object({\n roleId: z.string().describe(\"Role name (e.g. 'sean')\"),\n }),\n execute: async ({ roleId }) => {\n currentRole = rolex.role(roleId);\n const features = currentRole.identity();\n return renderFeatures(features);\n },\n});\n\n// ========== Role Tools ==========\n\nserver.addTool({\n name: \"growup\",\n description: DESC_GROWUP,\n parameters: z.object({\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .describe(\n \"Growth dimension: knowledge (what I know), experience (what I've lived), voice (how I'm perceived)\"\n ),\n name: z\n .string()\n .describe(\"Name for this growth (used as filename, e.g. 'distributed-systems')\"),\n source: z.string().describe(\"Gherkin feature source text\"),\n }),\n execute: async ({ type, name, source }) => {\n const role = requireRole();\n const feature = role.growup(type, name, source);\n return `Growth added (${type}): ${feature.name}`;\n },\n});\n\nserver.addTool({\n name: \"focus\",\n description: DESC_FOCUS,\n parameters: z.object({\n name: z.string().optional().describe(\"Optional goal name to switch focus to\"),\n }),\n execute: async ({ name }) => {\n const role = requireRole();\n const { current, otherGoals } = role.focus(name);\n if (!current && otherGoals.length === 0) return \"No active goal. Use want() to set a new goal.\";\n\n const parts: string[] = [];\n\n if (current) {\n parts.push(renderFeature(current));\n if (current.plan) {\n parts.push(renderFeature(current.plan));\n }\n for (const task of current.tasks) {\n parts.push(renderFeature(task));\n }\n }\n\n if (otherGoals.length > 0) {\n parts.push(\"Other active goals:\");\n for (const g of otherGoals) {\n parts.push(` - ${g.name}`);\n }\n }\n\n return parts.join(\"\\n\\n\");\n },\n});\n\nserver.addTool({\n name: \"want\",\n description: DESC_WANT,\n parameters: z.object({\n name: z.string().describe(\"Goal name (used as directory name, e.g. 'local-platform')\"),\n source: z.string().describe(\"Gherkin feature source text for the goal\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this goal's scenarios should become persistent automated verification\"),\n }),\n execute: async ({ name, source, testable }) => {\n const role = requireRole();\n const goal = role.want(name, source, testable);\n return `Goal created: ${goal.name}`;\n },\n});\n\nserver.addTool({\n name: \"plan\",\n description: DESC_PLAN,\n parameters: z.object({\n source: z.string().describe(\"Gherkin feature source text for the plan\"),\n }),\n execute: async ({ source }) => {\n const role = requireRole();\n const p = role.plan(source);\n return `Plan created: ${p.name}`;\n },\n});\n\nserver.addTool({\n name: \"todo\",\n description: DESC_TODO,\n parameters: z.object({\n name: z.string().describe(\"Task name (used as filename, e.g. 'implement-loader')\"),\n source: z.string().describe(\"Gherkin feature source text for the task\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this task's scenarios should become unit or integration tests\"),\n }),\n execute: async ({ name, source, testable }) => {\n const role = requireRole();\n const task = role.todo(name, source, testable);\n return `Task created: ${task.name}`;\n },\n});\n\nserver.addTool({\n name: \"achieve\",\n description: DESC_ACHIEVE,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: async ({ experience }) => {\n const role = requireRole();\n role.achieve(experience);\n return experience ? \"Goal achieved. Experience captured.\" : \"Goal achieved.\";\n },\n});\n\nserver.addTool({\n name: \"abandon\",\n description: DESC_ABANDON,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: async ({ experience }) => {\n const role = requireRole();\n role.abandon(experience);\n return experience ? \"Goal abandoned. Experience captured.\" : \"Goal abandoned.\";\n },\n});\n\nserver.addTool({\n name: \"finish\",\n description: DESC_FINISH,\n parameters: z.object({\n name: z.string().describe(\"Task name to mark as done\"),\n }),\n execute: async ({ name }) => {\n const role = requireRole();\n role.finish(name);\n return `Task finished: ${name}`;\n },\n});\n\nserver.start({\n transportType: \"stdio\",\n});\n"],"mappings":";;;AAeA,SAAS,eAAe;AACxB,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,IAAM,oBAAoB,KAAK,QAAQ,GAAG,QAAQ;AAClD,IAAM,WAAW,QAAQ,KAAK,CAAC,KA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EACP,SAAS,EACT;AAAA,MACC;AAAA,IACF;AAAA,EACJ,CAAC;AAAA,EACD,SAAS,OAAO,EAAE,WAAW,MAAM;AACjC,UAAM,OAAO,YAAY;AACzB,SAAK,QAAQ,UAAU;AACvB,WAAO,aAAa,yCAAyC;AAAA,EAC/D;AACF,CAAC;AAED,OAAO,QAAQ;AAAA,EACb,MAAM;AAAA,EACN,aAAa;AAAA,EACb,YAAY,EAAE,OAAO;AAAA,IACnB,MAAM,EAAE,OAAO,EAAE,SAAS,2BAA2B;AAAA,EACvD,CAAC;AAAA,EACD,SAAS,OAAO,EAAE,KAAK,MAAM;AAC3B,UAAM,OAAO,YAAY;AACzB,SAAK,OAAO,IAAI;AAChB,WAAO,kBAAkB,IAAI;AAAA,EAC/B;AACF,CAAC;AAED,OAAO,MAAM;AAAA,EACX,eAAe;AACjB,CAAC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @rolexjs/mcp-server\n *\n * MCP server for Rolex — Role-Driven Development.\n *\n * Tools:\n * society — Admin: born, found, directory, find, teach\n * organization — Admin: hire, fire\n * identity — Activate a role\n * growup/focus/want/plan/todo/achieve/abandon/finish — Role lifecycle\n *\n * Usage:\n * rolex-mcp [.rolex-dir]\n */\n\nimport { FastMCP } from \"fastmcp\";\nimport { z } from \"zod\";\nimport {\n Rolex,\n Organization,\n Role,\n INSTRUCTIONS,\n DESC_SOCIETY,\n DESC_ORGANIZATION,\n DESC_GROWUP,\n DESC_IDENTITY,\n DESC_FOCUS,\n DESC_WANT,\n DESC_PLAN,\n DESC_TODO,\n DESC_ACHIEVE,\n DESC_ABANDON,\n DESC_REFLECT,\n DESC_FINISH,\n renderFeatures,\n renderFeature,\n renderStatusBar,\n renderError,\n next,\n NEXT,\n nextHire,\n nextFinish,\n bootstrap,\n} from \"rolexjs\";\nimport { LocalPlatform } from \"@rolexjs/local-platform\";\n\nimport { join } from \"node:path\";\nimport { homedir } from \"node:os\";\n\nconst DEFAULT_ROLEX_DIR = join(homedir(), \".rolex\");\nconst rolexDir = process.argv[2] || process.env.ROLEX_DIR || DEFAULT_ROLEX_DIR;\nconst platform = new LocalPlatform(rolexDir);\nbootstrap(platform);\nconst rolex = new Rolex(platform);\nlet currentRole: Role | null = null;\nlet currentRoleName: string = \"\";\n\nconst server = new FastMCP({\n name: \"Rolex MCP Server\",\n version: \"0.1.0\",\n instructions: INSTRUCTIONS,\n});\n\n// ========== Helpers ==========\n\nfunction requireRole(): Role {\n if (!currentRole) {\n throw new Error(\"No active role. Call identity(roleId) first to activate a role.\");\n }\n return currentRole;\n}\n\n/**\n * Wrap a tool execute function with unified error handling.\n * Catches errors and renders them as formatted markdown.\n */\nfunction safeTool<T>(\n toolName: string,\n fn: (args: T) => Promise<string>\n): (args: T) => Promise<string> {\n return async (args: T) => {\n try {\n return await fn(args);\n } catch (error) {\n throw new Error(renderError(toolName, error));\n }\n };\n}\n\n// ========== Society (folded) ==========\n\nserver.addTool({\n name: \"society\",\n description: DESC_SOCIETY,\n parameters: z.object({\n operation: z\n .enum([\"born\", \"found\", \"directory\", \"find\", \"teach\"])\n .describe(\"The society operation to perform\"),\n name: z\n .string()\n .optional()\n .describe(\"Role name (born/find/teach) or organization name (found)\"),\n source: z\n .string()\n .optional()\n .describe(\"Gherkin feature source (born: persona, teach: knowledge)\"),\n roleId: z.string().optional().describe(\"Target role name for teach operation\"),\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .optional()\n .describe(\"Growth dimension for teach operation\"),\n dimensionName: z\n .string()\n .optional()\n .describe(\"Name for the knowledge being taught (e.g. 'distributed-systems')\"),\n }),\n execute: safeTool(\"society\", async ({ operation, name, source, roleId, type, dimensionName }) => {\n switch (operation) {\n case \"born\": {\n if (!name || !source) throw new Error(\"born requires: name, source\");\n const feature = rolex.born(name, source);\n return next(`Role born: ${feature.name}`, NEXT.born);\n }\n case \"found\": {\n if (!name) throw new Error(\"found requires: name\");\n rolex.found(name);\n return next(`Organization founded: ${name}`, NEXT.found);\n }\n case \"directory\": {\n const dir = rolex.directory();\n const lines: string[] = [];\n\n // Organizations and their hired roles\n for (const entry of dir.organizations) {\n const orgInstance = rolex.find(entry.name) as Organization;\n const info = orgInstance.info();\n lines.push(`Organization: ${info.name}`);\n for (const role of info.roles) {\n lines.push(` - ${role.name} (team: ${role.team})`);\n }\n }\n\n // Unaffiliated roles (born but not hired)\n const unaffiliated = dir.roles.filter((r) => !r.team);\n if (unaffiliated.length > 0) {\n lines.push(\"\");\n lines.push(\"Unaffiliated:\");\n for (const role of unaffiliated) {\n lines.push(` - ${role.name}`);\n }\n }\n\n return lines.join(\"\\n\") || \"No roles or organizations found.\";\n }\n case \"find\": {\n if (!name) throw new Error(\"find requires: name\");\n const result = rolex.find(name);\n if (result instanceof Organization) {\n const info = result.info();\n return `Organization: ${info.name} (${info.roles.length} roles)`;\n }\n const features = (result as Role).identity();\n return renderFeatures(features);\n }\n case \"teach\": {\n if (!roleId || !type || !dimensionName || !source)\n throw new Error(\"teach requires: roleId, type, dimensionName, source\");\n const feature = rolex.teach(roleId, type, dimensionName, source);\n return next(`Taught ${type}: ${feature.name}`, NEXT.teach);\n }\n default:\n throw new Error(`Unknown society operation: ${operation}`);\n }\n }),\n});\n\n// ========== Organization (folded) ==========\n\nserver.addTool({\n name: \"organization\",\n description: DESC_ORGANIZATION,\n parameters: z.object({\n operation: z.enum([\"hire\", \"fire\"]).describe(\"The organization operation to perform\"),\n name: z.string().describe(\"Role name to hire or fire\"),\n }),\n execute: safeTool(\"organization\", async ({ operation, name }) => {\n const dir = rolex.directory();\n const org = rolex.find(dir.organizations[0].name) as Organization;\n\n switch (operation) {\n case \"hire\": {\n org.hire(name);\n return next(`Role hired: ${name}`, nextHire(name));\n }\n case \"fire\": {\n org.fire(name);\n return next(`Role fired: ${name}`, NEXT.fire);\n }\n default:\n throw new Error(`Unknown organization operation: ${operation}`);\n }\n }),\n});\n\n// ========== Role Activation ==========\n\nserver.addTool({\n name: \"identity\",\n description: DESC_IDENTITY,\n parameters: z.object({\n roleId: z.string().describe(\"Role name (e.g. 'sean')\"),\n }),\n execute: safeTool(\"identity\", async ({ roleId }) => {\n currentRole = rolex.role(roleId);\n currentRoleName = roleId;\n const features = currentRole.identity();\n const { current } = currentRole.focus();\n const statusBar = renderStatusBar(roleId, current);\n return `${statusBar}\\n\\n${renderFeatures(features)}`;\n }),\n});\n\n// ========== Role Tools ==========\n\nserver.addTool({\n name: \"growup\",\n description: DESC_GROWUP,\n parameters: z.object({\n type: z\n .enum([\"knowledge\", \"experience\", \"voice\"])\n .describe(\n \"Growth dimension: knowledge (what I know), experience (what I've lived), voice (how I'm perceived)\"\n ),\n name: z\n .string()\n .describe(\"Name for this growth (used as filename, e.g. 'distributed-systems')\"),\n source: z.string().describe(\"Gherkin feature source text\"),\n }),\n execute: safeTool(\"growup\", async ({ type, name, source }) => {\n const role = requireRole();\n const feature = role.growup(type, name, source);\n return next(`Growth added (${type}): ${feature.name}`, NEXT.growup);\n }),\n});\n\nserver.addTool({\n name: \"focus\",\n description: DESC_FOCUS,\n parameters: z.object({\n name: z.string().optional().describe(\"Optional goal name to switch focus to\"),\n }),\n execute: safeTool(\"focus\", async ({ name }) => {\n const role = requireRole();\n const { current, otherGoals } = role.focus(name);\n\n const statusBar = renderStatusBar(currentRoleName, current);\n\n if (!current && otherGoals.length === 0)\n return `${statusBar}\\n\\nNo active goal. Use want() to set a new goal.`;\n\n const parts: string[] = [statusBar];\n\n if (current) {\n parts.push(renderFeature(current));\n if (current.plan) {\n parts.push(renderFeature(current.plan));\n }\n for (const task of current.tasks) {\n parts.push(renderFeature(task));\n }\n }\n\n if (otherGoals.length > 0) {\n parts.push(\"Other active goals:\");\n for (const g of otherGoals) {\n parts.push(` - ${g.name}`);\n }\n }\n\n return parts.join(\"\\n\\n\");\n }),\n});\n\nserver.addTool({\n name: \"want\",\n description: DESC_WANT,\n parameters: z.object({\n name: z.string().describe(\"Goal name (used as directory name, e.g. 'local-platform')\"),\n source: z.string().describe(\"Gherkin feature source text for the goal\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this goal's scenarios should become persistent automated verification\"),\n }),\n execute: safeTool(\"want\", async ({ name, source, testable }) => {\n const role = requireRole();\n const goal = role.want(name, source, testable);\n return next(`Goal created: ${goal.name}`, NEXT.want);\n }),\n});\n\nserver.addTool({\n name: \"plan\",\n description: DESC_PLAN,\n parameters: z.object({\n source: z.string().describe(\"Gherkin feature source text for the plan\"),\n }),\n execute: safeTool(\"plan\", async ({ source }) => {\n const role = requireRole();\n const p = role.plan(source);\n return next(`Plan created: ${p.name}`, NEXT.plan);\n }),\n});\n\nserver.addTool({\n name: \"todo\",\n description: DESC_TODO,\n parameters: z.object({\n name: z.string().describe(\"Task name (used as filename, e.g. 'implement-loader')\"),\n source: z.string().describe(\"Gherkin feature source text for the task\"),\n testable: z\n .boolean()\n .optional()\n .default(false)\n .describe(\"Whether this task's scenarios should become unit or integration tests\"),\n }),\n execute: safeTool(\"todo\", async ({ name, source, testable }) => {\n const role = requireRole();\n const task = role.todo(name, source, testable);\n return next(`Task created: ${task.name}`, NEXT.todo);\n }),\n});\n\nserver.addTool({\n name: \"achieve\",\n description: DESC_ACHIEVE,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: safeTool(\"achieve\", async ({ experience }) => {\n const role = requireRole();\n role.achieve(experience);\n const msg = experience ? \"Goal achieved. Experience captured.\" : \"Goal achieved.\";\n return next(msg, NEXT.achieve);\n }),\n});\n\nserver.addTool({\n name: \"abandon\",\n description: DESC_ABANDON,\n parameters: z.object({\n experience: z\n .string()\n .optional()\n .describe(\n \"Optional Gherkin feature source capturing what was learned — auto-saved as experience growup\"\n ),\n }),\n execute: safeTool(\"abandon\", async ({ experience }) => {\n const role = requireRole();\n role.abandon(experience);\n const msg = experience ? \"Goal abandoned. Experience captured.\" : \"Goal abandoned.\";\n return next(msg, NEXT.abandon);\n }),\n});\n\nserver.addTool({\n name: \"reflect\",\n description: DESC_REFLECT,\n parameters: z.object({\n experienceNames: z\n .array(z.string())\n .describe(\n \"Names of experience files to distill (without .experience.identity.feature suffix)\"\n ),\n knowledgeName: z\n .string()\n .describe(\n \"Name for the resulting knowledge (used as filename, e.g. 'authentication-principles')\"\n ),\n knowledgeSource: z.string().describe(\"Gherkin feature source text for the knowledge\"),\n }),\n execute: safeTool(\"reflect\", async ({ experienceNames, knowledgeName, knowledgeSource }) => {\n const role = requireRole();\n const feature = role.reflect(experienceNames, knowledgeName, knowledgeSource);\n return next(\n `Reflected: ${experienceNames.length} experience(s) → knowledge \"${feature.name}\"`,\n NEXT.reflect\n );\n }),\n});\n\nserver.addTool({\n name: \"finish\",\n description: DESC_FINISH,\n parameters: z.object({\n name: z.string().describe(\"Task name to mark as done\"),\n }),\n execute: safeTool(\"finish\", async ({ name }) => {\n const role = requireRole();\n role.finish(name);\n\n // Dynamic hint: check remaining tasks\n const { current } = role.focus();\n const remaining = current\n ? current.tasks.filter((t) => !t.tags?.some((tag) => tag.name === \"@done\")).length\n : -1;\n return next(`Task finished: ${name}`, remaining >= 0 ? nextFinish(remaining) : NEXT.achieve);\n }),\n});\n\nserver.start({\n transportType: \"stdio\",\n});\n"],"mappings":";;;AAeA,SAAS,eAAe;AACxB,SAAS,SAAS;AAClB;AAAA,EACE;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,qBAAqB;AAE9B,SAAS,YAAY;AACrB,SAAS,eAAe;AAExB,IAAM,oBAAoB,KAAK,QAAQ,GAAG,QAAQ;AAClD,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AAC;AACH,CAAC;AAED,OAAO,MAAM;AAAA,EACX,eAAe;AACjB,CAAC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rolexjs/mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "MCP server for Rolex — expose RDD role management as MCP tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rolex",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"clean": "rm -rf dist"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"rolexjs": "^0.
|
|
45
|
-
"@rolexjs/local-platform": "^0.
|
|
44
|
+
"rolexjs": "^0.7.0",
|
|
45
|
+
"@rolexjs/local-platform": "^0.7.0",
|
|
46
46
|
"fastmcp": "^3.0.0",
|
|
47
47
|
"zod": "^3.25.0"
|
|
48
48
|
},
|