strapi-content-embeddings 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 (61) hide show
  1. package/README.md +276 -0
  2. package/dist/_chunks/App-7LMg3lrX.mjs +1004 -0
  3. package/dist/_chunks/App-wC2qv6kC.js +1008 -0
  4. package/dist/_chunks/en-B4KWt_jN.js +4 -0
  5. package/dist/_chunks/en-Byx4XI2L.mjs +4 -0
  6. package/dist/_chunks/index-Cz9cEuvw.mjs +411 -0
  7. package/dist/_chunks/index-o-tbBpJG.js +413 -0
  8. package/dist/admin/index.js +4 -0
  9. package/dist/admin/index.mjs +5 -0
  10. package/dist/admin/src/components/Initializer.d.ts +5 -0
  11. package/dist/admin/src/components/PluginIcon.d.ts +2 -0
  12. package/dist/admin/src/components/custom/BackLink.d.ts +5 -0
  13. package/dist/admin/src/components/custom/ChatModal.d.ts +1 -0
  14. package/dist/admin/src/components/custom/EmbeddingsModal.d.ts +1 -0
  15. package/dist/admin/src/components/custom/EmbeddingsTable.d.ts +12 -0
  16. package/dist/admin/src/components/custom/EmbeddingsWidget.d.ts +1 -0
  17. package/dist/admin/src/components/custom/EmptyState.d.ts +1 -0
  18. package/dist/admin/src/components/custom/Illo.d.ts +1 -0
  19. package/dist/admin/src/components/custom/Markdown.d.ts +5 -0
  20. package/dist/admin/src/components/custom/MarkdownEditor.d.ts +9 -0
  21. package/dist/admin/src/components/custom/RobotIcon.d.ts +6 -0
  22. package/dist/admin/src/components/forms/CreateEmbeddingForm.d.ts +15 -0
  23. package/dist/admin/src/index.d.ts +12 -0
  24. package/dist/admin/src/pages/App.d.ts +2 -0
  25. package/dist/admin/src/pages/CreateEmbeddings.d.ts +1 -0
  26. package/dist/admin/src/pages/EmbeddingDetails.d.ts +1 -0
  27. package/dist/admin/src/pages/HomePage.d.ts +1 -0
  28. package/dist/admin/src/pluginId.d.ts +1 -0
  29. package/dist/admin/src/utils/api.d.ts +33 -0
  30. package/dist/admin/src/utils/getTranslation.d.ts +2 -0
  31. package/dist/server/index.js +1359 -0
  32. package/dist/server/index.mjs +1360 -0
  33. package/dist/server/src/bootstrap.d.ts +5 -0
  34. package/dist/server/src/config/index.d.ts +26 -0
  35. package/dist/server/src/content-types/embedding/index.d.ts +54 -0
  36. package/dist/server/src/content-types/index.d.ts +56 -0
  37. package/dist/server/src/controllers/controller.d.ts +12 -0
  38. package/dist/server/src/controllers/index.d.ts +18 -0
  39. package/dist/server/src/controllers/mcp.d.ts +18 -0
  40. package/dist/server/src/destroy.d.ts +5 -0
  41. package/dist/server/src/index.d.ts +154 -0
  42. package/dist/server/src/mcp/index.d.ts +6 -0
  43. package/dist/server/src/mcp/schemas/index.d.ts +65 -0
  44. package/dist/server/src/mcp/server.d.ts +8 -0
  45. package/dist/server/src/mcp/tools/create-embedding.d.ts +38 -0
  46. package/dist/server/src/mcp/tools/get-embedding.d.ts +34 -0
  47. package/dist/server/src/mcp/tools/index.d.ts +114 -0
  48. package/dist/server/src/mcp/tools/list-embeddings.d.ts +40 -0
  49. package/dist/server/src/mcp/tools/rag-query.d.ts +34 -0
  50. package/dist/server/src/mcp/tools/semantic-search.d.ts +34 -0
  51. package/dist/server/src/middlewares/index.d.ts +2 -0
  52. package/dist/server/src/plugin-manager.d.ts +45 -0
  53. package/dist/server/src/policies/index.d.ts +2 -0
  54. package/dist/server/src/register.d.ts +5 -0
  55. package/dist/server/src/routes/admin.d.ts +14 -0
  56. package/dist/server/src/routes/content-api.d.ts +15 -0
  57. package/dist/server/src/routes/index.d.ts +36 -0
  58. package/dist/server/src/services/embeddings.d.ts +45 -0
  59. package/dist/server/src/services/index.d.ts +26 -0
  60. package/dist/style.css +95 -0
  61. package/package.json +104 -0
@@ -0,0 +1,5 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ declare const bootstrap: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => Promise<void>;
5
+ export default bootstrap;
@@ -0,0 +1,26 @@
1
+ export declare const EMBEDDING_MODELS: {
2
+ readonly "text-embedding-3-small": {
3
+ readonly dimensions: 1536;
4
+ };
5
+ readonly "text-embedding-3-large": {
6
+ readonly dimensions: 3072;
7
+ };
8
+ readonly "text-embedding-ada-002": {
9
+ readonly dimensions: 1536;
10
+ };
11
+ };
12
+ export type EmbeddingModelName = keyof typeof EMBEDDING_MODELS;
13
+ export interface PluginConfigSchema {
14
+ openAIApiKey?: string;
15
+ neonConnectionString?: string;
16
+ embeddingModel?: EmbeddingModelName;
17
+ }
18
+ declare const _default: {
19
+ default: {
20
+ openAIApiKey: string;
21
+ neonConnectionString: string;
22
+ embeddingModel: "text-embedding-3-small" | "text-embedding-3-large" | "text-embedding-ada-002";
23
+ };
24
+ validator(config: PluginConfigSchema): void;
25
+ };
26
+ export default _default;
@@ -0,0 +1,54 @@
1
+ declare const _default: {
2
+ schema: {
3
+ kind: string;
4
+ collectionName: string;
5
+ info: {
6
+ singularName: string;
7
+ pluralName: string;
8
+ displayName: string;
9
+ };
10
+ options: {
11
+ draftAndPublish: boolean;
12
+ };
13
+ pluginOptions: {
14
+ "content-manager": {
15
+ visible: boolean;
16
+ };
17
+ "content-type-builder": {
18
+ visible: boolean;
19
+ };
20
+ };
21
+ attributes: {
22
+ title: {
23
+ type: string;
24
+ required: boolean;
25
+ };
26
+ content: {
27
+ type: string;
28
+ };
29
+ embedding: {
30
+ type: string;
31
+ };
32
+ embeddingId: {
33
+ type: string;
34
+ };
35
+ collectionType: {
36
+ type: string;
37
+ default: string;
38
+ };
39
+ fieldName: {
40
+ type: string;
41
+ default: string;
42
+ };
43
+ metadata: {
44
+ type: string;
45
+ };
46
+ related: {
47
+ type: string;
48
+ relation: string;
49
+ configurable: boolean;
50
+ };
51
+ };
52
+ };
53
+ };
54
+ export default _default;
@@ -0,0 +1,56 @@
1
+ declare const _default: {
2
+ embedding: {
3
+ schema: {
4
+ kind: string;
5
+ collectionName: string;
6
+ info: {
7
+ singularName: string;
8
+ pluralName: string;
9
+ displayName: string;
10
+ };
11
+ options: {
12
+ draftAndPublish: boolean;
13
+ };
14
+ pluginOptions: {
15
+ "content-manager": {
16
+ visible: boolean;
17
+ };
18
+ "content-type-builder": {
19
+ visible: boolean;
20
+ };
21
+ };
22
+ attributes: {
23
+ title: {
24
+ type: string;
25
+ required: boolean;
26
+ };
27
+ content: {
28
+ type: string;
29
+ };
30
+ embedding: {
31
+ type: string;
32
+ };
33
+ embeddingId: {
34
+ type: string;
35
+ };
36
+ collectionType: {
37
+ type: string;
38
+ default: string;
39
+ };
40
+ fieldName: {
41
+ type: string;
42
+ default: string;
43
+ };
44
+ metadata: {
45
+ type: string;
46
+ };
47
+ related: {
48
+ type: string;
49
+ relation: string;
50
+ configurable: boolean;
51
+ };
52
+ };
53
+ };
54
+ };
55
+ };
56
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ declare const controller: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => {
5
+ createEmbedding(ctx: any): Promise<void>;
6
+ deleteEmbedding(ctx: any): Promise<void>;
7
+ updateEmbedding(ctx: any): Promise<void>;
8
+ getEmbeddings(ctx: any): Promise<void>;
9
+ getEmbedding(ctx: any): Promise<void>;
10
+ queryEmbeddings(ctx: any): Promise<void>;
11
+ };
12
+ export default controller;
@@ -0,0 +1,18 @@
1
+ declare const _default: {
2
+ controller: ({ strapi }: {
3
+ strapi: import("@strapi/types/dist/core").Strapi;
4
+ }) => {
5
+ createEmbedding(ctx: any): Promise<void>;
6
+ deleteEmbedding(ctx: any): Promise<void>;
7
+ updateEmbedding(ctx: any): Promise<void>;
8
+ getEmbeddings(ctx: any): Promise<void>;
9
+ getEmbedding(ctx: any): Promise<void>;
10
+ queryEmbeddings(ctx: any): Promise<void>;
11
+ };
12
+ mcp: ({ strapi }: {
13
+ strapi: import("@strapi/types/dist/core").Strapi;
14
+ }) => {
15
+ handle(ctx: any): Promise<void>;
16
+ };
17
+ };
18
+ export default _default;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * MCP Controller for Content Embeddings
3
+ *
4
+ * Handles MCP (Model Context Protocol) requests with session management.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ /**
8
+ * MCP Controller
9
+ */
10
+ declare const mcpController: ({ strapi }: {
11
+ strapi: Core.Strapi;
12
+ }) => {
13
+ /**
14
+ * Handle MCP requests (POST, GET, DELETE)
15
+ */
16
+ handle(ctx: any): Promise<void>;
17
+ };
18
+ export default mcpController;
@@ -0,0 +1,5 @@
1
+ import type { Core } from "@strapi/strapi";
2
+ declare const destroy: ({ strapi }: {
3
+ strapi: Core.Strapi;
4
+ }) => Promise<void>;
5
+ export default destroy;
@@ -0,0 +1,154 @@
1
+ declare const _default: {
2
+ register: ({ strapi }: {
3
+ strapi: import("@strapi/types/dist/core").Strapi;
4
+ }) => void;
5
+ bootstrap: ({ strapi }: {
6
+ strapi: import("@strapi/types/dist/core").Strapi;
7
+ }) => Promise<void>;
8
+ destroy: ({ strapi }: {
9
+ strapi: import("@strapi/types/dist/core").Strapi;
10
+ }) => Promise<void>;
11
+ config: {
12
+ default: {
13
+ openAIApiKey: string;
14
+ neonConnectionString: string;
15
+ embeddingModel: "text-embedding-3-small" | "text-embedding-3-large" | "text-embedding-ada-002";
16
+ };
17
+ validator(config: import("./config").PluginConfigSchema): void;
18
+ };
19
+ controllers: {
20
+ controller: ({ strapi }: {
21
+ strapi: import("@strapi/types/dist/core").Strapi;
22
+ }) => {
23
+ createEmbedding(ctx: any): Promise<void>;
24
+ deleteEmbedding(ctx: any): Promise<void>;
25
+ updateEmbedding(ctx: any): Promise<void>;
26
+ getEmbeddings(ctx: any): Promise<void>;
27
+ getEmbedding(ctx: any): Promise<void>;
28
+ queryEmbeddings(ctx: any): Promise<void>;
29
+ };
30
+ mcp: ({ strapi }: {
31
+ strapi: import("@strapi/types/dist/core").Strapi;
32
+ }) => {
33
+ handle(ctx: any): Promise<void>;
34
+ };
35
+ };
36
+ routes: {
37
+ "content-api": {
38
+ type: string;
39
+ routes: ({
40
+ method: string;
41
+ path: string;
42
+ handler: string;
43
+ config?: undefined;
44
+ } | {
45
+ method: string;
46
+ path: string;
47
+ handler: string;
48
+ config: {
49
+ auth: boolean;
50
+ policies: any[];
51
+ };
52
+ })[];
53
+ };
54
+ admin: {
55
+ type: string;
56
+ routes: {
57
+ method: string;
58
+ path: string;
59
+ handler: string;
60
+ config: {
61
+ policies: {
62
+ name: string;
63
+ config: {
64
+ actions: string[];
65
+ };
66
+ }[];
67
+ };
68
+ }[];
69
+ };
70
+ };
71
+ services: {
72
+ embeddings: ({ strapi }: {
73
+ strapi: import("@strapi/types/dist/core").Strapi;
74
+ }) => {
75
+ createEmbedding(data: import("./services/embeddings").CreateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
76
+ deleteEmbedding(id: string | number): Promise<{
77
+ documentId: string;
78
+ entries: import("@strapi/types/dist/modules/documents").AnyDocument[];
79
+ }>;
80
+ updateEmbedding(id: string, data: import("./services/embeddings").UpdateEmbeddingData): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
81
+ queryEmbeddings(query: string): Promise<import("./plugin-manager").QueryResponse | {
82
+ error: string;
83
+ }>;
84
+ getEmbedding(id: string | number): Promise<import("@strapi/types/dist/modules/documents").AnyDocument>;
85
+ getEmbeddings(params?: {
86
+ page?: number;
87
+ pageSize?: number;
88
+ filters?: any;
89
+ }): Promise<{
90
+ data: import("@strapi/types/dist/modules/documents").AnyDocument[];
91
+ count: number;
92
+ totalCount: number;
93
+ }>;
94
+ };
95
+ };
96
+ contentTypes: {
97
+ embedding: {
98
+ schema: {
99
+ kind: string;
100
+ collectionName: string;
101
+ info: {
102
+ singularName: string;
103
+ pluralName: string;
104
+ displayName: string;
105
+ };
106
+ options: {
107
+ draftAndPublish: boolean;
108
+ };
109
+ pluginOptions: {
110
+ "content-manager": {
111
+ visible: boolean;
112
+ };
113
+ "content-type-builder": {
114
+ visible: boolean;
115
+ };
116
+ };
117
+ attributes: {
118
+ title: {
119
+ type: string;
120
+ required: boolean;
121
+ };
122
+ content: {
123
+ type: string;
124
+ };
125
+ embedding: {
126
+ type: string;
127
+ };
128
+ embeddingId: {
129
+ type: string;
130
+ };
131
+ collectionType: {
132
+ type: string;
133
+ default: string;
134
+ };
135
+ fieldName: {
136
+ type: string;
137
+ default: string;
138
+ };
139
+ metadata: {
140
+ type: string;
141
+ };
142
+ related: {
143
+ type: string;
144
+ relation: string;
145
+ configurable: boolean;
146
+ };
147
+ };
148
+ };
149
+ };
150
+ };
151
+ policies: {};
152
+ middlewares: {};
153
+ };
154
+ export default _default;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * MCP Module Exports
3
+ */
4
+ export { createMcpServer } from './server';
5
+ export { tools, handleToolCall } from './tools';
6
+ export { validateToolInput, ToolSchemas } from './schemas';
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Zod Schemas for MCP Tool Input Validation
3
+ */
4
+ import { z } from 'zod';
5
+ export declare const SemanticSearchSchema: z.ZodObject<{
6
+ query: z.ZodString;
7
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ query?: string;
10
+ limit?: number;
11
+ }, {
12
+ query?: string;
13
+ limit?: number;
14
+ }>;
15
+ export declare const RagQuerySchema: z.ZodObject<{
16
+ query: z.ZodString;
17
+ includeSourceDocuments: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ query?: string;
20
+ includeSourceDocuments?: boolean;
21
+ }, {
22
+ query?: string;
23
+ includeSourceDocuments?: boolean;
24
+ }>;
25
+ export declare const ListEmbeddingsSchema: z.ZodObject<{
26
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
27
+ pageSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
28
+ search: z.ZodOptional<z.ZodString>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ page?: number;
31
+ pageSize?: number;
32
+ search?: string;
33
+ }, {
34
+ page?: number;
35
+ pageSize?: number;
36
+ search?: string;
37
+ }>;
38
+ export declare const GetEmbeddingSchema: z.ZodObject<{
39
+ documentId: z.ZodString;
40
+ includeContent: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
41
+ }, "strip", z.ZodTypeAny, {
42
+ documentId?: string;
43
+ includeContent?: boolean;
44
+ }, {
45
+ documentId?: string;
46
+ includeContent?: boolean;
47
+ }>;
48
+ export declare const CreateEmbeddingSchema: z.ZodObject<{
49
+ title: z.ZodString;
50
+ content: z.ZodString;
51
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ metadata?: Record<string, any>;
54
+ content?: string;
55
+ title?: string;
56
+ }, {
57
+ metadata?: Record<string, any>;
58
+ content?: string;
59
+ title?: string;
60
+ }>;
61
+ export declare const ToolSchemas: Record<string, z.ZodSchema>;
62
+ /**
63
+ * Validate tool input against its schema
64
+ */
65
+ export declare function validateToolInput<T = unknown>(toolName: string, input: unknown): T;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * MCP Server Factory for Content Embeddings
3
+ *
4
+ * Creates an MCP server that exposes vector search and RAG tools.
5
+ */
6
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
+ import type { Core } from '@strapi/strapi';
8
+ export declare function createMcpServer(strapi: Core.Strapi): Server;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Create Embedding Tool
3
+ *
4
+ * Creates a new embedding from text content.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const createEmbeddingTool: {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ title: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ content: {
18
+ type: string;
19
+ description: string;
20
+ };
21
+ metadata: {
22
+ type: string;
23
+ description: string;
24
+ };
25
+ };
26
+ required: string[];
27
+ };
28
+ };
29
+ export declare function handleCreateEmbedding(strapi: Core.Strapi, args: {
30
+ title: string;
31
+ content: string;
32
+ metadata?: Record<string, any>;
33
+ }): Promise<{
34
+ content: {
35
+ type: string;
36
+ text: string;
37
+ }[];
38
+ }>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Get Embedding Tool
3
+ *
4
+ * Retrieves a single embedding by ID.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const getEmbeddingTool: {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ documentId: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ includeContent: {
18
+ type: string;
19
+ description: string;
20
+ default: boolean;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ };
26
+ export declare function handleGetEmbedding(strapi: Core.Strapi, args: {
27
+ documentId: string;
28
+ includeContent?: boolean;
29
+ }): Promise<{
30
+ content: {
31
+ type: string;
32
+ text: string;
33
+ }[];
34
+ }>;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * MCP Tools for Content Embeddings
3
+ *
4
+ * Exposes vector search, RAG queries, and embedding management tools.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const tools: ({
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ query: {
14
+ type: string;
15
+ description: string;
16
+ };
17
+ limit: {
18
+ type: string;
19
+ description: string;
20
+ default: number;
21
+ };
22
+ };
23
+ required: string[];
24
+ };
25
+ } | {
26
+ name: string;
27
+ description: string;
28
+ inputSchema: {
29
+ type: string;
30
+ properties: {
31
+ query: {
32
+ type: string;
33
+ description: string;
34
+ };
35
+ includeSourceDocuments: {
36
+ type: string;
37
+ description: string;
38
+ default: boolean;
39
+ };
40
+ };
41
+ required: string[];
42
+ };
43
+ } | {
44
+ name: string;
45
+ description: string;
46
+ inputSchema: {
47
+ type: string;
48
+ properties: {
49
+ page: {
50
+ type: string;
51
+ description: string;
52
+ default: number;
53
+ };
54
+ pageSize: {
55
+ type: string;
56
+ description: string;
57
+ default: number;
58
+ };
59
+ search: {
60
+ type: string;
61
+ description: string;
62
+ };
63
+ };
64
+ required: any[];
65
+ };
66
+ } | {
67
+ name: string;
68
+ description: string;
69
+ inputSchema: {
70
+ type: string;
71
+ properties: {
72
+ documentId: {
73
+ type: string;
74
+ description: string;
75
+ };
76
+ includeContent: {
77
+ type: string;
78
+ description: string;
79
+ default: boolean;
80
+ };
81
+ };
82
+ required: string[];
83
+ };
84
+ } | {
85
+ name: string;
86
+ description: string;
87
+ inputSchema: {
88
+ type: string;
89
+ properties: {
90
+ title: {
91
+ type: string;
92
+ description: string;
93
+ };
94
+ content: {
95
+ type: string;
96
+ description: string;
97
+ };
98
+ metadata: {
99
+ type: string;
100
+ description: string;
101
+ };
102
+ };
103
+ required: string[];
104
+ };
105
+ })[];
106
+ /**
107
+ * Handle MCP tool calls
108
+ */
109
+ export declare function handleToolCall(strapi: Core.Strapi, request: {
110
+ params: {
111
+ name: string;
112
+ arguments?: unknown;
113
+ };
114
+ }): Promise<any>;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * List Embeddings Tool
3
+ *
4
+ * Lists all embeddings stored in the database.
5
+ */
6
+ import type { Core } from '@strapi/strapi';
7
+ export declare const listEmbeddingsTool: {
8
+ name: string;
9
+ description: string;
10
+ inputSchema: {
11
+ type: string;
12
+ properties: {
13
+ page: {
14
+ type: string;
15
+ description: string;
16
+ default: number;
17
+ };
18
+ pageSize: {
19
+ type: string;
20
+ description: string;
21
+ default: number;
22
+ };
23
+ search: {
24
+ type: string;
25
+ description: string;
26
+ };
27
+ };
28
+ required: any[];
29
+ };
30
+ };
31
+ export declare function handleListEmbeddings(strapi: Core.Strapi, args: {
32
+ page?: number;
33
+ pageSize?: number;
34
+ search?: string;
35
+ }): Promise<{
36
+ content: {
37
+ type: string;
38
+ text: string;
39
+ }[];
40
+ }>;