@centrali-io/centrali-mcp 3.1.7 → 4.0.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 +13 -5
- package/dist/index.js +2 -0
- package/dist/resources/structures.d.ts +1 -0
- package/dist/resources/structures.js +74 -2
- package/dist/tools/search.js +12 -4
- package/dist/tools/structures.d.ts +1 -0
- package/dist/tools/structures.js +54 -2
- package/package.json +2 -2
- package/src/index.ts +4 -2
- package/src/resources/structures.ts +84 -2
- package/src/tools/search.ts +14 -4
- package/src/tools/structures.ts +63 -2
package/README.md
CHANGED
|
@@ -36,11 +36,17 @@ Add to your MCP client configuration (e.g., Claude Desktop, Cursor):
|
|
|
36
36
|
|
|
37
37
|
## Available Tools
|
|
38
38
|
|
|
39
|
-
###
|
|
39
|
+
### Collections
|
|
40
40
|
| Tool | Description |
|
|
41
41
|
|------|-------------|
|
|
42
|
-
| `
|
|
43
|
-
| `
|
|
42
|
+
| `list_collections` | List all data collections (schemas) in the workspace |
|
|
43
|
+
| `get_collection` | Get full schema for a collection by record slug |
|
|
44
|
+
|
|
45
|
+
### Structures (Deprecated)
|
|
46
|
+
| Tool | Description |
|
|
47
|
+
|------|-------------|
|
|
48
|
+
| `list_structures` | *Deprecated: use `list_collections`* — List all data structures in the workspace |
|
|
49
|
+
| `get_structure` | *Deprecated: use `get_collection`* — Get full schema for a structure by record slug |
|
|
44
50
|
|
|
45
51
|
### Records
|
|
46
52
|
| Tool | Description |
|
|
@@ -73,8 +79,10 @@ Add to your MCP client configuration (e.g., Claude Desktop, Cursor):
|
|
|
73
79
|
|
|
74
80
|
| URI | Description |
|
|
75
81
|
|-----|-------------|
|
|
76
|
-
| `centrali://
|
|
77
|
-
| `centrali://
|
|
82
|
+
| `centrali://collections` | List of all collections with name, slug, description |
|
|
83
|
+
| `centrali://collections/{slug}` | Full schema for a specific collection |
|
|
84
|
+
| `centrali://structures` | *Deprecated: use `centrali://collections`* |
|
|
85
|
+
| `centrali://structures/{slug}` | *Deprecated: use `centrali://collections/{slug}`* |
|
|
78
86
|
|
|
79
87
|
## Development
|
|
80
88
|
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ function main() {
|
|
|
47
47
|
version: "1.0.0",
|
|
48
48
|
});
|
|
49
49
|
// Register all tools
|
|
50
|
+
(0, structures_js_1.registerCollectionTools)(server, sdk);
|
|
50
51
|
(0, structures_js_1.registerStructureTools)(server, sdk);
|
|
51
52
|
(0, records_js_1.registerRecordTools)(server, sdk);
|
|
52
53
|
(0, search_js_1.registerSearchTools)(server, sdk);
|
|
@@ -56,6 +57,7 @@ function main() {
|
|
|
56
57
|
(0, insights_js_1.registerInsightTools)(server, sdk);
|
|
57
58
|
(0, validation_js_1.registerValidationTools)(server, sdk);
|
|
58
59
|
// Register resources
|
|
60
|
+
(0, structures_js_2.registerCollectionResources)(server, sdk);
|
|
59
61
|
(0, structures_js_2.registerStructureResources)(server, sdk);
|
|
60
62
|
// Start stdio transport
|
|
61
63
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { CentraliSDK } from "@centrali-io/centrali-sdk";
|
|
3
3
|
export declare function registerStructureResources(server: McpServer, sdk: CentraliSDK): void;
|
|
4
|
+
export declare function registerCollectionResources(server: McpServer, sdk: CentraliSDK): void;
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerStructureResources = registerStructureResources;
|
|
13
|
+
exports.registerCollectionResources = registerCollectionResources;
|
|
13
14
|
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
14
15
|
function formatError(error, context) {
|
|
15
16
|
var _a, _b;
|
|
@@ -36,7 +37,7 @@ function formatError(error, context) {
|
|
|
36
37
|
function registerStructureResources(server, sdk) {
|
|
37
38
|
// Static resource: list all structures (gives LLM workspace context)
|
|
38
39
|
server.resource("structures-list", "centrali://structures", {
|
|
39
|
-
description: "List of all data structures in the workspace with name, slug, and description",
|
|
40
|
+
description: "[DEPRECATED: use centrali://collections instead] List of all data structures in the workspace with name, slug, and description",
|
|
40
41
|
mimeType: "application/json",
|
|
41
42
|
}, (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
42
43
|
try {
|
|
@@ -84,7 +85,7 @@ function registerStructureResources(server, sdk) {
|
|
|
84
85
|
}
|
|
85
86
|
}),
|
|
86
87
|
}), {
|
|
87
|
-
description: "Full schema definition for a specific structure",
|
|
88
|
+
description: "[DEPRECATED: use centrali://collections/{slug} instead] Full schema definition for a specific structure",
|
|
88
89
|
mimeType: "application/json",
|
|
89
90
|
}, (uri_1, _a) => __awaiter(this, [uri_1, _a], void 0, function* (uri, { slug }) {
|
|
90
91
|
try {
|
|
@@ -104,3 +105,74 @@ function registerStructureResources(server, sdk) {
|
|
|
104
105
|
}
|
|
105
106
|
}));
|
|
106
107
|
}
|
|
108
|
+
function registerCollectionResources(server, sdk) {
|
|
109
|
+
// Static resource: list all collections (gives LLM workspace context)
|
|
110
|
+
server.resource("collections-list", "centrali://collections", {
|
|
111
|
+
description: "List of all data collections in the workspace with name, slug, and description",
|
|
112
|
+
mimeType: "application/json",
|
|
113
|
+
}, (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
114
|
+
try {
|
|
115
|
+
const result = yield sdk.collections.list({ limit: 100 });
|
|
116
|
+
const summary = (result.data || []).map((s) => {
|
|
117
|
+
var _a;
|
|
118
|
+
return ({
|
|
119
|
+
name: s.name,
|
|
120
|
+
recordSlug: s.recordSlug,
|
|
121
|
+
description: s.description || "",
|
|
122
|
+
propertyCount: ((_a = s.properties) === null || _a === void 0 ? void 0 : _a.length) || 0,
|
|
123
|
+
status: s.status,
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
return {
|
|
127
|
+
contents: [
|
|
128
|
+
{
|
|
129
|
+
uri: uri.href,
|
|
130
|
+
mimeType: "application/json",
|
|
131
|
+
text: JSON.stringify(summary, null, 2),
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
throw new Error(formatError(error, "listing collections resource"));
|
|
138
|
+
}
|
|
139
|
+
}));
|
|
140
|
+
// Resource template: full schema for a specific collection
|
|
141
|
+
server.resource("collection-schema", new mcp_js_1.ResourceTemplate("centrali://collections/{slug}", {
|
|
142
|
+
list: () => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
try {
|
|
144
|
+
const result = yield sdk.collections.list({ limit: 100 });
|
|
145
|
+
return {
|
|
146
|
+
resources: (result.data || []).map((s) => ({
|
|
147
|
+
uri: `centrali://collections/${s.recordSlug}`,
|
|
148
|
+
name: s.name,
|
|
149
|
+
description: s.description || `Schema for ${s.name}`,
|
|
150
|
+
mimeType: "application/json",
|
|
151
|
+
})),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
throw new Error(formatError(error, "listing collection schemas"));
|
|
156
|
+
}
|
|
157
|
+
}),
|
|
158
|
+
}), {
|
|
159
|
+
description: "Full schema definition for a specific collection",
|
|
160
|
+
mimeType: "application/json",
|
|
161
|
+
}, (uri_1, _a) => __awaiter(this, [uri_1, _a], void 0, function* (uri, { slug }) {
|
|
162
|
+
try {
|
|
163
|
+
const result = yield sdk.collections.getBySlug(slug);
|
|
164
|
+
return {
|
|
165
|
+
contents: [
|
|
166
|
+
{
|
|
167
|
+
uri: uri.href,
|
|
168
|
+
mimeType: "application/json",
|
|
169
|
+
text: JSON.stringify(result.data, null, 2),
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
throw new Error(formatError(error, `getting collection schema for '${slug}'`));
|
|
176
|
+
}
|
|
177
|
+
}));
|
|
178
|
+
}
|
package/dist/tools/search.js
CHANGED
|
@@ -36,19 +36,27 @@ function formatError(error, context) {
|
|
|
36
36
|
function registerSearchTools(server, sdk) {
|
|
37
37
|
server.tool("search_records", "Full-text search across records in the workspace. Powered by Meilisearch. Optionally filter by structure(s) and limit results.", {
|
|
38
38
|
query: zod_1.z.string().describe("The search query string"),
|
|
39
|
+
collections: zod_1.z
|
|
40
|
+
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
41
|
+
.optional()
|
|
42
|
+
.describe("Filter by collection slug(s). Single slug string or array of slugs"),
|
|
39
43
|
structures: zod_1.z
|
|
40
44
|
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
41
45
|
.optional()
|
|
42
|
-
.describe("Filter by structure slug(s). Single slug string or array of slugs"),
|
|
46
|
+
.describe("[DEPRECATED: use collections instead] Filter by structure slug(s). Single slug string or array of slugs"),
|
|
43
47
|
limit: zod_1.z
|
|
44
48
|
.number()
|
|
45
49
|
.optional()
|
|
46
50
|
.describe("Maximum results to return (default: 20, max: 100)"),
|
|
47
|
-
}, (_a) => __awaiter(this, [_a], void 0, function* ({ query, structures, limit }) {
|
|
51
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ query, collections, structures, limit }) {
|
|
48
52
|
try {
|
|
49
53
|
const options = {};
|
|
50
|
-
if (
|
|
51
|
-
options.
|
|
54
|
+
if (collections) {
|
|
55
|
+
options.collections = collections;
|
|
56
|
+
}
|
|
57
|
+
else if (structures) {
|
|
58
|
+
options.collections = structures;
|
|
59
|
+
}
|
|
52
60
|
if (limit)
|
|
53
61
|
options.limit = limit;
|
|
54
62
|
const result = yield sdk.search(query, Object.keys(options).length > 0 ? options : undefined);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { CentraliSDK } from "@centrali-io/centrali-sdk";
|
|
3
3
|
export declare function registerStructureTools(server: McpServer, sdk: CentraliSDK): void;
|
|
4
|
+
export declare function registerCollectionTools(server: McpServer, sdk: CentraliSDK): void;
|
package/dist/tools/structures.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.registerStructureTools = registerStructureTools;
|
|
13
|
+
exports.registerCollectionTools = registerCollectionTools;
|
|
13
14
|
const zod_1 = require("zod");
|
|
14
15
|
function formatError(error, context) {
|
|
15
16
|
var _a, _b;
|
|
@@ -34,7 +35,7 @@ function formatError(error, context) {
|
|
|
34
35
|
return `Error ${context}: ${error instanceof Error ? error.message : String(error)}`;
|
|
35
36
|
}
|
|
36
37
|
function registerStructureTools(server, sdk) {
|
|
37
|
-
server.tool("list_structures", "List all data structures (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each structure.", {
|
|
38
|
+
server.tool("list_structures", "[DEPRECATED: use list_collections instead] List all data structures (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each structure.", {
|
|
38
39
|
page: zod_1.z.number().optional().describe("Page number (1-indexed)"),
|
|
39
40
|
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
40
41
|
}, (_a) => __awaiter(this, [_a], void 0, function* ({ page, limit }) {
|
|
@@ -58,7 +59,7 @@ function registerStructureTools(server, sdk) {
|
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
}));
|
|
61
|
-
server.tool("get_structure", "Get the full schema definition for a specific structure by its record slug. Returns properties, types, constraints, and configuration.", {
|
|
62
|
+
server.tool("get_structure", "[DEPRECATED: use get_collection instead] Get the full schema definition for a specific structure by its record slug. Returns properties, types, constraints, and configuration.", {
|
|
62
63
|
recordSlug: zod_1.z
|
|
63
64
|
.string()
|
|
64
65
|
.describe("The structure's record slug (e.g., 'orders', 'customers')"),
|
|
@@ -84,3 +85,54 @@ function registerStructureTools(server, sdk) {
|
|
|
84
85
|
}
|
|
85
86
|
}));
|
|
86
87
|
}
|
|
88
|
+
function registerCollectionTools(server, sdk) {
|
|
89
|
+
server.tool("list_collections", "List all data collections (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each collection.", {
|
|
90
|
+
page: zod_1.z.number().optional().describe("Page number (1-indexed)"),
|
|
91
|
+
limit: zod_1.z.number().optional().describe("Results per page"),
|
|
92
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ page, limit }) {
|
|
93
|
+
try {
|
|
94
|
+
const result = yield sdk.collections.list({ page, limit });
|
|
95
|
+
return {
|
|
96
|
+
content: [
|
|
97
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
98
|
+
],
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
return {
|
|
103
|
+
content: [
|
|
104
|
+
{
|
|
105
|
+
type: "text",
|
|
106
|
+
text: formatError(error, "listing collections"),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
isError: true,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
server.tool("get_collection", "Get the full schema definition for a specific collection by its record slug. Returns properties, types, constraints, and configuration.", {
|
|
114
|
+
recordSlug: zod_1.z
|
|
115
|
+
.string()
|
|
116
|
+
.describe("The collection's record slug (e.g., 'orders', 'customers')"),
|
|
117
|
+
}, (_a) => __awaiter(this, [_a], void 0, function* ({ recordSlug }) {
|
|
118
|
+
try {
|
|
119
|
+
const result = yield sdk.collections.getBySlug(recordSlug);
|
|
120
|
+
return {
|
|
121
|
+
content: [
|
|
122
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
123
|
+
],
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
return {
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: "text",
|
|
131
|
+
text: formatError(error, `getting collection '${recordSlug}'`),
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
isError: true,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centrali-io/centrali-mcp",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "Centrali MCP Server - AI assistant integration for Centrali workspaces",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"author": "Blueinit",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@centrali-io/centrali-sdk": "^
|
|
28
|
+
"@centrali-io/centrali-sdk": "^4.0.1",
|
|
29
29
|
"@modelcontextprotocol/sdk": "^1.12.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
import { CentraliSDK } from "@centrali-io/centrali-sdk";
|
|
6
|
-
import { registerStructureTools } from "./tools/structures.js";
|
|
6
|
+
import { registerStructureTools, registerCollectionTools } from "./tools/structures.js";
|
|
7
7
|
import { registerRecordTools } from "./tools/records.js";
|
|
8
8
|
import { registerSearchTools } from "./tools/search.js";
|
|
9
9
|
import { registerComputeTools } from "./tools/compute.js";
|
|
@@ -11,7 +11,7 @@ import { registerSmartQueryTools } from "./tools/smart-queries.js";
|
|
|
11
11
|
import { registerOrchestrationTools } from "./tools/orchestrations.js";
|
|
12
12
|
import { registerInsightTools } from "./tools/insights.js";
|
|
13
13
|
import { registerValidationTools } from "./tools/validation.js";
|
|
14
|
-
import { registerStructureResources } from "./resources/structures.js";
|
|
14
|
+
import { registerStructureResources, registerCollectionResources } from "./resources/structures.js";
|
|
15
15
|
|
|
16
16
|
function getRequiredEnv(name: string): string {
|
|
17
17
|
const value = process.env[name];
|
|
@@ -41,6 +41,7 @@ async function main() {
|
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
// Register all tools
|
|
44
|
+
registerCollectionTools(server, sdk);
|
|
44
45
|
registerStructureTools(server, sdk);
|
|
45
46
|
registerRecordTools(server, sdk);
|
|
46
47
|
registerSearchTools(server, sdk);
|
|
@@ -51,6 +52,7 @@ async function main() {
|
|
|
51
52
|
registerValidationTools(server, sdk);
|
|
52
53
|
|
|
53
54
|
// Register resources
|
|
55
|
+
registerCollectionResources(server, sdk);
|
|
54
56
|
registerStructureResources(server, sdk);
|
|
55
57
|
|
|
56
58
|
// Start stdio transport
|
|
@@ -32,7 +32,7 @@ export function registerStructureResources(
|
|
|
32
32
|
"centrali://structures",
|
|
33
33
|
{
|
|
34
34
|
description:
|
|
35
|
-
"List of all data structures in the workspace with name, slug, and description",
|
|
35
|
+
"[DEPRECATED: use centrali://collections instead] List of all data structures in the workspace with name, slug, and description",
|
|
36
36
|
mimeType: "application/json",
|
|
37
37
|
},
|
|
38
38
|
async (uri) => {
|
|
@@ -64,6 +64,7 @@ export function registerStructureResources(
|
|
|
64
64
|
server.resource(
|
|
65
65
|
"structure-schema",
|
|
66
66
|
new ResourceTemplate("centrali://structures/{slug}", {
|
|
67
|
+
|
|
67
68
|
list: async () => {
|
|
68
69
|
try {
|
|
69
70
|
const result = await sdk.structures.list({ limit: 100 });
|
|
@@ -81,7 +82,7 @@ export function registerStructureResources(
|
|
|
81
82
|
},
|
|
82
83
|
}),
|
|
83
84
|
{
|
|
84
|
-
description: "Full schema definition for a specific structure",
|
|
85
|
+
description: "[DEPRECATED: use centrali://collections/{slug} instead] Full schema definition for a specific structure",
|
|
85
86
|
mimeType: "application/json",
|
|
86
87
|
},
|
|
87
88
|
async (uri, { slug }) => {
|
|
@@ -102,3 +103,84 @@ export function registerStructureResources(
|
|
|
102
103
|
}
|
|
103
104
|
);
|
|
104
105
|
}
|
|
106
|
+
|
|
107
|
+
export function registerCollectionResources(
|
|
108
|
+
server: McpServer,
|
|
109
|
+
sdk: CentraliSDK
|
|
110
|
+
) {
|
|
111
|
+
// Static resource: list all collections (gives LLM workspace context)
|
|
112
|
+
server.resource(
|
|
113
|
+
"collections-list",
|
|
114
|
+
"centrali://collections",
|
|
115
|
+
{
|
|
116
|
+
description:
|
|
117
|
+
"List of all data collections in the workspace with name, slug, and description",
|
|
118
|
+
mimeType: "application/json",
|
|
119
|
+
},
|
|
120
|
+
async (uri) => {
|
|
121
|
+
try {
|
|
122
|
+
const result = await sdk.collections.list({ limit: 100 });
|
|
123
|
+
const summary = (result.data || []).map((s) => ({
|
|
124
|
+
name: s.name,
|
|
125
|
+
recordSlug: s.recordSlug,
|
|
126
|
+
description: s.description || "",
|
|
127
|
+
propertyCount: s.properties?.length || 0,
|
|
128
|
+
status: s.status,
|
|
129
|
+
}));
|
|
130
|
+
return {
|
|
131
|
+
contents: [
|
|
132
|
+
{
|
|
133
|
+
uri: uri.href,
|
|
134
|
+
mimeType: "application/json",
|
|
135
|
+
text: JSON.stringify(summary, null, 2),
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
} catch (error: unknown) {
|
|
140
|
+
throw new Error(formatError(error, "listing collections resource"));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
// Resource template: full schema for a specific collection
|
|
146
|
+
server.resource(
|
|
147
|
+
"collection-schema",
|
|
148
|
+
new ResourceTemplate("centrali://collections/{slug}", {
|
|
149
|
+
list: async () => {
|
|
150
|
+
try {
|
|
151
|
+
const result = await sdk.collections.list({ limit: 100 });
|
|
152
|
+
return {
|
|
153
|
+
resources: (result.data || []).map((s) => ({
|
|
154
|
+
uri: `centrali://collections/${s.recordSlug}`,
|
|
155
|
+
name: s.name,
|
|
156
|
+
description: s.description || `Schema for ${s.name}`,
|
|
157
|
+
mimeType: "application/json",
|
|
158
|
+
})),
|
|
159
|
+
};
|
|
160
|
+
} catch (error: unknown) {
|
|
161
|
+
throw new Error(formatError(error, "listing collection schemas"));
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
{
|
|
166
|
+
description: "Full schema definition for a specific collection",
|
|
167
|
+
mimeType: "application/json",
|
|
168
|
+
},
|
|
169
|
+
async (uri, { slug }) => {
|
|
170
|
+
try {
|
|
171
|
+
const result = await sdk.collections.getBySlug(slug as string);
|
|
172
|
+
return {
|
|
173
|
+
contents: [
|
|
174
|
+
{
|
|
175
|
+
uri: uri.href,
|
|
176
|
+
mimeType: "application/json",
|
|
177
|
+
text: JSON.stringify(result.data, null, 2),
|
|
178
|
+
},
|
|
179
|
+
],
|
|
180
|
+
};
|
|
181
|
+
} catch (error: unknown) {
|
|
182
|
+
throw new Error(formatError(error, `getting collection schema for '${slug}'`));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
);
|
|
186
|
+
}
|
package/src/tools/search.ts
CHANGED
|
@@ -29,21 +29,31 @@ export function registerSearchTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
29
29
|
"Full-text search across records in the workspace. Powered by Meilisearch. Optionally filter by structure(s) and limit results.",
|
|
30
30
|
{
|
|
31
31
|
query: z.string().describe("The search query string"),
|
|
32
|
+
collections: z
|
|
33
|
+
.union([z.string(), z.array(z.string())])
|
|
34
|
+
.optional()
|
|
35
|
+
.describe(
|
|
36
|
+
"Filter by collection slug(s). Single slug string or array of slugs"
|
|
37
|
+
),
|
|
32
38
|
structures: z
|
|
33
39
|
.union([z.string(), z.array(z.string())])
|
|
34
40
|
.optional()
|
|
35
41
|
.describe(
|
|
36
|
-
"Filter by structure slug(s). Single slug string or array of slugs"
|
|
42
|
+
"[DEPRECATED: use collections instead] Filter by structure slug(s). Single slug string or array of slugs"
|
|
37
43
|
),
|
|
38
44
|
limit: z
|
|
39
45
|
.number()
|
|
40
46
|
.optional()
|
|
41
47
|
.describe("Maximum results to return (default: 20, max: 100)"),
|
|
42
48
|
},
|
|
43
|
-
async ({ query, structures, limit }) => {
|
|
49
|
+
async ({ query, collections, structures, limit }) => {
|
|
44
50
|
try {
|
|
45
|
-
const options: { structures?: string | string[]; limit?: number } = {};
|
|
46
|
-
if (
|
|
51
|
+
const options: { collections?: string | string[]; structures?: string | string[]; limit?: number } = {};
|
|
52
|
+
if (collections) {
|
|
53
|
+
options.collections = collections;
|
|
54
|
+
} else if (structures) {
|
|
55
|
+
options.collections = structures;
|
|
56
|
+
}
|
|
47
57
|
if (limit) options.limit = limit;
|
|
48
58
|
|
|
49
59
|
const result = await sdk.search(
|
package/src/tools/structures.ts
CHANGED
|
@@ -26,7 +26,7 @@ function formatError(error: unknown, context: string): string {
|
|
|
26
26
|
export function registerStructureTools(server: McpServer, sdk: CentraliSDK) {
|
|
27
27
|
server.tool(
|
|
28
28
|
"list_structures",
|
|
29
|
-
"List all data structures (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each structure.",
|
|
29
|
+
"[DEPRECATED: use list_collections instead] List all data structures (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each structure.",
|
|
30
30
|
{
|
|
31
31
|
page: z.number().optional().describe("Page number (1-indexed)"),
|
|
32
32
|
limit: z.number().optional().describe("Results per page"),
|
|
@@ -55,7 +55,7 @@ export function registerStructureTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
55
55
|
|
|
56
56
|
server.tool(
|
|
57
57
|
"get_structure",
|
|
58
|
-
"Get the full schema definition for a specific structure by its record slug. Returns properties, types, constraints, and configuration.",
|
|
58
|
+
"[DEPRECATED: use get_collection instead] Get the full schema definition for a specific structure by its record slug. Returns properties, types, constraints, and configuration.",
|
|
59
59
|
{
|
|
60
60
|
recordSlug: z
|
|
61
61
|
.string()
|
|
@@ -83,3 +83,64 @@ export function registerStructureTools(server: McpServer, sdk: CentraliSDK) {
|
|
|
83
83
|
}
|
|
84
84
|
);
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
export function registerCollectionTools(server: McpServer, sdk: CentraliSDK) {
|
|
88
|
+
server.tool(
|
|
89
|
+
"list_collections",
|
|
90
|
+
"List all data collections (schemas) in the Centrali workspace. Returns name, slug, description, and property definitions for each collection.",
|
|
91
|
+
{
|
|
92
|
+
page: z.number().optional().describe("Page number (1-indexed)"),
|
|
93
|
+
limit: z.number().optional().describe("Results per page"),
|
|
94
|
+
},
|
|
95
|
+
async ({ page, limit }) => {
|
|
96
|
+
try {
|
|
97
|
+
const result = await sdk.collections.list({ page, limit });
|
|
98
|
+
return {
|
|
99
|
+
content: [
|
|
100
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
} catch (error: unknown) {
|
|
104
|
+
return {
|
|
105
|
+
content: [
|
|
106
|
+
{
|
|
107
|
+
type: "text",
|
|
108
|
+
text: formatError(error, "listing collections"),
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
isError: true,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
server.tool(
|
|
118
|
+
"get_collection",
|
|
119
|
+
"Get the full schema definition for a specific collection by its record slug. Returns properties, types, constraints, and configuration.",
|
|
120
|
+
{
|
|
121
|
+
recordSlug: z
|
|
122
|
+
.string()
|
|
123
|
+
.describe("The collection's record slug (e.g., 'orders', 'customers')"),
|
|
124
|
+
},
|
|
125
|
+
async ({ recordSlug }) => {
|
|
126
|
+
try {
|
|
127
|
+
const result = await sdk.collections.getBySlug(recordSlug);
|
|
128
|
+
return {
|
|
129
|
+
content: [
|
|
130
|
+
{ type: "text", text: JSON.stringify(result.data, null, 2) },
|
|
131
|
+
],
|
|
132
|
+
};
|
|
133
|
+
} catch (error: unknown) {
|
|
134
|
+
return {
|
|
135
|
+
content: [
|
|
136
|
+
{
|
|
137
|
+
type: "text",
|
|
138
|
+
text: formatError(error, `getting collection '${recordSlug}'`),
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
isError: true,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
}
|