@opsee/mcp-server 0.6.5 → 0.6.7
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/package.json +1 -1
- package/src/tools/tasks.ts +15 -1
- package/src/utils/format.ts +42 -7
package/package.json
CHANGED
package/src/tools/tasks.ts
CHANGED
|
@@ -85,7 +85,21 @@ export function registerTaskTools(
|
|
|
85
85
|
sortDir,
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
const pagination = res.pagination;
|
|
89
|
+
const currentPage = page || 1;
|
|
90
|
+
const hasMore = (pagination?.nextPage ?? 0) > 0;
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
content: [{
|
|
94
|
+
type: "text",
|
|
95
|
+
text: formatTaskList(res.tasks, {
|
|
96
|
+
totalCount: pagination?.total,
|
|
97
|
+
page: currentPage,
|
|
98
|
+
hasMore,
|
|
99
|
+
nextPage: hasMore ? currentPage + 1 : undefined,
|
|
100
|
+
}),
|
|
101
|
+
}],
|
|
102
|
+
};
|
|
89
103
|
} catch (error) {
|
|
90
104
|
return { content: [{ type: "text", text: formatError(error) }], isError: true };
|
|
91
105
|
}
|
package/src/utils/format.ts
CHANGED
|
@@ -56,14 +56,49 @@ export function formatTask(t: Task): string {
|
|
|
56
56
|
return lines.join("\n");
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
|
|
59
|
+
interface TaskListMeta {
|
|
60
|
+
totalCount?: number;
|
|
61
|
+
page?: number;
|
|
62
|
+
hasMore?: boolean;
|
|
63
|
+
nextPage?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function formatTaskList(tasks: Task[], projectNameOrMeta?: string | TaskListMeta): string {
|
|
60
67
|
if (tasks.length === 0) return "No tasks found.";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
|
|
69
|
+
// Support both old signature (projectName: string) and new signature (meta: TaskListMeta)
|
|
70
|
+
const isMetaObject = projectNameOrMeta && typeof projectNameOrMeta === 'object';
|
|
71
|
+
const meta = isMetaObject ? projectNameOrMeta as TaskListMeta : undefined;
|
|
72
|
+
const projectName = !isMetaObject ? projectNameOrMeta as string | undefined : undefined;
|
|
73
|
+
|
|
74
|
+
const lines: string[] = [];
|
|
75
|
+
|
|
76
|
+
// Pagination metadata header
|
|
77
|
+
if (meta?.totalCount !== undefined) {
|
|
78
|
+
const pageInfo = meta.page ? `page ${meta.page}` : '';
|
|
79
|
+
const totalInfo = `${meta.totalCount} total`;
|
|
80
|
+
const header = [pageInfo, totalInfo].filter(Boolean).join(', ');
|
|
81
|
+
lines.push(`Tasks (${header}):`);
|
|
82
|
+
if (meta.hasMore && meta.nextPage) {
|
|
83
|
+
lines.push(`(Use page: ${meta.nextPage} to fetch the next 50 tasks)`);
|
|
84
|
+
}
|
|
85
|
+
lines.push('');
|
|
86
|
+
} else {
|
|
87
|
+
// Original header format
|
|
88
|
+
const header = projectName
|
|
89
|
+
? `Found ${tasks.length} task(s) in project "${projectName}":\n`
|
|
90
|
+
: `Found ${tasks.length} task(s):\n`;
|
|
91
|
+
lines.push(header.trimEnd());
|
|
92
|
+
lines.push('');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Task list
|
|
96
|
+
tasks.forEach((t, i) => {
|
|
97
|
+
lines.push(`${i + 1}. ${formatTask(t)}`);
|
|
98
|
+
lines.push('');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return lines.join('\n').trimEnd();
|
|
67
102
|
}
|
|
68
103
|
|
|
69
104
|
export function formatCycle(c: Cycle): string {
|