@aigentyc/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.
Files changed (107) hide show
  1. package/AGENTS.md +197 -0
  2. package/LICENSE +21 -0
  3. package/README.md +112 -0
  4. package/context7.json +3 -0
  5. package/dist/cli.d.ts +3 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +289 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/client.d.ts +10 -0
  10. package/dist/client.d.ts.map +1 -0
  11. package/dist/client.js +70 -0
  12. package/dist/client.js.map +1 -0
  13. package/dist/config.d.ts +31 -0
  14. package/dist/config.d.ts.map +1 -0
  15. package/dist/config.js +79 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/errors.d.ts +10 -0
  18. package/dist/errors.d.ts.map +1 -0
  19. package/dist/errors.js +28 -0
  20. package/dist/errors.js.map +1 -0
  21. package/dist/fs-safety.d.ts +29 -0
  22. package/dist/fs-safety.d.ts.map +1 -0
  23. package/dist/fs-safety.js +107 -0
  24. package/dist/fs-safety.js.map +1 -0
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +4 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/llms-full.txt +659 -0
  30. package/dist/server.d.ts +2 -0
  31. package/dist/server.d.ts.map +1 -0
  32. package/dist/server.js +57 -0
  33. package/dist/server.js.map +1 -0
  34. package/dist/tools/analytics.d.ts +4 -0
  35. package/dist/tools/analytics.d.ts.map +1 -0
  36. package/dist/tools/analytics.js +82 -0
  37. package/dist/tools/analytics.js.map +1 -0
  38. package/dist/tools/backups.d.ts +4 -0
  39. package/dist/tools/backups.d.ts.map +1 -0
  40. package/dist/tools/backups.js +99 -0
  41. package/dist/tools/backups.js.map +1 -0
  42. package/dist/tools/config.d.ts +4 -0
  43. package/dist/tools/config.d.ts.map +1 -0
  44. package/dist/tools/config.js +84 -0
  45. package/dist/tools/config.js.map +1 -0
  46. package/dist/tools/corrections.d.ts +4 -0
  47. package/dist/tools/corrections.d.ts.map +1 -0
  48. package/dist/tools/corrections.js +69 -0
  49. package/dist/tools/corrections.js.map +1 -0
  50. package/dist/tools/data_stores.d.ts +4 -0
  51. package/dist/tools/data_stores.d.ts.map +1 -0
  52. package/dist/tools/data_stores.js +244 -0
  53. package/dist/tools/data_stores.js.map +1 -0
  54. package/dist/tools/documents.d.ts +4 -0
  55. package/dist/tools/documents.d.ts.map +1 -0
  56. package/dist/tools/documents.js +162 -0
  57. package/dist/tools/documents.js.map +1 -0
  58. package/dist/tools/extract.d.ts +4 -0
  59. package/dist/tools/extract.d.ts.map +1 -0
  60. package/dist/tools/extract.js +61 -0
  61. package/dist/tools/extract.js.map +1 -0
  62. package/dist/tools/files.d.ts +4 -0
  63. package/dist/tools/files.d.ts.map +1 -0
  64. package/dist/tools/files.js +198 -0
  65. package/dist/tools/files.js.map +1 -0
  66. package/dist/tools/golden_answers.d.ts +4 -0
  67. package/dist/tools/golden_answers.d.ts.map +1 -0
  68. package/dist/tools/golden_answers.js +117 -0
  69. package/dist/tools/golden_answers.js.map +1 -0
  70. package/dist/tools/helpers.d.ts +5 -0
  71. package/dist/tools/helpers.d.ts.map +1 -0
  72. package/dist/tools/helpers.js +10 -0
  73. package/dist/tools/helpers.js.map +1 -0
  74. package/dist/tools/index.d.ts +4 -0
  75. package/dist/tools/index.d.ts.map +1 -0
  76. package/dist/tools/index.js +35 -0
  77. package/dist/tools/index.js.map +1 -0
  78. package/dist/tools/jobs.d.ts +4 -0
  79. package/dist/tools/jobs.d.ts.map +1 -0
  80. package/dist/tools/jobs.js +78 -0
  81. package/dist/tools/jobs.js.map +1 -0
  82. package/dist/tools/link_sources.d.ts +4 -0
  83. package/dist/tools/link_sources.d.ts.map +1 -0
  84. package/dist/tools/link_sources.js +155 -0
  85. package/dist/tools/link_sources.js.map +1 -0
  86. package/dist/tools/misc.d.ts +8 -0
  87. package/dist/tools/misc.d.ts.map +1 -0
  88. package/dist/tools/misc.js +73 -0
  89. package/dist/tools/misc.js.map +1 -0
  90. package/dist/tools/page_questions.d.ts +4 -0
  91. package/dist/tools/page_questions.d.ts.map +1 -0
  92. package/dist/tools/page_questions.js +77 -0
  93. package/dist/tools/page_questions.js.map +1 -0
  94. package/dist/tools/personas.d.ts +4 -0
  95. package/dist/tools/personas.d.ts.map +1 -0
  96. package/dist/tools/personas.js +78 -0
  97. package/dist/tools/personas.js.map +1 -0
  98. package/dist/tools/tools_crud.d.ts +4 -0
  99. package/dist/tools/tools_crud.d.ts.map +1 -0
  100. package/dist/tools/tools_crud.js +207 -0
  101. package/dist/tools/tools_crud.js.map +1 -0
  102. package/dist/tools/types.d.ts +25 -0
  103. package/dist/tools/types.d.ts.map +1 -0
  104. package/dist/tools/types.js +15 -0
  105. package/dist/tools/types.js.map +1 -0
  106. package/llms.txt +150 -0
  107. package/package.json +53 -0
@@ -0,0 +1,207 @@
1
+ import { z } from "zod";
2
+ import { pid, projectIdArg } from "./helpers.js";
3
+ import { defineTool } from "./types.js";
4
+ const toolType = z.enum([
5
+ "rest_api",
6
+ "custom_execute",
7
+ "hybrid",
8
+ "data_store",
9
+ "web_search",
10
+ ]);
11
+ // Server accepts the JSON fields opaquely; we mirror that here.
12
+ const createToolSchema = z.object({
13
+ projectId: projectIdArg,
14
+ name: z.string().min(1).max(100),
15
+ displayName: z.string().min(1).max(255),
16
+ description: z.string().min(1),
17
+ toolType: toolType.default("rest_api"),
18
+ inputSchema: z.array(z.record(z.unknown())).default([]),
19
+ apiConfig: z.record(z.unknown()).optional().nullable(),
20
+ transformCode: z
21
+ .string()
22
+ .optional()
23
+ .describe("JavaScript code for toolType=custom_execute (runs as the whole tool body) or hybrid (runs on input.apiResult after the REST call). Sandboxed; no Node APIs. Rejected server-side if it contains `process.env`."),
24
+ dataStoreConfig: z.record(z.unknown()).optional().nullable(),
25
+ webSearchConfig: z.record(z.unknown()).optional().nullable(),
26
+ stopWhen: z.number().int().min(0).default(0),
27
+ searchKbAfter: z.boolean().default(false),
28
+ timeoutMs: z.number().int().min(100).max(60000).default(5000),
29
+ uiComponent: z.string().default("JsonDisplay"),
30
+ customHtml: z.string().optional(),
31
+ customCss: z.string().optional(),
32
+ audience: z.array(z.string()).optional(),
33
+ sampleInput: z.record(z.unknown()).optional(),
34
+ sampleOutput: z.record(z.unknown()).optional(),
35
+ category: z.string().default("general"),
36
+ tags: z.array(z.string()).optional(),
37
+ componentActions: z.array(z.record(z.unknown())).optional(),
38
+ jsonRenderSpec: z.record(z.unknown()).optional(),
39
+ uiRenderMode: z.enum(["legacy", "json"]).default("legacy"),
40
+ mobileGridCols: z.number().int().min(1).max(12).optional(),
41
+ desktopGridCols: z.number().int().min(1).max(12).optional(),
42
+ initialRenderLimit: z.number().int().min(0).max(200).optional(),
43
+ });
44
+ const updateToolSchema = z.object({
45
+ projectId: projectIdArg,
46
+ toolId: z.string().min(1),
47
+ patch: createToolSchema
48
+ .omit({ projectId: true })
49
+ .partial()
50
+ .describe("Any subset of tool fields to update. Sending executeCode or transformCode containing 'process.env' is rejected server-side."),
51
+ });
52
+ export function toolsCrudTools(client) {
53
+ return [
54
+ defineTool({
55
+ name: "tools_list",
56
+ title: "List custom tools",
57
+ description: "List every custom tool in the project (rest_api, custom_execute, hybrid, data_store, web_search).",
58
+ inputSchema: z.object({ projectId: projectIdArg }),
59
+ handler: async (args) => {
60
+ const projectId = pid(client, args.projectId);
61
+ return client.get(`/api/dashboard/${projectId}/tools`);
62
+ },
63
+ }),
64
+ defineTool({
65
+ name: "tools_get",
66
+ title: "Get a custom tool",
67
+ description: "Fetch one custom tool with its full config.",
68
+ inputSchema: z.object({
69
+ projectId: projectIdArg,
70
+ toolId: z.string().min(1),
71
+ }),
72
+ handler: async (args) => {
73
+ const projectId = pid(client, args.projectId);
74
+ return client.get(`/api/dashboard/${projectId}/tools/${encodeURIComponent(args.toolId)}`);
75
+ },
76
+ }),
77
+ defineTool({
78
+ name: "tools_create",
79
+ title: "Create a custom tool",
80
+ description: "Create a custom tool the chat agent can call. Tool code referencing `process.env` is rejected — put secrets in apiConfig.headers with template placeholders.",
81
+ inputSchema: createToolSchema,
82
+ handler: async (args) => {
83
+ const { projectId: rawPid, ...body } = args;
84
+ const projectId = pid(client, rawPid);
85
+ return client.post(`/api/dashboard/${projectId}/tools`, body);
86
+ },
87
+ }),
88
+ defineTool({
89
+ name: "tools_update",
90
+ title: "Update a custom tool",
91
+ description: "Patch selected fields of an existing custom tool.",
92
+ inputSchema: updateToolSchema,
93
+ handler: async (args) => {
94
+ const projectId = pid(client, args.projectId);
95
+ return client.patch(`/api/dashboard/${projectId}/tools/${encodeURIComponent(args.toolId)}`, args.patch);
96
+ },
97
+ }),
98
+ defineTool({
99
+ name: "tools_delete",
100
+ title: "Delete a custom tool",
101
+ description: "Delete a custom tool. Destructive.",
102
+ inputSchema: z.object({
103
+ projectId: projectIdArg,
104
+ toolId: z.string().min(1),
105
+ confirm: z.boolean().default(false),
106
+ }),
107
+ handler: async (args) => {
108
+ if (!args.confirm) {
109
+ return {
110
+ deleted: false,
111
+ reason: "Destructive. Re-invoke with confirm=true.",
112
+ };
113
+ }
114
+ const projectId = pid(client, args.projectId);
115
+ return client.delete(`/api/dashboard/${projectId}/tools/${encodeURIComponent(args.toolId)}`);
116
+ },
117
+ }),
118
+ defineTool({
119
+ name: "tools_execute_dry_run",
120
+ title: "Dry-run a custom tool",
121
+ description: "Invoke a custom tool in test mode with sample input. Safe for iteration; does not count against usage.",
122
+ inputSchema: z.object({
123
+ projectId: projectIdArg,
124
+ toolId: z.string().min(1),
125
+ input: z.record(z.unknown()).default({}),
126
+ dryRun: z.boolean().default(true),
127
+ }),
128
+ handler: async (args) => {
129
+ const projectId = pid(client, args.projectId);
130
+ return client.post(`/api/dashboard/${projectId}/tools/${encodeURIComponent(args.toolId)}/execute`, { input: args.input, dryRun: args.dryRun });
131
+ },
132
+ }),
133
+ defineTool({
134
+ name: "flows_list",
135
+ title: "List tool flows",
136
+ description: "List multi-step tool flows (orchestrations) in the project.",
137
+ inputSchema: z.object({ projectId: projectIdArg }),
138
+ handler: async (args) => {
139
+ const projectId = pid(client, args.projectId);
140
+ return client.get(`/api/dashboard/${projectId}/flows`);
141
+ },
142
+ }),
143
+ defineTool({
144
+ name: "flows_get",
145
+ title: "Get a flow",
146
+ description: "Fetch a single tool flow.",
147
+ inputSchema: z.object({
148
+ projectId: projectIdArg,
149
+ flowId: z.string().min(1),
150
+ }),
151
+ handler: async (args) => {
152
+ const projectId = pid(client, args.projectId);
153
+ return client.get(`/api/dashboard/${projectId}/flows/${encodeURIComponent(args.flowId)}`);
154
+ },
155
+ }),
156
+ defineTool({
157
+ name: "flows_create",
158
+ title: "Create a flow",
159
+ description: "Create a multi-step tool flow.",
160
+ inputSchema: z.object({
161
+ projectId: projectIdArg,
162
+ spec: z
163
+ .record(z.unknown())
164
+ .describe("Flow spec matching the server's CreateToolFlowInput. Passed through opaquely."),
165
+ }),
166
+ handler: async (args) => {
167
+ const projectId = pid(client, args.projectId);
168
+ return client.post(`/api/dashboard/${projectId}/flows`, args.spec);
169
+ },
170
+ }),
171
+ defineTool({
172
+ name: "flows_update",
173
+ title: "Update a flow",
174
+ description: "Patch a flow's fields.",
175
+ inputSchema: z.object({
176
+ projectId: projectIdArg,
177
+ flowId: z.string().min(1),
178
+ patch: z.record(z.unknown()),
179
+ }),
180
+ handler: async (args) => {
181
+ const projectId = pid(client, args.projectId);
182
+ return client.patch(`/api/dashboard/${projectId}/flows/${encodeURIComponent(args.flowId)}`, args.patch);
183
+ },
184
+ }),
185
+ defineTool({
186
+ name: "flows_delete",
187
+ title: "Delete a flow",
188
+ description: "Delete a flow. Destructive.",
189
+ inputSchema: z.object({
190
+ projectId: projectIdArg,
191
+ flowId: z.string().min(1),
192
+ confirm: z.boolean().default(false),
193
+ }),
194
+ handler: async (args) => {
195
+ if (!args.confirm) {
196
+ return {
197
+ deleted: false,
198
+ reason: "Destructive. Re-invoke with confirm=true.",
199
+ };
200
+ }
201
+ const projectId = pid(client, args.projectId);
202
+ return client.delete(`/api/dashboard/${projectId}/flows/${encodeURIComponent(args.flowId)}`);
203
+ },
204
+ }),
205
+ ];
206
+ }
207
+ //# sourceMappingURL=tools_crud.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools_crud.js","sourceRoot":"","sources":["../../src/tools/tools_crud.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC;IACtB,UAAU;IACV,gBAAgB;IAChB,QAAQ;IACR,YAAY;IACZ,YAAY;CACb,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAChC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9B,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;IACtC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;IACvD,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;IACtD,aAAa,EAAE,CAAC;SACb,MA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AE,IAAI,EAAE,EAAE;gBACtB,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC9C,OAAO,MAAM,CAAC,KAAK,CACjB,kBAAkB,SAAS,UAAU,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,EACtE,IAAI,CAAC,KAAK,CACX,CAAC;YACJ,CAAC;SACF,CAAC;QACF,UAAU,CAAC;YACT,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,eAAe;YACtB,WAAW,EAAE,6BAA6B;YAC1C,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;gBACpB,SAAS,EAAE,YAAY;gBACvB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBACzB,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;aACpC,CAAC;YACF,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;gBACtB,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;oBAClB,OAAO;wBACL,OAAO,EAAE,KAAK;wBACd,MAAM,EAAE,2CAA2C;qBACpD,CAAC;gBACJ,CAAC;gBACD,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC9C,OAAO,MAAM,CAAC,MAAM,CAClB,kBAAkB,SAAS,UAAU,kBAAkB,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CACvE,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { z } from "zod";
2
+ export interface ToolDef {
3
+ name: string;
4
+ title: string;
5
+ description: string;
6
+ /**
7
+ * ZodObject whose `.shape` is passed to `server.registerTool`. The SDK then
8
+ * wraps the shape + validates incoming args, so `handler` can trust them.
9
+ */
10
+ inputSchema: z.ZodObject<z.ZodRawShape>;
11
+ handler: (args: Record<string, unknown>) => Promise<unknown>;
12
+ }
13
+ /**
14
+ * Helper to define a tool with proper inference on the handler's `args`
15
+ * parameter while erasing the input type at the ToolDef boundary. The SDK
16
+ * validates inputs before calling us, so the cast is safe at runtime.
17
+ */
18
+ export declare function defineTool<S extends z.ZodObject<z.ZodRawShape>>(def: {
19
+ name: string;
20
+ title: string;
21
+ description: string;
22
+ inputSchema: S;
23
+ handler: (args: z.infer<S>) => Promise<unknown>;
24
+ }): ToolDef;
25
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,WAAW,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IACxC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,GAAG,EAAE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,CAAC,CAAC;IACf,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD,GAAG,OAAO,CAQV"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Helper to define a tool with proper inference on the handler's `args`
3
+ * parameter while erasing the input type at the ToolDef boundary. The SDK
4
+ * validates inputs before calling us, so the cast is safe at runtime.
5
+ */
6
+ export function defineTool(def) {
7
+ return {
8
+ name: def.name,
9
+ title: def.title,
10
+ description: def.description,
11
+ inputSchema: def.inputSchema,
12
+ handler: (args) => def.handler(args),
13
+ };
14
+ }
15
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAcA;;;;GAIG;AACH,MAAM,UAAU,UAAU,CAAuC,GAMhE;IACC,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,IAAkB,CAAC;KACnD,CAAC;AACJ,CAAC"}
package/llms.txt ADDED
@@ -0,0 +1,150 @@
1
+ # @aigentyc/mcp
2
+
3
+ > Model Context Protocol server for the Aigentyc platform. Lets Claude Code, Cursor, Windsurf, Claude Desktop, and any MCP-compatible agent drive the **content & authoring** side of an Aigentyc project — documents, files, crawling, custom tools, data stores, config, backups, analytics — without clicking through the dashboard. Chat/widget embedding is handled by a separate package, `@aigentyc/chat-sdk`.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npx @aigentyc/mcp login \
9
+ --api-key tyco_pk_XXXX \
10
+ --project-id proj_XXXX
11
+ ```
12
+
13
+ `login` verifies the key against `/api/auth/api-keys/verify` and writes `~/.aigentyc/config.json` with `0600` perms. The server refuses to start if perms are wider.
14
+
15
+ **Dev-only flag**: pass `--allow-insecure` to permit plaintext HTTP against non-loopback hosts. Never use this against production.
16
+
17
+ ## Wire into your agent
18
+
19
+ ### Claude Desktop / Claude Code
20
+
21
+ `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS):
22
+
23
+ ```json
24
+ {
25
+ "mcpServers": {
26
+ "aigentyc": {
27
+ "command": "npx",
28
+ "args": ["-y", "@aigentyc/mcp"]
29
+ }
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### Cursor
35
+
36
+ Settings → MCP → add server:
37
+
38
+ ```json
39
+ {
40
+ "aigentyc": {
41
+ "command": "npx",
42
+ "args": ["-y", "@aigentyc/mcp"]
43
+ }
44
+ }
45
+ ```
46
+
47
+ Restart the client. The new tools appear under the `aigentyc` namespace.
48
+
49
+ ## Commands
50
+
51
+ ```
52
+ aigentyc-mcp serve Start the stdio MCP server (default)
53
+ aigentyc-mcp login Save + verify an API key profile
54
+ aigentyc-mcp logout Remove a profile
55
+ aigentyc-mcp doctor Verify config + transport + clock skew + reachability
56
+ ```
57
+
58
+ ## Tools (82 total, 19 domains)
59
+
60
+ - **documents** — list, get, delete, create_from_text, merge, versions
61
+ - **files** — list, get, upload (path-based), delete, reprocess, versions, bulk_audience
62
+ - **extract** — from_urls (jobified for api-key)
63
+ - **link_sources** — list, get, create, update, delete, list_items, update_item, delete_item
64
+ - **page_questions** — list, set_manual, auto_generate (jobified), delete_page
65
+ - **data_stores** — full CRUD + bulk_upsert + import + export + scan_website (jobified)
66
+ - **tools** (custom-tool CRUD) — list, get, create, update, delete, execute_dry_run
67
+ - **flows** — list, get, create, update, delete
68
+ - **golden_answers** — list, create, update, delete + ai_improve + ai_generate_variations
69
+ - **corrections** — list, create, update_status
70
+ - **personas** — list, upsert, delete
71
+ - **config** — get (secrets redacted for api-key), update (secret writes rejected)
72
+ - **backups** — list, create (jobified), restore (jobified), download, import, delete
73
+ - **analytics** — overview, sessions, session_timeline, comments
74
+ - **branches** — list
75
+ - **search** — kb_search (read-only authoring aid)
76
+ - **jobs** — status, list, wait
77
+
78
+ ## Async job pattern
79
+
80
+ Long-running ops (backup create/restore, extract, data-store scan, page-questions auto-generate) return `{ jobId, status: "queued" }`. Poll with `jobs_wait`:
81
+
82
+ ```
83
+ extract_from_urls({ urls: [...] })
84
+ → { jobId: "abc-123", status: "queued" }
85
+ jobs_wait({ jobId: "abc-123" })
86
+ → blocks until terminal; returns { status: "completed", result: {...} }
87
+ ```
88
+
89
+ Concurrency cap: 3 active jobs per project.
90
+
91
+ ## Security
92
+
93
+ - **Project-scoped keys**: a key for project A cannot read/write project B (403).
94
+ - **Per-key rate limits**: 300 reads/min, 60 writes/min. 429 with `Retry-After` over the limit.
95
+ - **Secrets**: `config.get` redacts `openaiApiKey` + `customHttpHeaders` to `***` for api-key callers. `config.update` rejects writes to those fields with 403. Backup downloads (single + ZIP) deep-redact secrets.
96
+ - **Custom tool code**: `tools.create` rejects `transformCode` / `executeCode` containing `process.env`. Use `apiConfig.headers` with template placeholders for secrets.
97
+ - **Destructive ops** (`*.delete`, `backups.restore`): require `confirm: true`.
98
+ - **Path uploads**: `files.upload` refuses paths outside `$CWD` / `$HOME`, refuses non-regular files, caps 50MB/file, 500MB/batch.
99
+ - **URL inputs**: `extract.from_urls` + `link_sources.create` reject RFC1918 / loopback / cloud-metadata hosts.
100
+ - **Audit log**: every api-key request is logged server-side (`api_key_audit_log` table) with `keyId`, `projectId`, `route`, `method`, `status`, `latencyMs`, `requestId`. Reads sampled at 10%; writes 100%.
101
+
102
+ ## Recipes
103
+
104
+ ### Add a markdown KB from local files
105
+
106
+ ```
107
+ files_upload({ paths: ["docs/intro.md", "docs/api.md"], indexAsDocuments: true })
108
+ ```
109
+
110
+ The MCP reads each file (text formats only — `.md`, `.txt`, `.json`, `.csv`, `.html`, …), uploads metadata to `uploaded_files`, then chunks + embeds + indexes via `documents/create`.
111
+
112
+ ### Crawl a website + dedupe before adding more docs
113
+
114
+ ```
115
+ 1. link_sources_create({ sourceUrl: "https://example.com", sourceType: "website" })
116
+ 2. jobs_wait({ jobId: ... }) — wait for crawl to finish
117
+ 3. search_kb_search({ query: "billing FAQ" }) // confirm it indexed
118
+ ```
119
+
120
+ ### Build a custom tool end-to-end
121
+
122
+ ```
123
+ 1. tools_create({
124
+ name: "submitForm",
125
+ toolType: "rest_api",
126
+ apiConfig: { method: "POST", url: "...", body: "name={{name}}" },
127
+ inputSchema: [{ name: "name", type: "string", required: true }],
128
+ })
129
+ 2. tools_execute_dry_run({ toolId, input: { name: "Test" } })
130
+ // verify output before exposing to chat
131
+ ```
132
+
133
+ ### Update system prompt
134
+
135
+ ```
136
+ config_update({ patch: { systemPrompt: "You are the support agent for ACME..." } })
137
+ ```
138
+
139
+ (Cannot update `openaiApiKey` over api-key — use the dashboard for secrets.)
140
+
141
+ ## Troubleshooting
142
+
143
+ - **404 on login** — auth-service may be on a different origin in dev. `login` falls back to dashboard ping. Use `--base-url http://localhost:3000` for local Docker.
144
+ - **Tool calls hang** — confirm `aigentyc-mcp doctor` passes. Most failures are wrong base-url, expired key, or clock skew (>60s breaks auth).
145
+ - **Tool created but UI doesn't show it** — fully restart Claude Desktop / Cursor. Server-side caches invalidate on every write; client-side router caches don't.
146
+ - **Empty fields on tool call** — required string fields with `min(1)` get rejected by Zod, prompting the LLM to gather real values from the user. If a tool fires with empty inputs, the field wasn't marked required at creation.
147
+
148
+ ## Versioning
149
+
150
+ Server (`@aigentyc/mcp` on npm) and platform (`app.aigentyc.com`) version independently. The platform maintains backward compatibility with older MCP releases — endpoints aren't broken without deprecation.
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@aigentyc/mcp",
3
+ "version": "0.1.0",
4
+ "description": "Model Context Protocol server for aiGentyc — content & authoring tools for LLM agents",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "aigentyc-mcp": "./dist/cli.js"
9
+ },
10
+ "main": "./dist/index.js",
11
+ "types": "./dist/index.d.ts",
12
+ "keywords": [
13
+ "mcp",
14
+ "model-context-protocol",
15
+ "aigentyc",
16
+ "rag",
17
+ "llm",
18
+ "ai-tools",
19
+ "claude",
20
+ "cursor"
21
+ ],
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "AGENTS.md",
26
+ "llms.txt",
27
+ "context7.json",
28
+ "LICENSE"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc && node scripts/build-llms-full.mjs",
32
+ "build:llms-full": "node scripts/build-llms-full.mjs",
33
+ "dev": "tsx src/cli.ts",
34
+ "start": "node dist/cli.js",
35
+ "typecheck": "tsc --noEmit",
36
+ "smoke": "node scripts/smoke.mjs",
37
+ "release": "node scripts/release.mjs",
38
+ "release:dry": "node scripts/release.mjs --dry",
39
+ "prepublishOnly": "npm run build && npm run smoke"
40
+ },
41
+ "dependencies": {
42
+ "@modelcontextprotocol/sdk": "^1.0.4",
43
+ "zod": "^3.23.8"
44
+ },
45
+ "devDependencies": {
46
+ "@types/node": "^22.10.2",
47
+ "tsx": "^4.20.6",
48
+ "typescript": "^5.9.3"
49
+ },
50
+ "engines": {
51
+ "node": ">=20.0.0"
52
+ }
53
+ }