@t3ratech/market-pulse-mcp 1.0.0
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/.claude-plugin/marketplace.json +15 -0
- package/.claude-plugin/plugin.json +17 -0
- package/LICENSE +202 -0
- package/NOTICE +24 -0
- package/README.md +132 -0
- package/agent-skills/market-pulse/SKILL.md +79 -0
- package/package.json +63 -0
- package/src/client.js +58 -0
- package/src/config.js +50 -0
- package/src/server.js +147 -0
- package/src/tools.js +12 -0
- package/src/tools.json +693 -0
- package/src/validate.js +35 -0
package/src/validate.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The published schema is the contract on every path. A wrong argument is refused by
|
|
2
|
+
// name, with the values that would work, before any network call is made — never
|
|
3
|
+
// coerced into a plausible answer (an empty list reads to a model as "there are none").
|
|
4
|
+
|
|
5
|
+
export function validateToolArgs(tool, args) {
|
|
6
|
+
if (args === null || typeof args !== "object" || Array.isArray(args)) {
|
|
7
|
+
return `${tool.name}: arguments must be a JSON object`;
|
|
8
|
+
}
|
|
9
|
+
const schema = tool.inputSchema || {};
|
|
10
|
+
const props = schema.properties || {};
|
|
11
|
+
for (const req of schema.required || []) {
|
|
12
|
+
if (args[req] === undefined || args[req] === null || args[req] === "") {
|
|
13
|
+
return `${tool.name}: "${req}" is required (${props[req]?.description || "no description"})`;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
for (const [key, value] of Object.entries(args)) {
|
|
17
|
+
const prop = Object.hasOwn(props, key) ? props[key] : undefined;
|
|
18
|
+
if (!prop) return `${tool.name}: unknown argument "${key}". Accepted: ${Object.keys(props).join(", ") || "none"}`;
|
|
19
|
+
if (value === undefined) continue;
|
|
20
|
+
if (value === null) return `${tool.name}: "${key}" must be ${prop.type === "integer" ? "an integer" : `a ${prop.type}`}, got null — omit the argument instead of passing null`;
|
|
21
|
+
if (prop.type === "boolean" && typeof value !== "boolean") {
|
|
22
|
+
return `${tool.name}: "${key}" must be a JSON boolean (true or false), got ${JSON.stringify(value)} — a quoted string reads as true and returns the opposite set`;
|
|
23
|
+
}
|
|
24
|
+
if (prop.type === "integer") {
|
|
25
|
+
if (!Number.isInteger(value)) return `${tool.name}: "${key}" must be an integer, got ${JSON.stringify(value)}`;
|
|
26
|
+
if (prop.minimum !== undefined && value < prop.minimum) return `${tool.name}: "${key}" must be an integer >= ${prop.minimum}, got ${value}`;
|
|
27
|
+
if (prop.maximum !== undefined && value > prop.maximum) return `${tool.name}: "${key}" must be an integer <= ${prop.maximum}, got ${value}`;
|
|
28
|
+
}
|
|
29
|
+
if (prop.type === "string" && typeof value !== "string") return `${tool.name}: "${key}" must be a string, got ${JSON.stringify(value)}`;
|
|
30
|
+
if (Array.isArray(prop.enum) && !prop.enum.includes(value)) {
|
|
31
|
+
return `${tool.name}: "${key}" must be one of: ${prop.enum.join(", ")} — got ${JSON.stringify(value)}`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|