Skip to main content
Glama

MCP Test Server

by yvanfreitas
tasks.js3.98 kB
import { tasks } from '../data/mockData.js'; export class TaskService { static getAll(filters = {}) { let filteredTasks = tasks; if (filters.status) { filteredTasks = filteredTasks.filter(task => task.status === filters.status); } if (filters.assignedTo) { filteredTasks = filteredTasks.filter(task => task.assignedTo === filters.assignedTo); } return { success: true, data: filteredTasks, total: filteredTasks.length }; } static getById(id) { const task = tasks.find(t => t.id === id); if (!task) { return { success: false, message: 'Task not found' }; } return { success: true, data: task }; } static create(taskData) { const { title, status = 'pending', assignedTo } = taskData; if (!title) { return { success: false, message: 'Title is required' }; } const newTask = { id: Math.max(...tasks.map(t => t.id)) + 1, title, status, assignedTo: assignedTo || null }; tasks.push(newTask); return { success: true, message: 'Task created successfully', data: newTask }; } static update(id, taskData) { const taskIndex = tasks.findIndex(t => t.id === id); if (taskIndex === -1) { return { success: false, message: 'Task not found' }; } const { title, status, assignedTo } = taskData; const updatedTask = { ...tasks[taskIndex] }; if (title) updatedTask.title = title; if (status) updatedTask.status = status; if (assignedTo !== undefined) updatedTask.assignedTo = assignedTo ? parseInt(assignedTo) : null; tasks[taskIndex] = updatedTask; return { success: true, message: 'Task updated successfully', data: updatedTask }; } static search(query) { const searchTerm = query.toLowerCase(); return tasks.filter(task => task.title.toLowerCase().includes(searchTerm) ); } } // MCP Tool Schemas export const taskToolSchemas = [ { name: 'get_tasks', description: 'Get all tasks from the mock database', inputSchema: { type: 'object', properties: { status: { type: 'string', description: 'Filter tasks by status', enum: ['pending', 'in-progress', 'completed'] }, assignedTo: { type: 'number', description: 'Filter tasks by assigned user ID' } } } }, { name: 'get_task', description: 'Get a specific task by ID', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Task ID' } }, required: ['id'] } }, { name: 'create_task', description: 'Create a new task', inputSchema: { type: 'object', properties: { title: { type: 'string', description: 'Task title' }, status: { type: 'string', description: 'Task status', enum: ['pending', 'in-progress', 'completed'], default: 'pending' }, assignedTo: { type: 'number', description: 'ID of user assigned to this task' } }, required: ['title'] } }, { name: 'update_task', description: 'Update an existing task', inputSchema: { type: 'object', properties: { id: { type: 'number', description: 'Task ID' }, title: { type: 'string', description: 'Task title' }, status: { type: 'string', description: 'Task status', enum: ['pending', 'in-progress', 'completed'] }, assignedTo: { type: 'number', description: 'ID of user assigned to this task' } }, required: ['id'] } } ];

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yvanfreitas/MCP-test'

If you have feedback or need assistance with the MCP directory API, please join our Discord server