@atlassian/mcp-compressor 0.29.1 → 0.31.0-alpha.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/dist/local_tools.js
CHANGED
|
@@ -12,6 +12,29 @@ function asJsonSchema(schema, adapter) {
|
|
|
12
12
|
}
|
|
13
13
|
throw new Error("Tool inputSchema must be a JSON schema object or schemaAdapter must be provided");
|
|
14
14
|
}
|
|
15
|
+
const TOOL_INPUT_SCHEMA_DESCRIPTION = "JSON object matching the selected tool's input schema. Use get_tool_schema for the selected tool_name before invoking if required fields are unknown.";
|
|
16
|
+
function isRecord(value) {
|
|
17
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
18
|
+
}
|
|
19
|
+
function requiredFieldNames(schema) {
|
|
20
|
+
const required = schema.required;
|
|
21
|
+
if (!Array.isArray(required))
|
|
22
|
+
return [];
|
|
23
|
+
return required.filter((field) => typeof field === "string");
|
|
24
|
+
}
|
|
25
|
+
function validateRequiredToolInput(spec, toolInput) {
|
|
26
|
+
const required = requiredFieldNames(spec.inputSchema);
|
|
27
|
+
if (required.length === 0)
|
|
28
|
+
return;
|
|
29
|
+
const input = isRecord(toolInput) ? toolInput : {};
|
|
30
|
+
const missing = required.filter((field) => !Object.hasOwn(input, field));
|
|
31
|
+
if (missing.length === 0)
|
|
32
|
+
return;
|
|
33
|
+
throw new Error(`Tool \`${spec.name}\` is missing required tool_input fields: ${missing.join(", ")}. ` +
|
|
34
|
+
"tool_input must be a JSON object matching the selected tool's input schema. " +
|
|
35
|
+
`Call get_tool_schema with tool_name=\`${spec.name}\` and retry with tool_input matching this schema:\n` +
|
|
36
|
+
JSON.stringify(spec.inputSchema, null, 2));
|
|
37
|
+
}
|
|
15
38
|
function normalizeResult(value, toonify) {
|
|
16
39
|
const json = stringifyToolResult(value);
|
|
17
40
|
if (!toonify)
|
|
@@ -66,7 +89,7 @@ export function compressTools(tools, options = {}) {
|
|
|
66
89
|
tool_name: { type: "string", description: "Name of the tool" },
|
|
67
90
|
tool_input: {
|
|
68
91
|
type: "object",
|
|
69
|
-
description:
|
|
92
|
+
description: TOOL_INPUT_SCHEMA_DESCRIPTION,
|
|
70
93
|
properties: {},
|
|
71
94
|
additionalProperties: true,
|
|
72
95
|
},
|
|
@@ -75,10 +98,13 @@ export function compressTools(tools, options = {}) {
|
|
|
75
98
|
},
|
|
76
99
|
execute: async (input = {}) => {
|
|
77
100
|
const toolName = String(input.tool_name ?? "");
|
|
101
|
+
const spec = specByName.get(toolName);
|
|
78
102
|
const tool = toolByName.get(toolName);
|
|
79
|
-
if (!tool)
|
|
103
|
+
if (!spec || !tool)
|
|
80
104
|
throw new Error(`Tool not found: ${toolName}`);
|
|
81
|
-
const
|
|
105
|
+
const toolInput = input.tool_input ?? {};
|
|
106
|
+
validateRequiredToolInput(spec, toolInput);
|
|
107
|
+
const output = await tool.execute(toolInput);
|
|
82
108
|
return normalizeResult(output, options.toonify ?? false);
|
|
83
109
|
},
|
|
84
110
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlassian/mcp-compressor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0-alpha.1",
|
|
4
4
|
"description": "TypeScript MCP server wrapper for reducing tokens consumed by MCP tools.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/atlassian-labs/mcp-compressor",
|