Sunsama
STDIOSunsama任务管理MCP服务器
Sunsama任务管理MCP服务器
A Model Context Protocol (MCP) server that provides comprehensive task management capabilities through the Sunsama API. This server enables AI assistants to access Sunsama tasks, create new tasks, mark tasks complete, and manage your productivity workflow.
No installation required! Use directly with:
npx mcp-sunsama
git clone https://github.com/robertn702/mcp-sunsama.git cd mcp-sunsama
bun install
cp .env.example .env # Edit .env and add your Sunsama credentials
Environment variables:
SUNSAMA_EMAIL - Your Sunsama account email (required for stdio transport)SUNSAMA_PASSWORD - Your Sunsama account password (required for stdio transport)TRANSPORT_MODE - Transport type: stdio (default) or httpPORT - Server port for HTTP transport (default: 8080)HTTP_ENDPOINT - MCP endpoint path (default: /mcp)SESSION_TTL - Session timeout in milliseconds (default: 3600000 / 1 hour)CLIENT_IDLE_TIMEOUT - Client idle timeout in milliseconds (default: 900000 / 15 minutes)MAX_SESSIONS - Maximum concurrent sessions for HTTP transport (default: 100)This server supports two transport modes:
For local AI assistants (Claude Desktop, Cursor, etc.):
bun run dev # or TRANSPORT_MODE=stdio bun run src/main.ts
For remote access and web-based integrations:
TRANSPORT_MODE=http PORT=8080 bun run src/main.ts
HTTP Endpoints:
POST http://localhost:8080/mcpGET http://localhost:8080/Authentication: HTTP requests require HTTP Basic Auth with your Sunsama credentials:
curl -X POST http://localhost:8080/mcp \ -H "Authorization: Basic $(echo -n 'your-email:your-password' | base64)" \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"tools/list","id":1}'
Add this configuration to your Claude Desktop MCP settings:
{ "mcpServers": { "sunsama": { "command": "npx", "args": ["mcp-sunsama"], "env": { "SUNSAMA_EMAIL": "[email protected]", "SUNSAMA_PASSWORD": "your-password" } } } }
create-task - Create new tasks with optional propertiesget-tasks-by-day - Get tasks for a specific day with completion filteringget-tasks-backlog - Get backlog tasksget-archived-tasks - Get archived tasks with pagination (includes hasMore flag for LLM context)get-task-by-id - Get a specific task by its IDupdate-task-complete - Mark tasks as completeupdate-task-planned-time - Update the planned time (time estimate) for tasksupdate-task-notes - Update task notes content (requires either html or markdown parameter, mutually exclusive)update-task-due-date - Update the due date for tasks (set or clear due dates)update-task-text - Update the text/title of tasksupdate-task-stream - Update the stream/channel assignment for tasksupdate-task-snooze-date - Reschedule tasks to different datesupdate-task-backlog - Move tasks to the backlogdelete-task - Delete tasks permanentlyget-user - Get current user informationget-streams - Get streams/channels for project organizationbun run dev
bun run inspect
Then connect the MCP Inspector to test the tools interactively.
bun test # Run unit tests only bun test:unit # Run unit tests only (alias) bun test:integration # Run integration tests (requires credentials) bun test:all # Run all tests bun test:watch # Watch mode for unit tests
bun run build # Compile TypeScript to dist/ bun run typecheck # Run TypeScript type checking bun run typecheck:watch # Watch mode type checking
For information on creating releases and publishing to npm, see CONTRIBUTING.md.
The server is organized with a modular, resource-based architecture:
src/
├── tools/
│   ├── shared.ts          # Common utilities and patterns
│   ├── user-tools.ts      # User operations (get-user)
│   ├── task-tools.ts      # Task operations (14 tools)
│   ├── stream-tools.ts    # Stream operations (get-streams)
│   └── index.ts           # Export all tools
├── resources/
│   └── index.ts           # API documentation resource
├── auth/                  # Authentication strategies
│   ├── stdio.ts           # Stdio transport authentication
│   ├── http.ts            # HTTP Basic Auth parsing
│   └── types.ts           # Shared auth types
├── transports/
│   ├── stdio.ts           # Stdio transport implementation
│   └── http.ts            # HTTP Stream transport with session management
├── session/
│   └── session-manager.ts # Session lifecycle management
├── config/                # Environment configuration
│   ├── transport.ts       # Transport mode configuration
│   └── session-config.ts  # Session TTL configuration
├── utils/                 # Utilities (filtering, trimming, etc.)
│   ├── client-resolver.ts # Transport-agnostic client resolution
│   ├── task-filters.ts    # Task completion filtering
│   ├── task-trimmer.ts    # Response size optimization
│   └── to-tsv.ts          # TSV formatting utilities
├── schemas.ts             # Zod validation schemas
└── main.ts                # Server setup (47 lines vs 1162 before refactoring)
__tests__/
├── unit/                  # Unit tests (no auth required)
│   ├── auth/              # Auth utility tests
│   ├── config/            # Configuration tests
│   └── session/           # Session management tests
└── integration/           # Integration tests (requires credentials)
    └── http-transport.test.ts
Key Features:
Stdio Transport: Requires SUNSAMA_EMAIL and SUNSAMA_PASSWORD environment variables.
HTTP Transport: Credentials provided via HTTP Basic Auth per request. No environment variables needed for credentials.
We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines on:
Quick start:
bun installbun run changesetThis project is licensed under the MIT License - see the LICENSE file for details.