@centia-io/mcp-server 1.0.4 → 1.0.5

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 (4) hide show
  1. package/README.md +131 -131
  2. package/centia-api.json +3134 -3190
  3. package/dist/index.js +41 -7
  4. package/package.json +32 -32
package/dist/index.js CHANGED
@@ -159,6 +159,8 @@ function normalizeJsonSchemaForMCP(schema) {
159
159
  "date-time",
160
160
  "date",
161
161
  "time",
162
+ "binary",
163
+ "url",
162
164
  ]);
163
165
  const result = {};
164
166
  for (const [k, v] of Object.entries(schema)) {
@@ -264,6 +266,8 @@ for (const [pathStr, pathItem] of Object.entries(apiSpec.paths)) {
264
266
  headerParams: [],
265
267
  bodyParams: [],
266
268
  isBodyFlattened: false,
269
+ contentType: "application/json",
270
+ binaryParams: [],
267
271
  };
268
272
  // Handle path/query/header parameters
269
273
  for (const param of parameters) {
@@ -286,11 +290,21 @@ for (const [pathStr, pathItem] of Object.entries(apiSpec.paths)) {
286
290
  toolMeta.headerParams.push(resolvedParam.name);
287
291
  }
288
292
  // Handle request body
289
- if (requestBody?.content?.["application/json"]?.schema) {
290
- const bodySchema = resolveSchema(requestBody.content["application/json"].schema);
293
+ const content = requestBody?.content;
294
+ const jsonContent = content?.["application/json"];
295
+ const multipartContent = content?.["multipart/form-data"];
296
+ if (jsonContent?.schema || multipartContent?.schema) {
297
+ const bodySchema = resolveSchema(jsonContent?.schema || multipartContent?.schema);
298
+ if (multipartContent) {
299
+ toolMeta.contentType = "multipart/form-data";
300
+ }
291
301
  if (bodySchema.type === "object" && bodySchema.properties) {
292
302
  toolMeta.isBodyFlattened = true;
293
303
  for (const [key, value] of Object.entries(bodySchema.properties)) {
304
+ const resolvedValue = resolveSchema(value);
305
+ if (resolvedValue.format === "binary") {
306
+ toolMeta.binaryParams.push(key);
307
+ }
294
308
  properties[key] = normalizeJsonSchemaForMCP(sanitizeSchemaForMCP(value));
295
309
  toolMeta.bodyParams.push(key);
296
310
  }
@@ -361,7 +375,29 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
361
375
  }
362
376
  // Body
363
377
  if (toolMeta.bodyParams.length > 0) {
364
- if (toolMeta.isBodyFlattened) {
378
+ if (toolMeta.contentType === "multipart/form-data") {
379
+ const formData = new FormData();
380
+ for (const paramName of toolMeta.bodyParams) {
381
+ if (safeArgs[paramName] !== undefined) {
382
+ const value = safeArgs[paramName];
383
+ if (toolMeta.binaryParams.includes(paramName) && typeof value === "string") {
384
+ if (fs.existsSync(value)) {
385
+ const fileContent = fs.readFileSync(value);
386
+ const blob = new Blob([fileContent]);
387
+ formData.append(paramName, blob, path.basename(value));
388
+ }
389
+ else {
390
+ formData.append(paramName, value);
391
+ }
392
+ }
393
+ else {
394
+ formData.append(paramName, value);
395
+ }
396
+ }
397
+ }
398
+ config.data = formData;
399
+ }
400
+ else if (toolMeta.isBodyFlattened) {
365
401
  const body = {};
366
402
  for (const paramName of toolMeta.bodyParams) {
367
403
  if (safeArgs[paramName] !== undefined) {
@@ -380,7 +416,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
380
416
  content: [
381
417
  {
382
418
  type: "text",
383
- text: JSON.stringify(response.data, null, 2),
419
+ text: response.status === 200 ? JSON.stringify(response.data, null, 2) : response.statusText,
384
420
  },
385
421
  ],
386
422
  };
@@ -391,9 +427,7 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
391
427
  content: [
392
428
  {
393
429
  type: "text",
394
- text: error.response?.data
395
- ? JSON.stringify(error.response.data, null, 2)
396
- : error.message,
430
+ text: error.response.data.message || error.message,
397
431
  },
398
432
  ],
399
433
  };
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
- {
2
- "name": "@centia-io/mcp-server",
3
- "version": "1.0.4",
4
- "publishConfig": { "access": "public" },
5
- "description": "Centia MCP Server",
6
- "type": "module",
7
- "bin": {
8
- "mcp-server": "dist/index.js"
9
- },
10
- "files": [
11
- "dist",
12
- "centia-api.json"
13
- ],
14
- "scripts": {
15
- "build": "tsc",
16
- "start": "node dist/index.js",
17
- "dev": "tsx src/index.ts"
18
- },
19
- "keywords": [],
20
- "author": "",
21
- "license": "ISC",
22
- "dependencies": {
23
- "@modelcontextprotocol/sdk": "^1.26.0",
24
- "axios": "^1.13.5",
25
- "zod": "^4.3.6"
26
- },
27
- "devDependencies": {
28
- "@types/node": "^25.2.2",
29
- "tsx": "^4.21.0",
30
- "typescript": "^5.9.3"
31
- }
32
- }
1
+ {
2
+ "name": "@centia-io/mcp-server",
3
+ "version": "1.0.5",
4
+ "publishConfig": { "access": "public" },
5
+ "description": "Centia MCP Server",
6
+ "type": "module",
7
+ "bin": {
8
+ "mcp-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "centia-api.json"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "start": "node dist/index.js",
17
+ "dev": "tsx src/index.ts"
18
+ },
19
+ "keywords": [],
20
+ "author": "",
21
+ "license": "ISC",
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.26.0",
24
+ "axios": "^1.13.5",
25
+ "zod": "^4.3.6"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^25.2.2",
29
+ "tsx": "^4.21.0",
30
+ "typescript": "^5.9.3"
31
+ }
32
+ }