Skip to content

TypeScript MCP Server for Task Dispatch (replaces bash plugin) #7

@Olbrasoft

Description

@Olbrasoft

Summary

Create a TypeScript MCP server that provides task dispatch functionality for Claude Code, replacing the bash-based plugin approach.

User Story

As a Claude Code user, I want task dispatch functionality via MCP tools, so that Claude can fetch pending tasks and report completion without bash scripts.

Context

Current State (to be removed)

Claude Code → bash hooks → psql → PostgreSQL  ❌

Target Architecture

┌─────────────┐     ┌──────────────────┐     ┌─────────────────────┐     ┌────────────┐
│ Claude Code │ ←→  │ TypeScript       │ ←→  │ VirtualAssistant    │ ←→  │ PostgreSQL │
│             │     │ MCP Server       │     │ (C# .NET API)       │     │            │
└─────────────┘     └──────────────────┘     └─────────────────────┘     └────────────┘
                    HTTP calls              Entity Framework

Technology Stack (simplified)

  • C# .NET - VirtualAssistant API + database access (existing)
  • TypeScript - MCP server for Claude Code (new)
  • No bash scripts

Why MCP Server instead of Hooks?

  1. Cleaner architecture - MCP is the standard way for Claude to interact with external services
  2. No bash - Pure TypeScript, type-safe, testable
  3. Flexible - Claude can call tools anytime, not just on SessionStart/Stop
  4. Reusable - Same MCP server can be used by multiple Claude instances

Requirements

Must Have

  • Create TypeScript MCP server project
  • Implement get_pending_task tool
  • Implement complete_task tool
  • Configure server in Claude Code settings
  • Remove old bash plugin (plugins/task-dispatch/scripts/)

Should Have

  • Error handling for API failures
  • Timeout configuration
  • Logging for debugging

Technical Specification

MCP Server Location

~/mcp-servers/task-dispatch/
├── src/
│   ├── index.ts           # MCP server entry point
│   ├── tools/
│   │   ├── get-pending-task.ts
│   │   └── complete-task.ts
│   ├── api-client.ts      # HTTP client for VirtualAssistant
│   └── types.ts           # TypeScript interfaces
├── package.json
├── tsconfig.json
└── README.md

MCP Tools

get_pending_task

Fetches the oldest pending task for Claude agent.

Input: None

Output:

interface PendingTaskResult {
  found: boolean;
  task?: {
    id: number;
    githubIssueUrl: string;
    githubIssueNumber: number;
    summary: string;
    createdAt: string;
  };
  message: string;
}

Implementation:

// Calls GET http://localhost:5055/api/claude/tasks/pending
// Returns task data or "No pending tasks" message

complete_task

Marks a task as completed with result summary.

Input:

interface CompleteTaskInput {
  taskId: number;
  result: string;
  sessionId?: string;
}

Output:

interface CompleteTaskResult {
  success: boolean;
  taskId: number;
  status: string;
  completedAt: string;
  message: string;
}

Implementation:

// Calls POST http://localhost:5055/api/claude/tasks/{id}/complete
// Body: { sessionId, result }

Claude Code Configuration

Add to ~/.claude/settings.json:

{
  "mcpServers": {
    "task-dispatch": {
      "command": "node",
      "args": ["~/mcp-servers/task-dispatch/dist/index.js"],
      "env": {
        "API_URL": "http://localhost:5055"
      }
    }
  }
}

VirtualAssistant API (already implemented)

Endpoints in VirtualAssistant repo (issue #214):

  • GET /api/claude/tasks/pending
  • POST /api/claude/tasks/{id}/complete

Acceptance Criteria

  • Given MCP server is running, when Claude uses get_pending_task tool, then it returns pending task or "no tasks" message
  • Given a pending task exists, when get_pending_task is called, then task is marked as sent in database
  • Given valid task ID and result, when complete_task is called, then task is marked as completed
  • Given API is unreachable, when tools are called, then appropriate error is returned
  • Given old bash plugin exists, when this is implemented, then bash scripts are removed

Out of Scope

  • Auto-dispatch on session start (Claude will call tools manually or via prompts)
  • WebSocket real-time notifications
  • Authentication/authorization

Related

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions