atlas-mcp-server
Version:
ATLAS (Adaptive Task & Logic Automation System): An MCP server enabling LLM agents to manage projects, tasks, and knowledge via a Neo4j-backed, three-tier architecture. Facilitates complex workflow automation and project management through LLM Agents.
162 lines (161 loc) • 5.38 kB
JavaScript
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
import { logger, requestContextService } from "../../utils/index.js"; // Import requestContextService
/**
* Resource URIs for the Atlas MCP resources
*/
export const ResourceURIs = {
// Project resources
PROJECTS: "atlas://projects",
PROJECT_TEMPLATE: "atlas://projects/{projectId}",
// Task resources
TASKS: "atlas://tasks",
TASKS_BY_PROJECT: "atlas://projects/{projectId}/tasks",
TASK_TEMPLATE: "atlas://tasks/{taskId}",
// Knowledge resources
KNOWLEDGE: "atlas://knowledge",
KNOWLEDGE_BY_PROJECT: "atlas://projects/{projectId}/knowledge",
KNOWLEDGE_TEMPLATE: "atlas://knowledge/{knowledgeId}",
};
/**
* Resource templates for the Atlas MCP resources
*/
export const ResourceTemplates = {
// Project resource templates
PROJECT: new ResourceTemplate(ResourceURIs.PROJECT_TEMPLATE, {
list: () => ({
resources: [
{
uri: ResourceURIs.PROJECTS,
name: "All Projects",
description: "List of all projects in the Atlas platform",
},
],
}),
}),
// Task resource templates
TASK: new ResourceTemplate(ResourceURIs.TASK_TEMPLATE, {
list: () => ({
resources: [
{
uri: ResourceURIs.TASKS,
name: "All Tasks",
description: "List of all tasks in the Atlas platform",
},
],
}),
}),
TASKS_BY_PROJECT: new ResourceTemplate(ResourceURIs.TASKS_BY_PROJECT, {
list: undefined,
}),
// Knowledge resource templates
KNOWLEDGE: new ResourceTemplate(ResourceURIs.KNOWLEDGE_TEMPLATE, {
list: () => ({
resources: [
{
uri: ResourceURIs.KNOWLEDGE,
name: "All Knowledge",
description: "List of all knowledge items in the Atlas platform",
},
],
}),
}),
KNOWLEDGE_BY_PROJECT: new ResourceTemplate(ResourceURIs.KNOWLEDGE_BY_PROJECT, {
list: undefined,
}),
};
/**
* Convert Neo4j Project to Project Resource
*/
export function toProjectResource(project) {
const reqContext = requestContextService.createRequestContext({
operation: "toProjectResource",
projectId: project.id,
});
// Log the incoming project structure for debugging
logger.debug("Converting project to resource:", {
...reqContext,
projectData: project,
});
// Ensure all fields are properly extracted
const resource = {
id: project.id,
name: project.name,
description: project.description,
status: project.status,
urls: project.urls || [],
completionRequirements: project.completionRequirements,
outputFormat: project.outputFormat,
taskType: project.taskType,
createdAt: project.createdAt,
updatedAt: project.updatedAt,
};
logger.debug("Created project resource:", {
...reqContext,
projectResource: resource,
});
return resource;
}
/**
* Convert Neo4j Task (with added assignedToUserId) to Task Resource
*/
export function toTaskResource(task) {
const reqContext = requestContextService.createRequestContext({
operation: "toTaskResource",
taskId: task.id,
});
// Log the incoming task structure for debugging
logger.debug("Converting task to resource:", {
...reqContext,
taskData: task,
});
const resource = {
id: task.id,
projectId: task.projectId,
title: task.title,
description: task.description,
priority: task.priority,
status: task.status,
assignedTo: task.assignedToUserId, // Use assignedToUserId from the input object
urls: task.urls || [],
tags: task.tags || [],
completionRequirements: task.completionRequirements,
outputFormat: task.outputFormat,
taskType: task.taskType,
createdAt: task.createdAt,
updatedAt: task.updatedAt,
};
logger.debug("Created task resource:", {
...reqContext,
taskResource: resource,
});
return resource;
}
/**
* Convert Neo4j Knowledge (with added domain/citations) to Knowledge Resource
*/
export function toKnowledgeResource(knowledge) {
const reqContext = requestContextService.createRequestContext({
operation: "toKnowledgeResource",
knowledgeId: knowledge.id,
});
// Log the incoming knowledge structure for debugging
logger.debug("Converting knowledge to resource:", {
...reqContext,
knowledgeData: knowledge,
});
const resource = {
id: knowledge.id,
projectId: knowledge.projectId,
text: knowledge.text,
tags: knowledge.tags || [],
domain: knowledge.domain || "", // Use domain from the input object, default to empty string if null
citations: knowledge.citations || [], // Use citations from the input object
createdAt: knowledge.createdAt,
updatedAt: knowledge.updatedAt,
};
logger.debug("Created knowledge resource:", {
...reqContext,
knowledgeResource: resource,
});
return resource;
}