Token导航 LogoToken导航TokenDH.com
Task API Server logo
AI代理SSE官方级别未说明来源级核验

Task API Server

MCP Server

一个基于TypeScript实现的任务管理API服务器,提供标准化的任务管理接口,支持STDIO和HTTP+SSE两种运行模式。

工具数

0

提示词数

0

GitHub Stars

11

资源数

0
API集成JavaScript任务管理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

milkosten

提供方

milkosten

最后核验

2026/5/17 20:32

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

任务API服务器-MCP类型脚本实现

用TypeScript编写的用于任务管理API的模型上下文协议(MCP)实现。该项目既是参考实现,也是功能任务管理服务器。

概述

此MCP服务器连接到外部任务API服务,并为任务管理提供标准化接口。它支持两种运行时模式:

  1. STDIO模式:基于CLI的应用程序和AI代理的标准输入/输出通信
  2. HTTP+SSE模式:可通过Web访问的服务器,为浏览器和基于HTTP的客户端提供服务器发送事件

该服务器提供了一套完整的任务管理操作、广泛的验证和强大的错误处理。

特性

  • 任务管理操作:

- 列出具有过滤功能的现有任务 - 创建具有可自定义属性的新任务 - 更新任务详细信息(描述、状态、类别、优先级) - 完成或不再需要时删除任务

  • 双界面模式:

- STDIO协议支持命令行和AI代理集成 - HTTP+SSE协议,具有基于浏览器的web界面访问

  • MCP协议实现:

- 模型上下文协议的完整实现 - 任务数据结构的资源 - 任务操作工具 - 错误处理和信息性消息

  • 质量保证:

- 用于验证的综合测试客户端 - 测试完成后自动关闭服务器 - API响应的详细验证

入门指南

先决条件

  • Node.js 16.x或更高版本
  • npm或pnpm包管理器

安装

  1. 克隆存储库:
   git clone https://github.com/yourusername/mcp-template-ts.git
   cd mcp-template-ts
  1. 安装依赖项:
   npm install

或使用pnpm:

   pnpm install
  1. 创建一个 .env 使用您的任务API凭据的文件:
   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
  1. 构建项目:
   npm run build

运行服务器

STDIO模式(用于CLI/AI集成)

npm start

node dist/index.js

HTTP模式(用于web访问)

npm run start:http

node dist/http-server.js

默认情况下,HTTP服务器在端口3000上运行。您可以通过设置 TASK_MANAGER_HTTP_PORT 环境变量。

测试

运行综合测试套件以验证功能:

npm test

这将:

  1. 构建项目
  2. 启动服务器实例
  3. 将测试客户端连接到服务器
  4. 执行所有任务操作
  5. 验证正确的回答
  6. 自动关闭服务器

使用MCP客户端

STDIO客户端

要从应用程序连接到STDIO服务器,请执行以下操作:

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();

HTTP客户端

要从浏览器连接到HTTP服务器,请执行以下操作:


  Task Manager
  
    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
    });
  

  
Task Manager

  

可用工具

列表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
  }
});

创建任务

创建新任务。

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
  }
});

updateTask

更新现有任务。

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
  }
});

删除任务

删除任务。

const result = await client.callTool({
  name: "deleteTask",
  arguments: {
    taskId: 123  // Required: ID of task to delete
  }
});

环境变量

变量描述默认值
TASK_MANAGER_API_BASE_URL外部任务API的URL无(必需)
TASK_MANAGER_API_KEY用于身份验证的API密钥无(必需)
TASK_MANAGER_HTTP_PORTHTTP服务器的端口3000
PORT备用端口名(优先)

项目结构

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

发展

  1. 在监视模式下启动TypeScript编译器:
   npm run watch
  1. 运行测试以验证更改:
   npm test

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

致谢

目录标签

目录标签

API集成JavaScript任务管理本地部署API服务器TypeScriptMCP协议双接口模式

接入字段

传输方式(transport,传输协议)

SSE

鉴权方式(authType,认证方式)

none

部署方式(deploymentType,部署类型)

remote-capable

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

SSEnoneremote-capable

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP