@ttoss/http-server-mcp-openapi 0.8.0 → 0.8.2
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 +4 -2
- package/dist/index.cjs +24 -4
- package/dist/index.d.cts +5 -1
- package/dist/index.d.mts +5 -1
- package/dist/index.mjs +24 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -66,10 +66,12 @@ Each OpenAPI operation with an `operationId` and a supported HTTP method
|
|
|
66
66
|
| path/query/body params | a single `inputSchema` object |
|
|
67
67
|
| `$ref`, `oneOf`, `anyOf` | dereferenced and merged into a flat schema |
|
|
68
68
|
| snake_case names | camelCase tool inputs, mapped back on call |
|
|
69
|
-
| operation `description` | tool description
|
|
69
|
+
| operation `description` | tool description, newlines flattened |
|
|
70
70
|
| operation `tags` | tool `tags`, for the deferred `search` filter |
|
|
71
71
|
|
|
72
|
-
Path params are always required strings
|
|
72
|
+
Path params are always required strings, carrying their own `description`; a
|
|
73
|
+
call missing one is refused before `callApi` runs, whatever
|
|
74
|
+
`validateArguments` says. Query and body params carry their
|
|
73
75
|
declared type and `required` flag. Array params keep their `items` schema. A
|
|
74
76
|
body property declared as a single-entry `allOf` (usually `allOf: [{ $ref }]`
|
|
75
77
|
beside its own `description`) takes `type`, `nullable` and `items` from the
|
package/dist/index.cjs
CHANGED
|
@@ -865,7 +865,7 @@ var getJsonSchemaType = schemaType => {
|
|
|
865
865
|
return "string";
|
|
866
866
|
};
|
|
867
867
|
var sanitizeDescription = description => {
|
|
868
|
-
return (description || "").replace(
|
|
868
|
+
return (description || "").replace(/\n/g, " ").trim();
|
|
869
869
|
};
|
|
870
870
|
var defaultDescribe = ({
|
|
871
871
|
operation
|
|
@@ -945,7 +945,7 @@ var buildInputSchema = (pathParams, queryParams, bodyProps) => {
|
|
|
945
945
|
const properties = {};
|
|
946
946
|
for (const param of modelPathParams) properties[param.argName] = {
|
|
947
947
|
type: "string",
|
|
948
|
-
description:
|
|
948
|
+
description: sanitizeDescription(param.description)
|
|
949
949
|
};
|
|
950
950
|
for (const param of [...modelQueryParams, ...bodyProps]) properties[param.argName] = normalizeNullable(buildTypedProperty(param));
|
|
951
951
|
return {
|
|
@@ -956,6 +956,25 @@ var buildInputSchema = (pathParams, queryParams, bodyProps) => {
|
|
|
956
956
|
} : {})
|
|
957
957
|
};
|
|
958
958
|
};
|
|
959
|
+
/**
|
|
960
|
+
* Builds the request path. A path without one of its params is another route —
|
|
961
|
+
* `/projects/{id}/members` reaches the API as a `404` naming the resource, not
|
|
962
|
+
* the missing argument — so the call is refused instead.
|
|
963
|
+
*/
|
|
964
|
+
var pathFn = args => {
|
|
965
|
+
const build = buildPathFn(args.pathTemplate, args.pathParams);
|
|
966
|
+
const required = values => {
|
|
967
|
+
const missing = args.pathParams.find(param => {
|
|
968
|
+
return !param.serverManaged && values[param.argName] === void 0;
|
|
969
|
+
});
|
|
970
|
+
if (missing) throw new Error(`Missing required argument "${missing.argName}".`);
|
|
971
|
+
return build(values);
|
|
972
|
+
};
|
|
973
|
+
return withPinned({
|
|
974
|
+
build: required,
|
|
975
|
+
pinned: args.pinned
|
|
976
|
+
});
|
|
977
|
+
};
|
|
959
978
|
var SUPPORTED_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
960
979
|
/** The tool description, from `options.describe` or the default. */
|
|
961
980
|
var describeOperation = args => {
|
|
@@ -1048,8 +1067,9 @@ var processOperation = args => {
|
|
|
1048
1067
|
pathTemplate: args.pathTemplate,
|
|
1049
1068
|
operationId: args.operation.operationId,
|
|
1050
1069
|
tags: operationTags(args.operation),
|
|
1051
|
-
path:
|
|
1052
|
-
|
|
1070
|
+
path: pathFn({
|
|
1071
|
+
pathTemplate: args.pathTemplate,
|
|
1072
|
+
pathParams,
|
|
1053
1073
|
pinned
|
|
1054
1074
|
}),
|
|
1055
1075
|
query: withPinned({
|
package/dist/index.d.cts
CHANGED
|
@@ -51,7 +51,10 @@ interface ToolDefinition {
|
|
|
51
51
|
operationId: string;
|
|
52
52
|
/** The operation's `tags`, e.g. to filter the deferred `search` by module. */
|
|
53
53
|
tags: string[];
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Builds the request path, substituting path params from the args. Throws
|
|
56
|
+
* when an argument a path param needs is missing.
|
|
57
|
+
*/
|
|
55
58
|
path: (args: Record<string, unknown>) => string;
|
|
56
59
|
/** Builds the query string (including leading `?`), or `undefined` if none. */
|
|
57
60
|
query?: (args: Record<string, unknown>) => string;
|
|
@@ -608,6 +611,7 @@ declare const getJsonSchemaType: (schemaType: string | undefined) => JsonSchemaP
|
|
|
608
611
|
declare const buildInputSchema: (pathParams: Array<{
|
|
609
612
|
name: string;
|
|
610
613
|
argName: string;
|
|
614
|
+
description?: string;
|
|
611
615
|
serverManaged?: boolean;
|
|
612
616
|
}>, queryParams: Array<{
|
|
613
617
|
name: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -51,7 +51,10 @@ interface ToolDefinition {
|
|
|
51
51
|
operationId: string;
|
|
52
52
|
/** The operation's `tags`, e.g. to filter the deferred `search` by module. */
|
|
53
53
|
tags: string[];
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Builds the request path, substituting path params from the args. Throws
|
|
56
|
+
* when an argument a path param needs is missing.
|
|
57
|
+
*/
|
|
55
58
|
path: (args: Record<string, unknown>) => string;
|
|
56
59
|
/** Builds the query string (including leading `?`), or `undefined` if none. */
|
|
57
60
|
query?: (args: Record<string, unknown>) => string;
|
|
@@ -608,6 +611,7 @@ declare const getJsonSchemaType: (schemaType: string | undefined) => JsonSchemaP
|
|
|
608
611
|
declare const buildInputSchema: (pathParams: Array<{
|
|
609
612
|
name: string;
|
|
610
613
|
argName: string;
|
|
614
|
+
description?: string;
|
|
611
615
|
serverManaged?: boolean;
|
|
612
616
|
}>, queryParams: Array<{
|
|
613
617
|
name: string;
|
package/dist/index.mjs
CHANGED
|
@@ -862,7 +862,7 @@ var getJsonSchemaType = schemaType => {
|
|
|
862
862
|
return "string";
|
|
863
863
|
};
|
|
864
864
|
var sanitizeDescription = description => {
|
|
865
|
-
return (description || "").replace(
|
|
865
|
+
return (description || "").replace(/\n/g, " ").trim();
|
|
866
866
|
};
|
|
867
867
|
var defaultDescribe = ({
|
|
868
868
|
operation
|
|
@@ -942,7 +942,7 @@ var buildInputSchema = (pathParams, queryParams, bodyProps) => {
|
|
|
942
942
|
const properties = {};
|
|
943
943
|
for (const param of modelPathParams) properties[param.argName] = {
|
|
944
944
|
type: "string",
|
|
945
|
-
description:
|
|
945
|
+
description: sanitizeDescription(param.description)
|
|
946
946
|
};
|
|
947
947
|
for (const param of [...modelQueryParams, ...bodyProps]) properties[param.argName] = normalizeNullable(buildTypedProperty(param));
|
|
948
948
|
return {
|
|
@@ -953,6 +953,25 @@ var buildInputSchema = (pathParams, queryParams, bodyProps) => {
|
|
|
953
953
|
} : {})
|
|
954
954
|
};
|
|
955
955
|
};
|
|
956
|
+
/**
|
|
957
|
+
* Builds the request path. A path without one of its params is another route —
|
|
958
|
+
* `/projects/{id}/members` reaches the API as a `404` naming the resource, not
|
|
959
|
+
* the missing argument — so the call is refused instead.
|
|
960
|
+
*/
|
|
961
|
+
var pathFn = args => {
|
|
962
|
+
const build = buildPathFn(args.pathTemplate, args.pathParams);
|
|
963
|
+
const required = values => {
|
|
964
|
+
const missing = args.pathParams.find(param => {
|
|
965
|
+
return !param.serverManaged && values[param.argName] === void 0;
|
|
966
|
+
});
|
|
967
|
+
if (missing) throw new Error(`Missing required argument "${missing.argName}".`);
|
|
968
|
+
return build(values);
|
|
969
|
+
};
|
|
970
|
+
return withPinned({
|
|
971
|
+
build: required,
|
|
972
|
+
pinned: args.pinned
|
|
973
|
+
});
|
|
974
|
+
};
|
|
956
975
|
var SUPPORTED_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
|
|
957
976
|
/** The tool description, from `options.describe` or the default. */
|
|
958
977
|
var describeOperation = args => {
|
|
@@ -1045,8 +1064,9 @@ var processOperation = args => {
|
|
|
1045
1064
|
pathTemplate: args.pathTemplate,
|
|
1046
1065
|
operationId: args.operation.operationId,
|
|
1047
1066
|
tags: operationTags(args.operation),
|
|
1048
|
-
path:
|
|
1049
|
-
|
|
1067
|
+
path: pathFn({
|
|
1068
|
+
pathTemplate: args.pathTemplate,
|
|
1069
|
+
pathParams,
|
|
1050
1070
|
pinned
|
|
1051
1071
|
}),
|
|
1052
1072
|
query: withPinned({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/http-server-mcp-openapi",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Generate Model Context Protocol (MCP) tools from an OpenAPI specification for @ttoss/http-server-mcp",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ttoss/http-server
|
|
40
|
-
"@ttoss/http-server": "^0.
|
|
39
|
+
"@ttoss/http-server": "^0.11.1",
|
|
40
|
+
"@ttoss/http-server-mcp": "^0.34.2"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@modelcontextprotocol/server": "^2.0.0",
|