@skemacms/mcp-server 1.1.0 → 1.2.1
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/README.md +0 -1
- package/dist/skema-client.d.ts +14 -27
- package/dist/skema-client.js +50 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,7 +52,6 @@ Ajoutez dans vos paramètres MCP :
|
|
|
52
52
|
| Variable | Description | Requis |
|
|
53
53
|
| ---------------- | ------------------------------------------------------- | ------ |
|
|
54
54
|
| `SKEMA_API_KEY` | Clé API Skema (format `pk_live_xxx`) | Oui |
|
|
55
|
-
| `SKEMA_BASE_URL` | URL de l'API Skema (défaut: `https://api.skemacms.com`) | Non |
|
|
56
55
|
|
|
57
56
|
## Outils disponibles (11 outils)
|
|
58
57
|
|
package/dist/skema-client.d.ts
CHANGED
|
@@ -1,31 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client HTTP pour communiquer avec l'API
|
|
2
|
+
* Client HTTP pour communiquer avec l'API MCP Skema (JSON-RPC 2.0)
|
|
3
3
|
*/
|
|
4
|
-
export interface SkemaResponse<T = unknown> {
|
|
5
|
-
data: T;
|
|
6
|
-
count?: number;
|
|
7
|
-
page?: number;
|
|
8
|
-
totalPages?: number;
|
|
9
|
-
message: string;
|
|
10
|
-
statusCode: number;
|
|
11
|
-
}
|
|
12
|
-
export interface FetchOptions {
|
|
13
|
-
method?: "GET" | "POST" | "PUT" | "DELETE";
|
|
14
|
-
body?: unknown;
|
|
15
|
-
params?: Record<string, string | number | boolean | undefined>;
|
|
16
|
-
}
|
|
17
4
|
/**
|
|
18
|
-
*
|
|
5
|
+
* Appelle un outil MCP via JSON-RPC
|
|
19
6
|
*/
|
|
20
|
-
export declare const
|
|
7
|
+
export declare const mcpCall: <T = unknown>(toolName: string, args?: Record<string, unknown>) => Promise<T>;
|
|
21
8
|
/**
|
|
22
9
|
* Recupere la liste des collections
|
|
23
10
|
*/
|
|
24
|
-
export declare const getCollections: () => Promise<
|
|
11
|
+
export declare const getCollections: () => Promise<unknown>;
|
|
25
12
|
/**
|
|
26
13
|
* Recupere le schema d'une collection
|
|
27
14
|
*/
|
|
28
|
-
export declare const getCollection: (
|
|
15
|
+
export declare const getCollection: (collection: string) => Promise<unknown>;
|
|
29
16
|
/**
|
|
30
17
|
* Liste les items d'une collection
|
|
31
18
|
*/
|
|
@@ -35,25 +22,25 @@ export declare const getItems: (collection: string, options?: {
|
|
|
35
22
|
sort?: string;
|
|
36
23
|
populate?: string;
|
|
37
24
|
filters?: Record<string, unknown>;
|
|
38
|
-
}) => Promise<
|
|
25
|
+
}) => Promise<unknown>;
|
|
39
26
|
/**
|
|
40
27
|
* Recupere un item par son ID
|
|
41
28
|
*/
|
|
42
29
|
export declare const getItem: (collection: string, id: string, options?: {
|
|
43
30
|
populate?: string;
|
|
44
|
-
}) => Promise<
|
|
31
|
+
}) => Promise<unknown>;
|
|
45
32
|
/**
|
|
46
33
|
* Cree un nouvel item
|
|
47
34
|
*/
|
|
48
|
-
export declare const createItem: (collection: string, data: Record<string, unknown>) => Promise<
|
|
35
|
+
export declare const createItem: (collection: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
49
36
|
/**
|
|
50
37
|
* Met a jour un item
|
|
51
38
|
*/
|
|
52
|
-
export declare const updateItem: (collection: string, id: string, data: Record<string, unknown>) => Promise<
|
|
39
|
+
export declare const updateItem: (collection: string, id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
53
40
|
/**
|
|
54
41
|
* Supprime un item
|
|
55
42
|
*/
|
|
56
|
-
export declare const deleteItem: (collection: string, id: string) => Promise<
|
|
43
|
+
export declare const deleteItem: (collection: string, id: string) => Promise<unknown>;
|
|
57
44
|
/**
|
|
58
45
|
* Recherche dans une collection
|
|
59
46
|
*/
|
|
@@ -61,18 +48,18 @@ export declare const searchItems: (collection: string, query: string, options?:
|
|
|
61
48
|
fields?: string;
|
|
62
49
|
page?: number;
|
|
63
50
|
perPage?: number;
|
|
64
|
-
}) => Promise<
|
|
51
|
+
}) => Promise<unknown>;
|
|
65
52
|
/**
|
|
66
53
|
* Compte les items d'une collection
|
|
67
54
|
*/
|
|
68
|
-
export declare const countItems: (collection: string, filters?: Record<string, unknown>) => Promise<
|
|
55
|
+
export declare const countItems: (collection: string, filters?: Record<string, unknown>) => Promise<unknown>;
|
|
69
56
|
/**
|
|
70
57
|
* Cree plusieurs items en une seule requete
|
|
71
58
|
*/
|
|
72
|
-
export declare const batchCreate: (collection: string, items: Record<string, unknown>[]) => Promise<
|
|
59
|
+
export declare const batchCreate: (collection: string, items: Record<string, unknown>[]) => Promise<unknown>;
|
|
73
60
|
/**
|
|
74
61
|
* Met a jour plusieurs items en une seule requete
|
|
75
62
|
*/
|
|
76
63
|
export declare const batchUpdate: (collection: string, items: Array<{
|
|
77
64
|
id: string;
|
|
78
|
-
} & Record<string, unknown>>) => Promise<
|
|
65
|
+
} & Record<string, unknown>>) => Promise<unknown>;
|
package/dist/skema-client.js
CHANGED
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Client HTTP pour communiquer avec l'API
|
|
2
|
+
* Client HTTP pour communiquer avec l'API MCP Skema (JSON-RPC 2.0)
|
|
3
3
|
*/
|
|
4
4
|
const API_KEY = process.env.SKEMA_API_KEY || "";
|
|
5
5
|
const BASE_URL = process.env.SKEMA_BASE_URL || "https://api.skemacms.com";
|
|
6
|
+
let requestId = 0;
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
+
* Appelle un outil MCP via JSON-RPC
|
|
8
9
|
*/
|
|
9
|
-
export const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const searchParams = new URLSearchParams();
|
|
14
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
15
|
-
if (value !== undefined) {
|
|
16
|
-
searchParams.append(key, String(value));
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
const queryString = searchParams.toString();
|
|
20
|
-
if (queryString) {
|
|
21
|
-
url += `?${queryString}`;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const response = await fetch(url, {
|
|
25
|
-
method,
|
|
10
|
+
export const mcpCall = async (toolName, args = {}) => {
|
|
11
|
+
requestId++;
|
|
12
|
+
const response = await fetch(`${BASE_URL}/mcp`, {
|
|
13
|
+
method: "POST",
|
|
26
14
|
headers: {
|
|
27
|
-
|
|
15
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
28
16
|
"Content-Type": "application/json",
|
|
29
17
|
},
|
|
30
|
-
|
|
18
|
+
body: JSON.stringify({
|
|
19
|
+
jsonrpc: "2.0",
|
|
20
|
+
id: requestId,
|
|
21
|
+
method: "tools/call",
|
|
22
|
+
params: {
|
|
23
|
+
name: toolName,
|
|
24
|
+
arguments: args,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
31
27
|
});
|
|
32
28
|
if (!response.ok) {
|
|
33
29
|
const error = await response
|
|
@@ -35,82 +31,73 @@ export const skemaFetch = async (path, options = {}) => {
|
|
|
35
31
|
.catch(() => ({ message: "Erreur inconnue" }));
|
|
36
32
|
throw new Error(error.message || `Erreur HTTP ${response.status}`);
|
|
37
33
|
}
|
|
38
|
-
|
|
34
|
+
const jsonRpc = await response.json();
|
|
35
|
+
if (jsonRpc.error) {
|
|
36
|
+
throw new Error(jsonRpc.error.message);
|
|
37
|
+
}
|
|
38
|
+
if (!jsonRpc.result?.content?.[0]?.text) {
|
|
39
|
+
throw new Error("Reponse MCP invalide");
|
|
40
|
+
}
|
|
41
|
+
return JSON.parse(jsonRpc.result.content[0].text);
|
|
39
42
|
};
|
|
40
43
|
/**
|
|
41
44
|
* Recupere la liste des collections
|
|
42
45
|
*/
|
|
43
|
-
export const getCollections = () =>
|
|
46
|
+
export const getCollections = () => mcpCall("get_collections");
|
|
44
47
|
/**
|
|
45
48
|
* Recupere le schema d'une collection
|
|
46
49
|
*/
|
|
47
|
-
export const getCollection = (
|
|
50
|
+
export const getCollection = (collection) => mcpCall("get_collection", { collection });
|
|
48
51
|
/**
|
|
49
52
|
* Liste les items d'une collection
|
|
50
53
|
*/
|
|
51
|
-
export const getItems = (collection, options) =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
54
|
+
export const getItems = (collection, options) => mcpCall("get_collection_items", {
|
|
55
|
+
collection,
|
|
56
|
+
page: options?.page,
|
|
57
|
+
perPage: options?.perPage,
|
|
58
|
+
sort: options?.sort,
|
|
59
|
+
populate: options?.populate,
|
|
60
|
+
filters: options?.filters,
|
|
59
61
|
});
|
|
60
62
|
/**
|
|
61
63
|
* Recupere un item par son ID
|
|
62
64
|
*/
|
|
63
|
-
export const getItem = (collection, id, options) =>
|
|
64
|
-
|
|
65
|
+
export const getItem = (collection, id, options) => mcpCall("get_collection_item", {
|
|
66
|
+
collection,
|
|
67
|
+
id,
|
|
68
|
+
populate: options?.populate,
|
|
65
69
|
});
|
|
66
70
|
/**
|
|
67
71
|
* Cree un nouvel item
|
|
68
72
|
*/
|
|
69
|
-
export const createItem = (collection, data) =>
|
|
70
|
-
method: "POST",
|
|
71
|
-
body: data,
|
|
72
|
-
});
|
|
73
|
+
export const createItem = (collection, data) => mcpCall("create_collection_item", { collection, data });
|
|
73
74
|
/**
|
|
74
75
|
* Met a jour un item
|
|
75
76
|
*/
|
|
76
|
-
export const updateItem = (collection, id, data) =>
|
|
77
|
-
method: "PUT",
|
|
78
|
-
body: data,
|
|
79
|
-
});
|
|
77
|
+
export const updateItem = (collection, id, data) => mcpCall("update_collection_item", { collection, id, data });
|
|
80
78
|
/**
|
|
81
79
|
* Supprime un item
|
|
82
80
|
*/
|
|
83
|
-
export const deleteItem = (collection, id) =>
|
|
84
|
-
method: "DELETE",
|
|
85
|
-
});
|
|
81
|
+
export const deleteItem = (collection, id) => mcpCall("delete_collection_item", { collection, id });
|
|
86
82
|
/**
|
|
87
83
|
* Recherche dans une collection
|
|
88
84
|
*/
|
|
89
|
-
export const searchItems = (collection, query, options) =>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
85
|
+
export const searchItems = (collection, query, options) => mcpCall("search_collection_items", {
|
|
86
|
+
collection,
|
|
87
|
+
query,
|
|
88
|
+
fields: options?.fields,
|
|
89
|
+
page: options?.page,
|
|
90
|
+
perPage: options?.perPage,
|
|
96
91
|
});
|
|
97
92
|
/**
|
|
98
93
|
* Compte les items d'une collection
|
|
99
94
|
*/
|
|
100
|
-
export const countItems = (collection, filters) =>
|
|
101
|
-
params: filters ? { filters: JSON.stringify(filters) } : undefined,
|
|
102
|
-
});
|
|
95
|
+
export const countItems = (collection, filters) => mcpCall("count_collection_items", { collection, filters });
|
|
103
96
|
/**
|
|
104
97
|
* Cree plusieurs items en une seule requete
|
|
105
98
|
*/
|
|
106
|
-
export const batchCreate = (collection, items) =>
|
|
107
|
-
method: "POST",
|
|
108
|
-
body: items,
|
|
109
|
-
});
|
|
99
|
+
export const batchCreate = (collection, items) => mcpCall("batch_create_items", { collection, items });
|
|
110
100
|
/**
|
|
111
101
|
* Met a jour plusieurs items en une seule requete
|
|
112
102
|
*/
|
|
113
|
-
export const batchUpdate = (collection, items) =>
|
|
114
|
-
method: "PUT",
|
|
115
|
-
body: items,
|
|
116
|
-
});
|
|
103
|
+
export const batchUpdate = (collection, items) => mcpCall("batch_update_items", { collection, items });
|