Task Management
STDIOMCP implementation for Task Management API written in TypeScript.
MCP implementation for Task Management API written in TypeScript.
A Model Context Protocol (MCP) implementation for Task Management API written in TypeScript. This project serves as both a reference implementation and a functional task management server.
This MCP server connects to an external Task API service and provides a standardized interface for task management. It supports two runtime modes:
The server offers a complete set of task management operations, extensive validation, and robust error handling.
Task Management Operations:
Dual Interface Modes:
MCP Protocol Implementation:
Quality Assurance:
Clone the repository:
git clone https://github.com/yourusername/mcp-template-ts.git
cd mcp-template-ts
Install dependencies:
npm install
or using pnpm:
pnpm install
Create an .env
file with your Task API credentials:
TASK_MANAGER_API_BASE_URL=https://your-task-api-url.com/api
TASK_MANAGER_API_KEY=your_api_key_here
TASK_MANAGER_HTTP_PORT=3000
Build the project:
npm run build
npm start
or
node dist/index.js
npm run start:http
or
node dist/http-server.js
By default, the HTTP server runs on port 3000. You can change this by setting the TASK_MANAGER_HTTP_PORT
environment variable.
Run the comprehensive test suite to verify functionality:
npm test
This will:
To connect to the STDIO server from your application:
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; import * as path from 'path'; // Create transport const transport = new StdioClientTransport({ command: 'node', args: [path.resolve('path/to/dist/index.js')] }); // Initialize client const client = new Client( { name: "your-client-name", version: "1.0.0" }, { capabilities: { prompts: {}, resources: {}, tools: {} } } ); // Connect to server await client.connect(transport); // Example: List all tasks const listTasksResult = await client.callTool({ name: "listTasks", arguments: {} }); // Example: Create a new task const createTaskResult = await client.callTool({ name: "createTask", arguments: { task: "Complete project documentation", category: "Documentation", priority: "high" } }); // Clean up when done await client.close();
To connect to the HTTP server from a browser:
<!DOCTYPE html> <html> <head> <title>Task Manager</title> <script type="module"> import { Client } from 'https://cdn.jsdelivr.net/npm/@modelcontextprotocol/sdk/dist/esm/client/index.js'; import { SSEClientTransport } from 'https://cdn.jsdelivr.net/npm/@modelcontextprotocol/sdk/dist/esm/client/sse.js'; document.addEventListener('DOMContentLoaded', async () => { // Create transport const transport = new SSEClientTransport('http://localhost:3000/mcp'); // Initialize client const client = new Client( { name: "browser-client", version: "1.0.0" }, { capabilities: { prompts: {}, resources: {}, tools: {} } } ); // Connect to server await client.connect(transport); // Now you can use client.callTool() for tasks }); </script> </head> <body> <h1>Task Manager</h1> <!-- Your interface elements here --> </body> </html>
Lists all available tasks.
const result = await client.callTool({ name: "listTasks", arguments: { // Optional filters status: "pending", // Filter by status category: "Work", // Filter by category priority: "high" // Filter by priority } });
Creates a new task.
const result = await client.callTool({ name: "createTask", arguments: { task: "Complete the project report", // Required: task description category: "Work", // Optional: task category priority: "high" // Optional: low, medium, high } });
Updates an existing task.
const result = await client.callTool({ name: "updateTask", arguments: { taskId: 123, // Required: ID of task to update task: "Updated task description", // Optional: new description status: "done", // Optional: pending, started, done category: "Personal", // Optional: new category priority: "medium" // Optional: low, medium, high } });
Deletes a task.
const result = await client.callTool({ name: "deleteTask", arguments: { taskId: 123 // Required: ID of task to delete } });
Variable | Description | Default |
---|---|---|
TASK_MANAGER_API_BASE_URL | URL for the external Task API | None (Required) |
TASK_MANAGER_API_KEY | API key for authentication | None (Required) |
TASK_MANAGER_HTTP_PORT | Port for the HTTP server | 3000 |
PORT | Alternative port name (takes precedence) | None |
mcp-template-ts/
├── dist/ # Compiled JavaScript files
├── src/ # TypeScript source files
│ ├── index.ts # STDIO server entry point
│ ├── http-server.ts # HTTP+SSE server entry point
│ ├── test-client.ts # Test client implementation
├── .env # Environment variables
├── package.json # Project dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
Start the TypeScript compiler in watch mode:
npm run watch
Run tests to verify changes:
npm test
This project is licensed under the MIT License - see the LICENSE file for details.