@segosolutions/mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,233 @@
1
+ # Sego PM MCP Server
2
+
3
+ Model Context Protocol (MCP) server for [Sego PM](https://sego.pm) task management. This server allows Claude (or any MCP-compatible AI) to interact with your Sego PM tasks - query tasks, update statuses, add comments, create projects from codebases, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @sego/mcp-server
9
+ ```
10
+
11
+ Or use npx directly:
12
+
13
+ ```bash
14
+ npx @sego/mcp-server
15
+ ```
16
+
17
+ ## Prerequisites
18
+
19
+ 1. **Sego PM Account** - Sign up at https://sego.pm
20
+ 2. **API Key** - Generate from Developer Dashboard → API Keys
21
+ 3. **Node.js 18+**
22
+
23
+ ## Quick Start
24
+
25
+ ### 1. Get Your API Key
26
+
27
+ 1. Log into Sego PM at https://sego.pm
28
+ 2. Navigate to Developer Dashboard → API Keys
29
+ 3. Click "Create New API Key"
30
+ 4. Copy the key (format: `sk_dev_XXXX...`)
31
+
32
+ ### 2. Configure Claude Desktop
33
+
34
+ Add to your Claude Desktop config file:
35
+
36
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
37
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "sego-pm": {
43
+ "command": "npx",
44
+ "args": ["-y", "@sego/mcp-server"],
45
+ "env": {
46
+ "SEGO_API_KEY": "sk_dev_your_api_key_here",
47
+ "SEGO_API_URL": "https://sego.pm"
48
+ }
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ ### 3. Restart Claude Desktop
55
+
56
+ The MCP server will connect automatically on startup.
57
+
58
+ ## Environment Variables
59
+
60
+ | Variable | Required | Default | Description |
61
+ |----------|----------|---------|-------------|
62
+ | `SEGO_API_KEY` | Yes | - | Your Sego PM API key |
63
+ | `SEGO_API_URL` | No | `http://localhost:3000` | Sego PM API URL |
64
+
65
+ You can also use a `.env` file in your project directory.
66
+
67
+ ## Available Tools
68
+
69
+ ### Task Management
70
+
71
+ #### `get_my_tasks`
72
+ Get tasks assigned to you, optionally filtered by project or status.
73
+
74
+ ```
75
+ Show me all my tasks in progress
76
+ ```
77
+
78
+ #### `search_tasks`
79
+ Search tasks by keyword in title, description, or technical notes.
80
+
81
+ ```
82
+ Search for tasks related to authentication
83
+ ```
84
+
85
+ #### `update_task_status`
86
+ Update the status of a task (with workflow validation).
87
+
88
+ ```
89
+ Move task abc123 to in progress
90
+ ```
91
+
92
+ #### `add_task_comment`
93
+ Add a comment to a task (supports markdown).
94
+
95
+ ```
96
+ Add a comment to task abc123 saying "Implemented basic auth flow"
97
+ ```
98
+
99
+ #### `assign_task`
100
+ Assign a task to yourself or another user.
101
+
102
+ ```
103
+ Assign task abc123 to me
104
+ ```
105
+
106
+ ### Client Requests
107
+
108
+ #### `get_client_request`
109
+ Get a client request with all associated tasks and context.
110
+
111
+ #### `search_client_requests`
112
+ Search client requests by project, status, or keyword.
113
+
114
+ ### Projects
115
+
116
+ #### `create_project_from_codebase`
117
+ Create a Sego PM project from a local codebase with CLAUDE.md file. Auto-extracts project name, description, and tech stack.
118
+
119
+ ```
120
+ Create a Sego PM project from this codebase
121
+ ```
122
+
123
+ ## Available Resources
124
+
125
+ ### Task Detail
126
+ URI: `sego://tasks/{taskId}`
127
+
128
+ Get detailed information about a specific task including comments and full context.
129
+
130
+ ### Client Request Detail
131
+ URI: `sego://client-requests/{requestId}`
132
+
133
+ Get detailed information about a client request including all associated tasks.
134
+
135
+ ## Usage Examples
136
+
137
+ ### Daily Standup
138
+ ```
139
+ Claude, give me a summary of my tasks:
140
+ - What's in progress?
141
+ - What's blocked?
142
+ - What's in review?
143
+ ```
144
+
145
+ ### Working on a Task
146
+ ```
147
+ I'm working on the password reset task.
148
+ Move it to in progress and show me the full details.
149
+ ```
150
+
151
+ ### Completing Work
152
+ ```
153
+ I've finished the user export feature in task xyz789.
154
+ Add a comment with what I did and move it to in review.
155
+ ```
156
+
157
+ ### Creating a Project
158
+ ```
159
+ Create a Sego PM project from this codebase.
160
+ My CLAUDE.md file is in the project root.
161
+ ```
162
+
163
+ ## Task Status Workflow
164
+
165
+ Valid transitions:
166
+ - `AI_REVIEW` → `DRAFT`, `BACKLOG`, `CANCELLED`
167
+ - `DRAFT` → `BACKLOG`, `CANCELLED`
168
+ - `BACKLOG` → `IN_PROGRESS`, `CANCELLED`
169
+ - `IN_PROGRESS` → `IN_REVIEW`, `BLOCKED`, `BACKLOG`
170
+ - `BLOCKED` → `IN_PROGRESS`, `BACKLOG`
171
+ - `IN_REVIEW` → `COMPLETED`, `IN_PROGRESS`
172
+ - `COMPLETED` → (terminal)
173
+ - `CANCELLED` → (terminal)
174
+
175
+ ## Development
176
+
177
+ ### Local Development
178
+
179
+ ```bash
180
+ # Clone the repo
181
+ git clone https://github.com/sego-solutions/sego-pm
182
+ cd sego-pm/mcp-server
183
+
184
+ # Install dependencies
185
+ npm install
186
+
187
+ # Set up environment
188
+ cp .env.example .env
189
+ # Edit .env with your API key
190
+
191
+ # Run in development mode
192
+ npm run dev
193
+
194
+ # Build
195
+ npm run build
196
+
197
+ # Run built version
198
+ npm start
199
+ ```
200
+
201
+ ### Testing
202
+
203
+ ```bash
204
+ # Type checking
205
+ npm run typecheck
206
+ ```
207
+
208
+ ## Troubleshooting
209
+
210
+ ### MCP Server Not Connecting
211
+
212
+ 1. Check API key is valid and not expired
213
+ 2. Verify SEGO_API_URL is correct
214
+ 3. Check Claude Desktop logs:
215
+ - macOS: `~/Library/Logs/Claude/`
216
+ - Windows: `%APPDATA%\Claude\logs\`
217
+
218
+ ### Invalid Status Transition
219
+
220
+ Tasks must follow the workflow (e.g., can't jump from BACKLOG to COMPLETED directly).
221
+
222
+ ### Permission Denied
223
+
224
+ Only tasks you're assigned to or created are accessible.
225
+
226
+ ## Support
227
+
228
+ - Documentation: https://sego.pm/docs
229
+ - Issues: https://github.com/sego-solutions/sego-pm/issues
230
+
231
+ ## License
232
+
233
+ MIT - See [LICENSE](LICENSE)
@@ -0,0 +1,202 @@
1
+ /**
2
+ * Sego PM API Client
3
+ *
4
+ * HTTP client for communicating with the Sego PM web application.
5
+ * Used by MCP server tools to access data via API instead of direct database.
6
+ */
7
+ export interface McpUser {
8
+ id: string;
9
+ email: string;
10
+ name: string | null;
11
+ role: string;
12
+ }
13
+ export interface ProjectMembership {
14
+ projectId: string;
15
+ role: string;
16
+ }
17
+ export interface Project {
18
+ id: string;
19
+ name: string;
20
+ description: string | null;
21
+ status?: string;
22
+ }
23
+ export interface UserInfo {
24
+ id: string;
25
+ name: string | null;
26
+ email: string;
27
+ }
28
+ export interface Task {
29
+ id: string;
30
+ title: string;
31
+ description: string;
32
+ status: string;
33
+ priority: string;
34
+ type: string;
35
+ estimatedHours: string | null;
36
+ actualHours: string | null;
37
+ acceptanceCriteria: string[];
38
+ technicalNotes: string | null;
39
+ questionsForClient: string[];
40
+ aiConfidence: number | null;
41
+ clientVisible: boolean;
42
+ clientRequestId?: string | null;
43
+ dueDate: string | null;
44
+ completedAt: string | null;
45
+ approvedAt?: string | null;
46
+ approvedById?: string | null;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ project: Project;
50
+ createdBy: UserInfo;
51
+ assignedTo: UserInfo | null;
52
+ comments?: Comment[];
53
+ }
54
+ export interface Comment {
55
+ id: string;
56
+ content: string;
57
+ createdAt: string;
58
+ user: UserInfo;
59
+ taskId?: string;
60
+ }
61
+ export interface ClientRequest {
62
+ id: string;
63
+ projectId: string;
64
+ description: string;
65
+ channel: string;
66
+ rawContent: string | null;
67
+ files?: string[];
68
+ status: string;
69
+ aiAnalysis: string | null;
70
+ aiConfidence: number | null;
71
+ createdById?: string;
72
+ createdAt: string;
73
+ updatedAt: string;
74
+ project: Project;
75
+ createdBy: UserInfo;
76
+ tasks: Task[];
77
+ }
78
+ export interface TaskFilters {
79
+ projectId?: string;
80
+ status?: string;
81
+ assignedToId?: string;
82
+ }
83
+ export interface ClientRequestFilters {
84
+ projectId?: string;
85
+ status?: string;
86
+ query?: string;
87
+ }
88
+ export interface UpdateTaskInput {
89
+ status?: string;
90
+ assignedToId?: string | null;
91
+ comment?: string;
92
+ }
93
+ export interface CreateProjectInput {
94
+ content: string;
95
+ projectName?: string;
96
+ monthlyHours?: number;
97
+ hourlyRate?: number;
98
+ claudeFilePath?: string;
99
+ }
100
+ export interface CreateProjectResult {
101
+ success: boolean;
102
+ project?: {
103
+ id: string;
104
+ name: string;
105
+ description: string | null;
106
+ techStack: string[] | null;
107
+ knowledgeBaseVersion: string;
108
+ claudeFilePath?: string;
109
+ };
110
+ warnings?: string[];
111
+ error?: string;
112
+ }
113
+ export declare class SegoApiClient {
114
+ private baseUrl;
115
+ private apiKey;
116
+ private cachedUser;
117
+ private cachedProjects;
118
+ constructor(baseUrl: string, apiKey: string);
119
+ /**
120
+ * Make an authenticated API request
121
+ */
122
+ private request;
123
+ /**
124
+ * Validate API key and get authenticated user
125
+ */
126
+ validateAuth(): Promise<{
127
+ user: McpUser;
128
+ projects: ProjectMembership[];
129
+ }>;
130
+ /**
131
+ * Get cached user (call validateAuth first)
132
+ */
133
+ getUser(): McpUser | null;
134
+ /**
135
+ * Get cached projects (call validateAuth first)
136
+ */
137
+ getProjects(): ProjectMembership[] | null;
138
+ /**
139
+ * Get tasks from user's projects
140
+ */
141
+ getTasks(filters?: TaskFilters): Promise<Task[]>;
142
+ /**
143
+ * Search tasks by keyword
144
+ */
145
+ searchTasks(query: string, projectId?: string): Promise<{
146
+ tasks: Task[];
147
+ count: number;
148
+ }>;
149
+ /**
150
+ * Get task detail with comments
151
+ */
152
+ getTask(taskId: string): Promise<Task>;
153
+ /**
154
+ * Update task status or assignment
155
+ */
156
+ updateTask(taskId: string, input: UpdateTaskInput): Promise<{
157
+ task: {
158
+ id: string;
159
+ title: string;
160
+ status: string;
161
+ previousStatus: string;
162
+ completedAt: string | null;
163
+ approvedAt: string | null;
164
+ approvedById: string | null;
165
+ assignedToId: string | null;
166
+ updatedAt: string;
167
+ project: Project;
168
+ };
169
+ }>;
170
+ /**
171
+ * Add comment to task
172
+ */
173
+ addTaskComment(taskId: string, content: string): Promise<{
174
+ comment: Comment;
175
+ }>;
176
+ /**
177
+ * Search client requests
178
+ */
179
+ searchClientRequests(filters?: ClientRequestFilters): Promise<{
180
+ requests: ClientRequest[];
181
+ count: number;
182
+ }>;
183
+ /**
184
+ * Get client request detail
185
+ */
186
+ getClientRequest(requestId: string): Promise<{
187
+ request: ClientRequest;
188
+ summary: {
189
+ totalTasks: number;
190
+ tasksByStatus: Record<string, number>;
191
+ totalEstimatedHours: number;
192
+ totalActualHours: number;
193
+ };
194
+ }>;
195
+ /**
196
+ * Create project from CLAUDE.md content
197
+ */
198
+ createProjectFromCodebase(input: CreateProjectInput): Promise<CreateProjectResult>;
199
+ }
200
+ export declare function initializeApiClient(baseUrl: string, apiKey: string): SegoApiClient;
201
+ export declare function getApiClient(): SegoApiClient;
202
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAA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M web application.
5
+ * Used by MCP server tools to access data via API instead of direct database.
6
+ */
7
+ export class SegoApiClient {
8
+ baseUrl;
9
+ apiKey;
10
+ cachedUser = null;
11
+ cachedProjects = null;
12
+ constructor(baseUrl, apiKey) {
13
+ this.baseUrl = baseUrl.replace(/\/$/, ''); // Remove trailing slash
14
+ this.apiKey = apiKey;
15
+ }
16
+ /**
17
+ * Make an authenticated API request
18
+ */
19
+ async request(path, options = {}) {
20
+ const url = `${this.baseUrl}${path}`;
21
+ const response = await fetch(url, {
22
+ ...options,
23
+ headers: {
24
+ 'Content-Type': 'application/json',
25
+ Authorization: `Bearer ${this.apiKey}`,
26
+ ...options.headers,
27
+ },
28
+ });
29
+ if (!response.ok) {
30
+ const errorBody = await response.text();
31
+ let errorMessage;
32
+ try {
33
+ const errorJson = JSON.parse(errorBody);
34
+ errorMessage = errorJson.error || errorJson.message || errorBody;
35
+ }
36
+ catch {
37
+ errorMessage = errorBody;
38
+ }
39
+ throw new Error(`API error (${response.status}): ${errorMessage}`);
40
+ }
41
+ return response.json();
42
+ }
43
+ // ============================================
44
+ // Authentication
45
+ // ============================================
46
+ /**
47
+ * Validate API key and get authenticated user
48
+ */
49
+ async validateAuth() {
50
+ const result = await this.request('/api/mcp/auth/validate', { method: 'POST' });
51
+ // Cache for later use
52
+ this.cachedUser = result.user;
53
+ this.cachedProjects = result.projects;
54
+ return result;
55
+ }
56
+ /**
57
+ * Get cached user (call validateAuth first)
58
+ */
59
+ getUser() {
60
+ return this.cachedUser;
61
+ }
62
+ /**
63
+ * Get cached projects (call validateAuth first)
64
+ */
65
+ getProjects() {
66
+ return this.cachedProjects;
67
+ }
68
+ // ============================================
69
+ // Tasks
70
+ // ============================================
71
+ /**
72
+ * Get tasks from user's projects
73
+ */
74
+ async getTasks(filters) {
75
+ const params = new URLSearchParams();
76
+ if (filters?.projectId)
77
+ params.set('projectId', filters.projectId);
78
+ if (filters?.status)
79
+ params.set('status', filters.status);
80
+ if (filters?.assignedToId)
81
+ params.set('assignedToId', filters.assignedToId);
82
+ const query = params.toString();
83
+ const path = `/api/mcp/tasks${query ? `?${query}` : ''}`;
84
+ const result = await this.request(path);
85
+ return result.tasks;
86
+ }
87
+ /**
88
+ * Search tasks by keyword
89
+ */
90
+ async searchTasks(query, projectId) {
91
+ const params = new URLSearchParams({ query });
92
+ if (projectId)
93
+ params.set('projectId', projectId);
94
+ const result = await this.request(`/api/mcp/tasks/search?${params.toString()}`);
95
+ return result;
96
+ }
97
+ /**
98
+ * Get task detail with comments
99
+ */
100
+ async getTask(taskId) {
101
+ const result = await this.request(`/api/mcp/tasks/${taskId}`);
102
+ return result.task;
103
+ }
104
+ /**
105
+ * Update task status or assignment
106
+ */
107
+ async updateTask(taskId, input) {
108
+ return this.request(`/api/mcp/tasks/${taskId}`, {
109
+ method: 'PATCH',
110
+ body: JSON.stringify(input),
111
+ });
112
+ }
113
+ /**
114
+ * Add comment to task
115
+ */
116
+ async addTaskComment(taskId, content) {
117
+ return this.request(`/api/mcp/tasks/${taskId}/comments`, {
118
+ method: 'POST',
119
+ body: JSON.stringify({ content }),
120
+ });
121
+ }
122
+ // ============================================
123
+ // Client Requests
124
+ // ============================================
125
+ /**
126
+ * Search client requests
127
+ */
128
+ async searchClientRequests(filters) {
129
+ const params = new URLSearchParams();
130
+ if (filters?.projectId)
131
+ params.set('projectId', filters.projectId);
132
+ if (filters?.status)
133
+ params.set('status', filters.status);
134
+ if (filters?.query)
135
+ params.set('query', filters.query);
136
+ const query = params.toString();
137
+ const path = `/api/mcp/client-requests${query ? `?${query}` : ''}`;
138
+ return this.request(path);
139
+ }
140
+ /**
141
+ * Get client request detail
142
+ */
143
+ async getClientRequest(requestId) {
144
+ return this.request(`/api/mcp/client-requests/${requestId}`);
145
+ }
146
+ // ============================================
147
+ // Projects
148
+ // ============================================
149
+ /**
150
+ * Create project from CLAUDE.md content
151
+ */
152
+ async createProjectFromCodebase(input) {
153
+ return this.request('/api/mcp/projects/from-codebase', {
154
+ method: 'POST',
155
+ body: JSON.stringify(input),
156
+ });
157
+ }
158
+ }
159
+ // Singleton instance (initialized in index.ts)
160
+ let apiClient = null;
161
+ export function initializeApiClient(baseUrl, apiKey) {
162
+ apiClient = new SegoApiClient(baseUrl, apiKey);
163
+ return apiClient;
164
+ }
165
+ export function getApiClient() {
166
+ if (!apiClient) {
167
+ throw new Error('API client not initialized. Call initializeApiClient first.');
168
+ }
169
+ return apiClient;
170
+ }
171
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAyHH,MAAM,OAAO,aAAa;IAChB,OAAO,CAAQ;IACf,MAAM,CAAQ;IACd,UAAU,GAAmB,IAAI,CAAA;IACjC,cAAc,GAA+B,IAAI,CAAA;IAEzD,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA,CAAC,wBAAwB;QAClE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,OAAO,CACnB,IAAY,EACZ,UAAuB,EAAE;QAEzB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAA;QAEpC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YAChC,GAAG,OAAO;YACV,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,UAAU,IAAI,CAAC,MAAM,EAAE;gBACtC,GAAG,OAAO,CAAC,OAAO;aACnB;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;YACvC,IAAI,YAAoB,CAAA;YACxB,IAAI,CAAC;gBACH,MAAM,SAAS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AAI,SAAS,GAAyB,IAAI,CAAA;AAE1C,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,MAAc;IACjE,SAAS,GAAG,IAAI,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAC9C,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;IAChF,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Sego PM MCP Server
4
+ *
5
+ * Model Context Protocol server for AI-assisted project management.
6
+ * Communicates with the Sego PM web application via HTTP API.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}