onerios-mcp-server
Version:
OneriosMCP server providing memory, backlog management, file operations, and utility functions for enhanced AI assistant capabilities
262 lines (261 loc) • 9.86 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backlogManager = exports.backlogTools = void 0;
const zod_1 = require("zod");
const backlog_manager_js_1 = require("./backlog-manager.js");
// Schema definitions for validation
const CreateIssueSchema = zod_1.z.object({
name: zod_1.z.string().min(1, 'Issue name is required'),
description: zod_1.z.string().optional().default(''),
status: zod_1.z.nativeEnum(backlog_manager_js_1.IssueStatus).optional().default(backlog_manager_js_1.IssueStatus.NEW)
});
const SelectIssueSchema = zod_1.z.object({
name: zod_1.z.string().min(1, 'Issue name is required')
});
const InitializeIssueSchema = zod_1.z.object({
name: zod_1.z.string().min(1, 'Issue name is required'),
description: zod_1.z.string().optional().default(''),
status: zod_1.z.nativeEnum(backlog_manager_js_1.IssueStatus).optional().default(backlog_manager_js_1.IssueStatus.NEW)
});
const UpdateIssueStatusSchema = zod_1.z.object({
name: zod_1.z.string().min(1, 'Issue name is required'),
status: zod_1.z.nativeEnum(backlog_manager_js_1.IssueStatus)
});
const AddTaskSchema = zod_1.z.object({
title: zod_1.z.string().min(1, 'Task title is required'),
description: zod_1.z.string().optional().default('')
});
const ListTasksSchema = zod_1.z.object({
status: zod_1.z.nativeEnum(backlog_manager_js_1.TaskStatus).optional()
});
const UpdateTaskStatusSchema = zod_1.z.object({
taskId: zod_1.z.string().min(1, 'Task ID is required'),
status: zod_1.z.nativeEnum(backlog_manager_js_1.TaskStatus)
});
// Tool definitions for MCP
exports.backlogTools = [
{
name: 'backlog_create_issue',
description: 'Create a new issue in the backlog manager. Issues represent high-level features, bugs, or work items that need to be completed.',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'The name/title of the issue (required)',
},
description: {
type: 'string',
description: 'Detailed description of the issue (optional)',
},
status: {
type: 'string',
enum: Object.values(backlog_manager_js_1.IssueStatus),
description: 'Initial status of the issue (default: New)',
},
},
required: ['name'],
},
},
{
name: 'backlog_list_issues',
description: 'List all issues in the backlog with their status, task count, and active issue indicator.',
inputSchema: {
type: 'object',
properties: {},
},
},
{
name: 'backlog_select_issue',
description: 'Select an issue as the active issue for subsequent task operations. All task operations will be performed on the active issue.',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'The name of the issue to select as active',
},
},
required: ['name'],
},
},
{
name: 'backlog_initialize_issue',
description: 'Initialize or reset an issue, clearing all existing tasks. This is useful for starting fresh or resetting an issue.',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'The name of the issue to initialize',
},
description: {
type: 'string',
description: 'Description of the issue (optional)',
},
status: {
type: 'string',
enum: Object.values(backlog_manager_js_1.IssueStatus),
description: 'Initial status of the issue (default: New)',
},
},
required: ['name'],
},
},
{
name: 'backlog_update_issue_status',
description: 'Update the status of an existing issue (New, InWork, or Done).',
inputSchema: {
type: 'object',
properties: {
name: {
type: 'string',
description: 'The name of the issue to update',
},
status: {
type: 'string',
enum: Object.values(backlog_manager_js_1.IssueStatus),
description: 'The new status for the issue',
},
},
required: ['name', 'status'],
},
},
{
name: 'backlog_add_task',
description: 'Add a new task to the currently active issue. Tasks represent specific work items needed to complete an issue.',
inputSchema: {
type: 'object',
properties: {
title: {
type: 'string',
description: 'The title of the task (required)',
},
description: {
type: 'string',
description: 'Detailed description of the task (optional)',
},
},
required: ['title'],
},
},
{
name: 'backlog_list_tasks',
description: 'List all tasks in the active issue, optionally filtered by status. Shows task details including ID, title, status, and description.',
inputSchema: {
type: 'object',
properties: {
status: {
type: 'string',
enum: Object.values(backlog_manager_js_1.TaskStatus),
description: 'Filter tasks by status (optional)',
},
},
},
},
{
name: 'backlog_update_task_status',
description: 'Update the status of a specific task in the active issue (New, InWork, or Done).',
inputSchema: {
type: 'object',
properties: {
taskId: {
type: 'string',
description: 'The ID of the task to update',
},
status: {
type: 'string',
enum: Object.values(backlog_manager_js_1.TaskStatus),
description: 'The new status for the task',
},
},
required: ['taskId', 'status'],
},
},
{
name: 'backlog_get_stats',
description: 'Get comprehensive statistics about the backlog including issue counts, task counts, status distributions, and active issue information.',
inputSchema: {
type: 'object',
properties: {},
},
},
];
// Handler functions for each tool
const toolHandlers = {
backlog_create_issue: async (args) => {
const { name, description, status } = CreateIssueSchema.parse(args);
const result = await (0, backlog_manager_js_1.createIssue)(name, description, status);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_list_issues: async () => {
const result = await (0, backlog_manager_js_1.listIssues)();
return {
content: [{ type: 'text', text: result }],
};
},
backlog_select_issue: async (args) => {
const { name } = SelectIssueSchema.parse(args);
const result = await (0, backlog_manager_js_1.selectIssue)(name);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_initialize_issue: async (args) => {
const { name, description, status } = InitializeIssueSchema.parse(args);
const result = await (0, backlog_manager_js_1.initializeIssue)(name, description, status);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_update_issue_status: async (args) => {
const { name, status } = UpdateIssueStatusSchema.parse(args);
const result = await (0, backlog_manager_js_1.updateIssueStatus)(name, status);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_add_task: async (args) => {
const { title, description } = AddTaskSchema.parse(args);
const result = await (0, backlog_manager_js_1.addTask)(title, description);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_list_tasks: async (args) => {
const { status } = ListTasksSchema.parse(args);
const result = await (0, backlog_manager_js_1.listTasks)(status);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_update_task_status: async (args) => {
const { taskId, status } = UpdateTaskStatusSchema.parse(args);
const result = await (0, backlog_manager_js_1.updateTaskStatus)(taskId, status);
return {
content: [{ type: 'text', text: result }],
};
},
backlog_get_stats: async () => {
const result = await (0, backlog_manager_js_1.getBacklogStats)();
return {
content: [{ type: 'text', text: result }],
};
},
};
// Module interface following the existing pattern
exports.backlogManager = {
getTools: () => exports.backlogTools,
hasHandler: (name) => {
return name in toolHandlers;
},
handleTool: async (name, args) => {
const handler = toolHandlers[name];
if (!handler) {
throw new Error(`Unknown backlog tool: ${name}`);
}
return handler(args);
},
};