@gluneau/hive-mcp-server
Version:
An MCP server that enables AI assistants to interact with the Hive blockchain
112 lines • 3.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.userQueryCategories = exports.tagQueryCategories = exports.beneficiariesSchema = exports.operationFilterSchema = exports.tagsSchema = void 0;
// Common schema components that can be reused across multiple tools
const zod_1 = require("zod");
// Schema for parsing tags from either array or comma-separated string
exports.tagsSchema = zod_1.z
.union([
zod_1.z.array(zod_1.z.string()),
zod_1.z.string().transform((val, ctx) => {
// Handle empty string
if (!val.trim())
return ['blog'];
try {
// Try to parse it as JSON first in case it's a properly formatted JSON array
if (val.startsWith('[') && val.endsWith(']')) {
try {
const parsed = JSON.parse(val);
if (Array.isArray(parsed)) {
return parsed;
}
}
catch (e) {
// Failed to parse as JSON, continue to other methods
}
}
// Handle comma-separated list (possibly with quotes)
return val
.replace(/^\[|\]$/g, '') // Remove outer brackets if present
.split(',')
.map((item) => item
.trim()
.replace(/^['"]|['"]$/g, '') // Remove surrounding quotes
.toLowerCase() // Hive tags are lowercase
)
.filter(Boolean); // Remove empty entries
}
catch (error) {
ctx.addIssue({
code: zod_1.z.ZodIssueCode.custom,
message: `Could not parse tags: ${val}. Please provide a comma-separated list or array of tags.`,
});
return zod_1.z.NEVER;
}
}),
])
.default(['blog']);
// Schema for operation filter parameter
exports.operationFilterSchema = zod_1.z
.union([
zod_1.z.array(zod_1.z.string()),
zod_1.z.string().transform((val, ctx) => {
// Handle empty string
if (!val.trim())
return [];
try {
// Try to parse it as JSON first in case it's a properly formatted JSON array
if (val.startsWith('[') && val.endsWith(']')) {
try {
const parsed = JSON.parse(val);
if (Array.isArray(parsed)) {
return parsed;
}
}
catch (e) {
// Failed to parse as JSON, continue to other methods
}
}
// Handle comma-separated list (possibly with quotes)
return val
.replace(/^\[|\]$/g, '') // Remove outer brackets if present
.split(',')
.map((item) => item.trim().replace(/^['"]|['"]$/g, '') // Remove surrounding quotes
)
.filter(Boolean); // Remove empty entries
}
catch (error) {
ctx.addIssue({
code: zod_1.z.ZodIssueCode.custom,
message: `Could not parse operation_filter: ${val}. Please provide a comma-separated list or array of operation types.`,
});
return zod_1.z.NEVER;
}
}),
])
.optional();
// Schema for beneficiaries
exports.beneficiariesSchema = zod_1.z
.union([
zod_1.z.array(zod_1.z.object({
account: zod_1.z.string(),
weight: zod_1.z.number().min(1).max(10000),
})),
zod_1.z.null(),
])
.optional()
.nullable();
// Export valid discussion query categories
exports.tagQueryCategories = zod_1.z.enum([
'active',
'cashout',
'children',
'comments',
'created',
'hot',
'promoted',
'trending',
'votes',
]);
// Export valid user-based query categories
exports.userQueryCategories = zod_1.z.enum(['blog', 'feed']);
//# sourceMappingURL=common.js.map