Implement a TypeScript MCP task API server with dual interface modes and comprehensive task management features
The Task API Server - MCP TypeScript Implementation is a comprehensive Model Context Protocol (MCP) reference server designed to facilitate seamless integration with diverse AI applications and external task management APIs. This implementation adopts a dual interface approach, offering both STDIO and HTTP+SSE protocols for varying deployment scenarios. The server supports multiple operational modes, ensuring robustness and adaptability.
The server provides an extensive suite of task management functionalities, including listing tasks with custom filters, creating new tasks, updating task details, and deleting completed or outdated tasks. Each operation ensures data integrity through comprehensive validation mechanisms and sophisticated error handling.
The fully implemented MCP includes resource handling for task data structures, along with tools and error management features. The comprehensive test client ensures thorough validation of API responses, maintaining high standards in client-server communication.
To setup and run this server, you need Node.js 16.x or higher along with npm or pnpm. Follow these steps to get started:
npm
or pnpm
for package installation.Clone the Repository
git clone https://github.com/yourusername/mcp-template-ts.git
cd mcp-template-ts
Install Dependencies
npm install
pnpm install
Create .env File for Credentials
Add the necessary environment variables in a .env
file:
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 Ensure the latest code is compiled by running:
npm run build
Run the Server in Different Modes
For STDIO Mode (CLI/AI agents)
npm start
For HTTP Mode (web access)
npm run start:http
By default, the HTTP server runs on port 3000. You can change this by setting TASK_MANAGER_HTTP_PORT
in your .env
file.
Suppose an developer wants to integrate a project management tool with multiple AI applications, including Claude Desktop and Continue. The Task API Server - MCP TypeScript Implementation can be used as the central bridge, supporting both STDIO and HTTP modes for versatile connectivity.
Another scenario involves a writer collaborating with an AI assistant to automate the documentation process. Here, the Task API Server handles updating task statuses and descriptions in near-real-time as documents are edited.
To connect an application using STDIO protocol, follow this TypeScript example:
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 operations
const listTasksResult = await client.callTool({
name: "listTasks",
arguments: { status: "pending" }
});
// Clean up
await client.close();
For browser-based clients, use the following JavaScript snippet:
<!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);
// Perform operation
const result = await client.callTool({
name: 'listTasks',
arguments: { status: "pending" }
});
console.log(result);
});
</script>
</head>
<body>
</body>
</html>
This example demonstrates calling the listTasks
tool with a specific argument—here, 'pending' tasks. Ensure to customize paths and other details as required.
graph TD
A[AI Application] -->|MCP Client| B[MCP Server]
B --> C[Data Source/Tool]
style A fill:#e1f5fe
style C fill:#f3e5f5
graph TD
subgraph "Data Flow"
A[Task] -->|Stored| D[Storage Layer]
B[Client] -->|Reads/Updates| E[MCP API Layer]
F["Database or External API"] -->|Access Point from MCP Server|
D --> F
style A fill:#e8f5e8
end
In this use case, the server is deployed within a company's project management ecosystem. Multiple developers and reviewers collaborate on a large-scale software development project using various AI tools and platforms. The Task API Server acts as the central integration point:
For a publishing house, the server is integrated with an AI-driven content creation platform. Authors and editors use this system for collaborative document writing:
Configuration of multiple servers or different modes might look like:
{
"mcpServers": {
"serverOne": {
"command": "npx",
"args": ["@modelcontextprotocol/server-stdio"],
"env": {
"API_KEY": "your-api-key-one"
}
},
"serverTwo": {
"command": "node",
"args": ["./dist/index.js"],
"env": {
"API_KEY": "your-api-key-two",
"MODE": "HTTP"
}
}
}
}
This JSON snippet configures two separate servers—one for STDIO and another for HTTP mode—with distinct API keys.
A: Configure the .env
file with API_KEY
required by Claude Desktop. Then run the server in STDIO mode, which is compatible out of the box.
A: No official setup exists; however, you can clone the repository and follow the steps outlined above to create your own test environment quickly.
A: Yes, but performance depends on how well the server is optimized. Consider scaling strategies such as load balancing if deploying to high-traffic environments.
A: The compatibility matrix indicates full support for Claude Desktop and Continue, while Cursor may lack some features like prompts or resources.
A: Detailed error handling and logging mechanisms are in place. Information messages are provided to both clients and servers for debugging purposes.
For developers looking to enhance this implementation, please refer to the project's CONTRIBUTING.md
file for guidelines on setting up your development environment, submitting bug reports, and feature requests.
The Task API Server - MCP TypeScript Implementation is part of a broader ecosystem supporting various AI tools. Explore other resources such as forums, documentation, and community projects to expand your understanding and capabilities in building intelligent applications through MCP integration.
This comprehensive documentation aims to assist developers in effectively integrating this server with their AI application ecosystems, emphasizing real-world applicability and technical depth.
RuinedFooocus is a local AI image generator and chatbot image server for seamless creative control
Simplify MySQL queries with Java-based MysqlMcpServer for easy standard input-output communication
Learn to set up MCP Airflow Database server for efficient database interactions and querying airflow data
Build stunning one-page websites track engagement create QR codes monetize content easily with Acalytica
Explore CoRT MCP server for advanced self-arguing AI with multi-LLM inference and enhanced evaluation methods
Access NASA APIs for space data, images, asteroids, weather, and exoplanets via MCP integration