@damper/mcp 0.2.0 → 0.3.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 +79 -2
- package/dist/index.js +359 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,14 @@ The AI will see tools from both servers and can distinguish between them:
|
|
|
85
85
|
| `abandon_task` | Release lock, return to planned |
|
|
86
86
|
| `list_feedback` | Browse user feedback |
|
|
87
87
|
| `get_feedback` | Feedback details + votes |
|
|
88
|
+
| `list_templates` | List available code templates |
|
|
89
|
+
| `get_template` | Get template content |
|
|
90
|
+
| `update_template` | Create/update a template |
|
|
91
|
+
| `sync_templates` | Bulk upload templates |
|
|
92
|
+
| `list_modules` | List monorepo modules |
|
|
93
|
+
| `get_module` | Get module details |
|
|
94
|
+
| `update_module` | Register/update a module |
|
|
95
|
+
| `sync_modules` | Bulk upload module registry |
|
|
88
96
|
|
|
89
97
|
### Project Context
|
|
90
98
|
|
|
@@ -94,8 +102,8 @@ AI agents can store and retrieve project documentation to help future agents wor
|
|
|
94
102
|
|------|-------------|
|
|
95
103
|
| `get_project_context` | Get context index with section previews. Optionally highlights sections relevant to a task. |
|
|
96
104
|
| `list_context_sections` | List all available context sections |
|
|
97
|
-
| `get_context_section` | Get full content of a specific section |
|
|
98
|
-
| `update_context_section` | Upload/update a context section (requires user permission) |
|
|
105
|
+
| `get_context_section` | Get full content of a specific section. Supports glob patterns (`api/*`, `api/**`). |
|
|
106
|
+
| `update_context_section` | Upload/update a context section with optional tags (requires user permission) |
|
|
99
107
|
| `sync_project_context` | Bulk upload multiple sections at once (requires user permission) |
|
|
100
108
|
|
|
101
109
|
**How it works:**
|
|
@@ -108,6 +116,75 @@ AI agents can store and retrieve project documentation to help future agents wor
|
|
|
108
116
|
|
|
109
117
|
⚠️ **Security:** Never include sensitive data (API keys, secrets, credentials, connection strings) in context uploads. Users can review and delete context from Settings → AI Context.
|
|
110
118
|
|
|
119
|
+
### Hierarchical Sections
|
|
120
|
+
|
|
121
|
+
For monorepos or large projects, organize sections hierarchically:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
> Update the api/architecture section
|
|
125
|
+
> Get all api sections: api/**
|
|
126
|
+
> Get direct children only: api/*
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**When to use**: When a project has many related sections that benefit from organization (e.g., `api/architecture`, `api/endpoints`, `api/testing`).
|
|
130
|
+
|
|
131
|
+
**When to skip**: For simple projects, flat section names like `overview`, `api`, `testing` are sufficient.
|
|
132
|
+
|
|
133
|
+
### Section Tags
|
|
134
|
+
|
|
135
|
+
Add tags to sections for better automatic matching with task labels:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
> Update api section with tags: backend, critical
|
|
139
|
+
> Sections tagged "backend" will auto-surface for tasks labeled "backend"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**When to use**: When you have multiple related sections that should surface together (e.g., all docs tagged "backend" for backend tasks).
|
|
143
|
+
|
|
144
|
+
**When to skip**: For simple projects with few sections. Tags add complexity without much benefit.
|
|
145
|
+
|
|
146
|
+
### Code Templates
|
|
147
|
+
|
|
148
|
+
Store and retrieve code templates for maintaining consistency.
|
|
149
|
+
|
|
150
|
+
| Tool | Description |
|
|
151
|
+
|------|-------------|
|
|
152
|
+
| `list_templates` | List available templates with previews |
|
|
153
|
+
| `get_template` | Get full template content |
|
|
154
|
+
| `update_template` | Create/update a template |
|
|
155
|
+
| `sync_templates` | Bulk upload templates |
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
> List available templates
|
|
159
|
+
> Get the service-module template
|
|
160
|
+
> Create a template for API controllers
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**When to use**: Check for templates before creating new service files, components, or test files. If you notice repetitive patterns, extract them into templates.
|
|
164
|
+
|
|
165
|
+
**When to skip**: If the project doesn't have templates defined, create files using patterns you observe in the existing codebase.
|
|
166
|
+
|
|
167
|
+
### Module Registry
|
|
168
|
+
|
|
169
|
+
Track monorepo package structure for better cross-package awareness.
|
|
170
|
+
|
|
171
|
+
| Tool | Description |
|
|
172
|
+
|------|-------------|
|
|
173
|
+
| `list_modules` | List registered modules with paths and ports |
|
|
174
|
+
| `get_module` | Get module details including dependencies |
|
|
175
|
+
| `update_module` | Register/update a module |
|
|
176
|
+
| `sync_modules` | Bulk upload module registry |
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
> List all modules in this monorepo
|
|
180
|
+
> What port does the dashboard run on?
|
|
181
|
+
> Register the new shared package
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**When to use**: For monorepos with multiple packages. Helps understand package structure and dependencies before making cross-package changes.
|
|
185
|
+
|
|
186
|
+
**When to skip**: For single-package projects, the module registry isn't needed.
|
|
187
|
+
|
|
111
188
|
### Task Types
|
|
112
189
|
|
|
113
190
|
Filter tasks by type to prioritize work:
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,7 @@ async function api(method, path, body) {
|
|
|
34
34
|
// Server
|
|
35
35
|
const server = new McpServer({
|
|
36
36
|
name: 'damper',
|
|
37
|
-
version: '0.
|
|
37
|
+
version: '0.3.0',
|
|
38
38
|
});
|
|
39
39
|
// Output schemas
|
|
40
40
|
const SubtaskProgressSchema = z.object({
|
|
@@ -571,6 +571,8 @@ server.registerTool('list_context_sections', {
|
|
|
571
571
|
updatedAt: z.string(),
|
|
572
572
|
source: z.string(),
|
|
573
573
|
preview: z.string(),
|
|
574
|
+
tags: z.array(z.string()).optional(),
|
|
575
|
+
appliesTo: z.array(z.string()).optional(),
|
|
574
576
|
})),
|
|
575
577
|
isEmpty: z.boolean(),
|
|
576
578
|
}),
|
|
@@ -588,7 +590,10 @@ server.registerTool('list_context_sections', {
|
|
|
588
590
|
structuredContent: data,
|
|
589
591
|
};
|
|
590
592
|
}
|
|
591
|
-
const lines = data.sections.map((s) =>
|
|
593
|
+
const lines = data.sections.map((s) => {
|
|
594
|
+
const tags = s.tags && s.tags.length > 0 ? ` [${s.tags.join(', ')}]` : '';
|
|
595
|
+
return `• ${s.section}${tags} (${s.source}, updated ${s.updatedAt.split('T')[0]})`;
|
|
596
|
+
});
|
|
592
597
|
return {
|
|
593
598
|
content: [{ type: 'text', text: `Context sections:\n${lines.join('\n')}` }],
|
|
594
599
|
structuredContent: data,
|
|
@@ -597,16 +602,35 @@ server.registerTool('list_context_sections', {
|
|
|
597
602
|
// Tool: Get context section
|
|
598
603
|
server.registerTool('get_context_section', {
|
|
599
604
|
title: 'Get Context Section',
|
|
600
|
-
description: 'Get full content of a specific context section.'
|
|
605
|
+
description: 'Get full content of a specific context section. Supports glob patterns for hierarchical sections.\n\n' +
|
|
606
|
+
'**Hierarchical paths**: For monorepos or large projects, sections can be organized hierarchically ' +
|
|
607
|
+
'(e.g., "api/architecture", "api/endpoints/auth"). Use glob patterns to fetch multiple:\n' +
|
|
608
|
+
'- `api/*` - direct children only (api/architecture, api/testing)\n' +
|
|
609
|
+
'- `api/**` - all descendants (api/architecture, api/endpoints/auth)',
|
|
601
610
|
inputSchema: z.object({
|
|
602
|
-
section: z.string().describe('Section name (e.g., "overview", "api", "
|
|
603
|
-
}),
|
|
604
|
-
outputSchema: z.object({
|
|
605
|
-
section: z.string(),
|
|
606
|
-
content: z.string(),
|
|
607
|
-
updatedAt: z.string(),
|
|
608
|
-
source: z.string(),
|
|
611
|
+
section: z.string().describe('Section name or glob pattern (e.g., "overview", "api/architecture", "api/*", "api/**")'),
|
|
609
612
|
}),
|
|
613
|
+
outputSchema: z.union([
|
|
614
|
+
z.object({
|
|
615
|
+
section: z.string(),
|
|
616
|
+
content: z.string(),
|
|
617
|
+
updatedAt: z.string(),
|
|
618
|
+
source: z.string(),
|
|
619
|
+
tags: z.array(z.string()).optional(),
|
|
620
|
+
appliesTo: z.array(z.string()).optional(),
|
|
621
|
+
}),
|
|
622
|
+
z.object({
|
|
623
|
+
pattern: z.string(),
|
|
624
|
+
sections: z.array(z.object({
|
|
625
|
+
section: z.string(),
|
|
626
|
+
content: z.string(),
|
|
627
|
+
updatedAt: z.string(),
|
|
628
|
+
source: z.string(),
|
|
629
|
+
tags: z.array(z.string()).optional(),
|
|
630
|
+
appliesTo: z.array(z.string()).optional(),
|
|
631
|
+
})),
|
|
632
|
+
}),
|
|
633
|
+
]),
|
|
610
634
|
annotations: {
|
|
611
635
|
readOnlyHint: true,
|
|
612
636
|
destructiveHint: false,
|
|
@@ -614,7 +638,19 @@ server.registerTool('get_context_section', {
|
|
|
614
638
|
openWorldHint: false,
|
|
615
639
|
},
|
|
616
640
|
}, async ({ section }) => {
|
|
617
|
-
const data = await api('GET', `/api/agent/context/${section}`);
|
|
641
|
+
const data = await api('GET', `/api/agent/context/${encodeURIComponent(section)}`);
|
|
642
|
+
// Handle glob pattern response (multiple sections)
|
|
643
|
+
if (data.pattern && data.sections) {
|
|
644
|
+
const lines = [`**Sections matching "${data.pattern}":**\n`];
|
|
645
|
+
for (const s of data.sections) {
|
|
646
|
+
lines.push(`# ${s.section}\n\n${s.content}\n\n---\n`);
|
|
647
|
+
}
|
|
648
|
+
return {
|
|
649
|
+
content: [{ type: 'text', text: lines.join('\n') }],
|
|
650
|
+
structuredContent: data,
|
|
651
|
+
};
|
|
652
|
+
}
|
|
653
|
+
// Single section response
|
|
618
654
|
return {
|
|
619
655
|
content: [{ type: 'text', text: `# ${data.section}\n\n${data.content}` }],
|
|
620
656
|
structuredContent: data,
|
|
@@ -625,6 +661,11 @@ server.registerTool('update_context_section', {
|
|
|
625
661
|
title: 'Update Context Section',
|
|
626
662
|
description: 'Upload/update a project context section. Use after analyzing local codebase. ' +
|
|
627
663
|
'This action shares documentation with the Damper project for future AI agents.\n\n' +
|
|
664
|
+
'**When to use hierarchical names**: For monorepos or large projects, use paths like ' +
|
|
665
|
+
'`api/architecture`, `api/testing` to organize by module. For simple projects, flat ' +
|
|
666
|
+
'names like `overview`, `conventions` are sufficient.\n\n' +
|
|
667
|
+
'**When to add tags**: Only if you have multiple related sections that should surface ' +
|
|
668
|
+
'together (e.g., all "backend" docs). Skip for simple projects.\n\n' +
|
|
628
669
|
'⚠️ SECURITY WARNING: Do NOT include sensitive information:\n' +
|
|
629
670
|
'- API keys, secrets, passwords, tokens\n' +
|
|
630
671
|
'- Database connection strings\n' +
|
|
@@ -633,13 +674,17 @@ server.registerTool('update_context_section', {
|
|
|
633
674
|
'- .env file contents or credentials',
|
|
634
675
|
inputSchema: z.object({
|
|
635
676
|
section: z.string()
|
|
636
|
-
.regex(/^[a-z][a-z0-9-]{0,49}$/)
|
|
637
|
-
.describe('Section name
|
|
677
|
+
.regex(/^[a-z][a-z0-9-]{0,49}(\/[a-z][a-z0-9-]{0,49}){0,2}$/)
|
|
678
|
+
.describe('Section name or path (e.g., "overview", "api/architecture"). Max 3 levels.'),
|
|
638
679
|
content: z.string().describe('Markdown documentation for this section. Must NOT contain secrets, API keys, or sensitive data.'),
|
|
680
|
+
tags: z.array(z.string()).optional().describe('Categorization tags (e.g., ["backend", "critical"]). Helps match sections to task labels.'),
|
|
681
|
+
appliesTo: z.array(z.string()).optional().describe('Module names this section applies to (e.g., ["server", "dashboard"]).'),
|
|
639
682
|
}),
|
|
640
683
|
outputSchema: z.object({
|
|
641
684
|
success: z.boolean(),
|
|
642
685
|
section: z.string(),
|
|
686
|
+
tags: z.array(z.string()).optional(),
|
|
687
|
+
appliesTo: z.array(z.string()).optional(),
|
|
643
688
|
warnings: z.array(z.string()).optional(),
|
|
644
689
|
}),
|
|
645
690
|
annotations: {
|
|
@@ -648,9 +693,12 @@ server.registerTool('update_context_section', {
|
|
|
648
693
|
idempotentHint: true,
|
|
649
694
|
openWorldHint: false,
|
|
650
695
|
},
|
|
651
|
-
}, async ({ section, content }) => {
|
|
652
|
-
const result = await api('POST', `/api/agent/context/${section}`, { content });
|
|
696
|
+
}, async ({ section, content, tags, appliesTo }) => {
|
|
697
|
+
const result = await api('POST', `/api/agent/context/${encodeURIComponent(section)}`, { content, tags, appliesTo });
|
|
653
698
|
let text = `📝 Updated context section: ${result.section}`;
|
|
699
|
+
if (result.tags && result.tags.length > 0) {
|
|
700
|
+
text += ` [${result.tags.join(', ')}]`;
|
|
701
|
+
}
|
|
654
702
|
if (result.warnings && result.warnings.length > 0) {
|
|
655
703
|
text += `\n⚠️ Warnings: ${result.warnings.join(', ')}`;
|
|
656
704
|
}
|
|
@@ -673,9 +721,11 @@ server.registerTool('sync_project_context', {
|
|
|
673
721
|
inputSchema: z.object({
|
|
674
722
|
sections: z.array(z.object({
|
|
675
723
|
section: z.string()
|
|
676
|
-
.regex(/^[a-z][a-z0-9-]{0,49}$/)
|
|
677
|
-
.describe('Section name'),
|
|
724
|
+
.regex(/^[a-z][a-z0-9-]{0,49}(\/[a-z][a-z0-9-]{0,49}){0,2}$/)
|
|
725
|
+
.describe('Section name or path (e.g., "overview", "api/architecture")'),
|
|
678
726
|
content: z.string().describe('Markdown documentation (no secrets!)'),
|
|
727
|
+
tags: z.array(z.string()).optional().describe('Categorization tags'),
|
|
728
|
+
appliesTo: z.array(z.string()).optional().describe('Module names this applies to'),
|
|
679
729
|
})).describe('Array of sections to upload'),
|
|
680
730
|
}),
|
|
681
731
|
outputSchema: z.object({
|
|
@@ -709,6 +759,8 @@ server.registerTool('get_project_context', {
|
|
|
709
759
|
section: z.string(),
|
|
710
760
|
preview: z.string(),
|
|
711
761
|
updatedAt: z.string(),
|
|
762
|
+
tags: z.array(z.string()).optional(),
|
|
763
|
+
appliesTo: z.array(z.string()).optional(),
|
|
712
764
|
})),
|
|
713
765
|
relevantSections: z.array(z.string()).optional(),
|
|
714
766
|
hint: z.string().optional(),
|
|
@@ -731,7 +783,8 @@ server.registerTool('get_project_context', {
|
|
|
731
783
|
const lines = ['**Available context sections:**'];
|
|
732
784
|
for (const s of data.index) {
|
|
733
785
|
const relevant = data.relevantSections?.includes(s.section) ? ' ⭐' : '';
|
|
734
|
-
|
|
786
|
+
const tags = s.tags && s.tags.length > 0 ? ` [${s.tags.join(', ')}]` : '';
|
|
787
|
+
lines.push(`• ${s.section}${relevant}${tags} - ${s.preview}`);
|
|
735
788
|
}
|
|
736
789
|
if (data.relevantSections && data.relevantSections.length > 0) {
|
|
737
790
|
lines.push(`\n**Relevant for this task:** ${data.relevantSections.join(', ')}`);
|
|
@@ -821,6 +874,294 @@ server.registerTool('get_feedback', {
|
|
|
821
874
|
structuredContent: f,
|
|
822
875
|
};
|
|
823
876
|
});
|
|
877
|
+
// ==================== Template Tools ====================
|
|
878
|
+
// Tool: List templates
|
|
879
|
+
server.registerTool('list_templates', {
|
|
880
|
+
title: 'List Templates',
|
|
881
|
+
description: 'List available code templates for this project. Templates help maintain consistency ' +
|
|
882
|
+
'when creating new files.\n\n' +
|
|
883
|
+
'**When to use**: Check for templates before creating new service files, components, ' +
|
|
884
|
+
'or test files. If no templates exist, create files using patterns you observe in the codebase.\n\n' +
|
|
885
|
+
'**When to skip**: If the list is empty, the project doesn\'t use templates - that\'s fine.',
|
|
886
|
+
inputSchema: z.object({}),
|
|
887
|
+
outputSchema: z.object({
|
|
888
|
+
templates: z.array(z.object({
|
|
889
|
+
name: z.string(),
|
|
890
|
+
description: z.string().nullable().optional(),
|
|
891
|
+
filePattern: z.string().nullable().optional(),
|
|
892
|
+
tags: z.array(z.string()).optional(),
|
|
893
|
+
preview: z.string(),
|
|
894
|
+
updatedAt: z.string(),
|
|
895
|
+
})),
|
|
896
|
+
isEmpty: z.boolean(),
|
|
897
|
+
}),
|
|
898
|
+
annotations: {
|
|
899
|
+
readOnlyHint: true,
|
|
900
|
+
destructiveHint: false,
|
|
901
|
+
idempotentHint: true,
|
|
902
|
+
openWorldHint: false,
|
|
903
|
+
},
|
|
904
|
+
}, async () => {
|
|
905
|
+
const data = await api('GET', '/api/agent/templates');
|
|
906
|
+
if (data.isEmpty) {
|
|
907
|
+
return {
|
|
908
|
+
content: [{ type: 'text', text: 'No templates available for this project.' }],
|
|
909
|
+
structuredContent: data,
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
const lines = data.templates.map((t) => {
|
|
913
|
+
const pattern = t.filePattern ? ` → ${t.filePattern}` : '';
|
|
914
|
+
const desc = t.description ? `: ${t.description}` : '';
|
|
915
|
+
return `• ${t.name}${pattern}${desc}`;
|
|
916
|
+
});
|
|
917
|
+
return {
|
|
918
|
+
content: [{ type: 'text', text: `Templates:\n${lines.join('\n')}` }],
|
|
919
|
+
structuredContent: data,
|
|
920
|
+
};
|
|
921
|
+
});
|
|
922
|
+
// Tool: Get template
|
|
923
|
+
server.registerTool('get_template', {
|
|
924
|
+
title: 'Get Template',
|
|
925
|
+
description: 'Get full content of a specific code template.',
|
|
926
|
+
inputSchema: z.object({
|
|
927
|
+
name: z.string().describe('Template name'),
|
|
928
|
+
}),
|
|
929
|
+
outputSchema: z.object({
|
|
930
|
+
name: z.string(),
|
|
931
|
+
description: z.string().nullable().optional(),
|
|
932
|
+
content: z.string(),
|
|
933
|
+
filePattern: z.string().nullable().optional(),
|
|
934
|
+
tags: z.array(z.string()).optional(),
|
|
935
|
+
updatedAt: z.string(),
|
|
936
|
+
}),
|
|
937
|
+
annotations: {
|
|
938
|
+
readOnlyHint: true,
|
|
939
|
+
destructiveHint: false,
|
|
940
|
+
idempotentHint: true,
|
|
941
|
+
openWorldHint: false,
|
|
942
|
+
},
|
|
943
|
+
}, async ({ name }) => {
|
|
944
|
+
const t = await api('GET', `/api/agent/templates/${name}`);
|
|
945
|
+
const header = t.description ? `${t.name}: ${t.description}` : t.name;
|
|
946
|
+
const pattern = t.filePattern ? `\nFile pattern: ${t.filePattern}` : '';
|
|
947
|
+
return {
|
|
948
|
+
content: [{ type: 'text', text: `# Template: ${header}${pattern}\n\n\`\`\`\n${t.content}\n\`\`\`` }],
|
|
949
|
+
structuredContent: t,
|
|
950
|
+
};
|
|
951
|
+
});
|
|
952
|
+
// Tool: Update template
|
|
953
|
+
server.registerTool('update_template', {
|
|
954
|
+
title: 'Update Template',
|
|
955
|
+
description: 'Create or update a code template. Templates help maintain consistency across similar files.\n\n' +
|
|
956
|
+
'**When to create templates**: When you notice repetitive file patterns in a project ' +
|
|
957
|
+
'(e.g., all services follow same structure). Extract the pattern and store it.\n\n' +
|
|
958
|
+
'**File patterns**: Use `{name}` as a placeholder in the file pattern ' +
|
|
959
|
+
'(e.g., "src/services/{name}.ts").',
|
|
960
|
+
inputSchema: z.object({
|
|
961
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{0,49}$/).describe('Template name (lowercase, alphanumeric, hyphens)'),
|
|
962
|
+
content: z.string().describe('Template content (can include placeholders like {name}, {description})'),
|
|
963
|
+
description: z.string().optional().describe('Brief description of when to use this template'),
|
|
964
|
+
filePattern: z.string().optional().describe('File path pattern (e.g., "src/services/{name}.ts")'),
|
|
965
|
+
tags: z.array(z.string()).optional().describe('Categorization tags'),
|
|
966
|
+
}),
|
|
967
|
+
outputSchema: z.object({
|
|
968
|
+
success: z.boolean(),
|
|
969
|
+
name: z.string(),
|
|
970
|
+
description: z.string().nullable().optional(),
|
|
971
|
+
filePattern: z.string().nullable().optional(),
|
|
972
|
+
tags: z.array(z.string()).optional(),
|
|
973
|
+
}),
|
|
974
|
+
annotations: {
|
|
975
|
+
readOnlyHint: false,
|
|
976
|
+
destructiveHint: false,
|
|
977
|
+
idempotentHint: true,
|
|
978
|
+
openWorldHint: false,
|
|
979
|
+
},
|
|
980
|
+
}, async ({ name, content, description, filePattern, tags }) => {
|
|
981
|
+
const result = await api('POST', `/api/agent/templates/${name}`, { content, description, filePattern, tags });
|
|
982
|
+
return {
|
|
983
|
+
content: [{ type: 'text', text: `📝 Updated template: ${result.name}` }],
|
|
984
|
+
structuredContent: result,
|
|
985
|
+
};
|
|
986
|
+
});
|
|
987
|
+
// Tool: Sync templates
|
|
988
|
+
server.registerTool('sync_templates', {
|
|
989
|
+
title: 'Sync Templates',
|
|
990
|
+
description: 'Bulk upload multiple templates at once.',
|
|
991
|
+
inputSchema: z.object({
|
|
992
|
+
templates: z.array(z.object({
|
|
993
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{0,49}$/).describe('Template name'),
|
|
994
|
+
content: z.string().describe('Template content'),
|
|
995
|
+
description: z.string().optional().describe('Description'),
|
|
996
|
+
filePattern: z.string().optional().describe('File path pattern'),
|
|
997
|
+
tags: z.array(z.string()).optional().describe('Tags'),
|
|
998
|
+
})).describe('Array of templates to upload'),
|
|
999
|
+
}),
|
|
1000
|
+
outputSchema: z.object({
|
|
1001
|
+
success: z.boolean(),
|
|
1002
|
+
templatesUpdated: z.number(),
|
|
1003
|
+
}),
|
|
1004
|
+
annotations: {
|
|
1005
|
+
readOnlyHint: false,
|
|
1006
|
+
destructiveHint: false,
|
|
1007
|
+
idempotentHint: true,
|
|
1008
|
+
openWorldHint: false,
|
|
1009
|
+
},
|
|
1010
|
+
}, async ({ templates }) => {
|
|
1011
|
+
const result = await api('POST', '/api/agent/templates/sync', { templates });
|
|
1012
|
+
return {
|
|
1013
|
+
content: [{ type: 'text', text: `📚 Synced ${result.templatesUpdated} templates` }],
|
|
1014
|
+
structuredContent: result,
|
|
1015
|
+
};
|
|
1016
|
+
});
|
|
1017
|
+
// ==================== Module Tools ====================
|
|
1018
|
+
// Tool: List modules
|
|
1019
|
+
server.registerTool('list_modules', {
|
|
1020
|
+
title: 'List Modules',
|
|
1021
|
+
description: 'List registered modules in this monorepo. Shows package structure, ports, and dependencies.\n\n' +
|
|
1022
|
+
'**When to use**: For monorepos with multiple packages. Helps understand which packages ' +
|
|
1023
|
+
'exist and how they relate before making cross-package changes.\n\n' +
|
|
1024
|
+
'**When to skip**: For single-package projects or when you already understand the structure.',
|
|
1025
|
+
inputSchema: z.object({}),
|
|
1026
|
+
outputSchema: z.object({
|
|
1027
|
+
modules: z.array(z.object({
|
|
1028
|
+
name: z.string(),
|
|
1029
|
+
path: z.string(),
|
|
1030
|
+
port: z.number().nullable().optional(),
|
|
1031
|
+
dependsOn: z.array(z.string()).optional(),
|
|
1032
|
+
description: z.string().nullable().optional(),
|
|
1033
|
+
tags: z.array(z.string()).optional(),
|
|
1034
|
+
updatedAt: z.string(),
|
|
1035
|
+
})),
|
|
1036
|
+
isEmpty: z.boolean(),
|
|
1037
|
+
}),
|
|
1038
|
+
annotations: {
|
|
1039
|
+
readOnlyHint: true,
|
|
1040
|
+
destructiveHint: false,
|
|
1041
|
+
idempotentHint: true,
|
|
1042
|
+
openWorldHint: false,
|
|
1043
|
+
},
|
|
1044
|
+
}, async () => {
|
|
1045
|
+
const data = await api('GET', '/api/agent/modules');
|
|
1046
|
+
if (data.isEmpty) {
|
|
1047
|
+
return {
|
|
1048
|
+
content: [{ type: 'text', text: 'No modules registered. This may be a single-package project.' }],
|
|
1049
|
+
structuredContent: data,
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
const lines = data.modules.map((m) => {
|
|
1053
|
+
const port = m.port ? ` :${m.port}` : '';
|
|
1054
|
+
const deps = m.dependsOn && m.dependsOn.length > 0 ? ` → ${m.dependsOn.join(', ')}` : '';
|
|
1055
|
+
return `• ${m.name}${port} (${m.path})${deps}`;
|
|
1056
|
+
});
|
|
1057
|
+
return {
|
|
1058
|
+
content: [{ type: 'text', text: `Modules:\n${lines.join('\n')}` }],
|
|
1059
|
+
structuredContent: data,
|
|
1060
|
+
};
|
|
1061
|
+
});
|
|
1062
|
+
// Tool: Get module
|
|
1063
|
+
server.registerTool('get_module', {
|
|
1064
|
+
title: 'Get Module',
|
|
1065
|
+
description: 'Get details of a specific module.',
|
|
1066
|
+
inputSchema: z.object({
|
|
1067
|
+
name: z.string().describe('Module name'),
|
|
1068
|
+
}),
|
|
1069
|
+
outputSchema: z.object({
|
|
1070
|
+
name: z.string(),
|
|
1071
|
+
path: z.string(),
|
|
1072
|
+
port: z.number().nullable().optional(),
|
|
1073
|
+
dependsOn: z.array(z.string()).optional(),
|
|
1074
|
+
description: z.string().nullable().optional(),
|
|
1075
|
+
tags: z.array(z.string()).optional(),
|
|
1076
|
+
updatedAt: z.string(),
|
|
1077
|
+
}),
|
|
1078
|
+
annotations: {
|
|
1079
|
+
readOnlyHint: true,
|
|
1080
|
+
destructiveHint: false,
|
|
1081
|
+
idempotentHint: true,
|
|
1082
|
+
openWorldHint: false,
|
|
1083
|
+
},
|
|
1084
|
+
}, async ({ name }) => {
|
|
1085
|
+
const m = await api('GET', `/api/agent/modules/${name}`);
|
|
1086
|
+
const parts = [`# Module: ${m.name}`, `Path: ${m.path}`];
|
|
1087
|
+
if (m.port)
|
|
1088
|
+
parts.push(`Port: ${m.port}`);
|
|
1089
|
+
if (m.dependsOn && m.dependsOn.length > 0)
|
|
1090
|
+
parts.push(`Depends on: ${m.dependsOn.join(', ')}`);
|
|
1091
|
+
if (m.description)
|
|
1092
|
+
parts.push(`\n${m.description}`);
|
|
1093
|
+
return {
|
|
1094
|
+
content: [{ type: 'text', text: parts.join('\n') }],
|
|
1095
|
+
structuredContent: m,
|
|
1096
|
+
};
|
|
1097
|
+
});
|
|
1098
|
+
// Tool: Update module
|
|
1099
|
+
server.registerTool('update_module', {
|
|
1100
|
+
title: 'Update Module',
|
|
1101
|
+
description: 'Register or update a module in the registry. Use to track monorepo structure.\n\n' +
|
|
1102
|
+
'**When to use**: After analyzing a monorepo, register each package so future agents ' +
|
|
1103
|
+
'understand the structure without re-analyzing.',
|
|
1104
|
+
inputSchema: z.object({
|
|
1105
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{0,49}$/).describe('Module name (e.g., "server", "dashboard")'),
|
|
1106
|
+
path: z.string().describe('Path to module (e.g., "packages/server")'),
|
|
1107
|
+
port: z.number().nullable().optional().describe('Dev server port if applicable'),
|
|
1108
|
+
dependsOn: z.array(z.string()).optional().describe('Names of modules this depends on'),
|
|
1109
|
+
description: z.string().optional().describe('Brief description of the module'),
|
|
1110
|
+
tags: z.array(z.string()).optional().describe('Categorization tags'),
|
|
1111
|
+
}),
|
|
1112
|
+
outputSchema: z.object({
|
|
1113
|
+
success: z.boolean(),
|
|
1114
|
+
name: z.string(),
|
|
1115
|
+
path: z.string(),
|
|
1116
|
+
port: z.number().nullable().optional(),
|
|
1117
|
+
dependsOn: z.array(z.string()).optional(),
|
|
1118
|
+
description: z.string().nullable().optional(),
|
|
1119
|
+
tags: z.array(z.string()).optional(),
|
|
1120
|
+
}),
|
|
1121
|
+
annotations: {
|
|
1122
|
+
readOnlyHint: false,
|
|
1123
|
+
destructiveHint: false,
|
|
1124
|
+
idempotentHint: true,
|
|
1125
|
+
openWorldHint: false,
|
|
1126
|
+
},
|
|
1127
|
+
}, async ({ name, path, port, dependsOn, description, tags }) => {
|
|
1128
|
+
const result = await api('POST', `/api/agent/modules/${name}`, { path, port, dependsOn, description, tags });
|
|
1129
|
+
return {
|
|
1130
|
+
content: [{ type: 'text', text: `📦 Updated module: ${result.name} (${result.path})` }],
|
|
1131
|
+
structuredContent: result,
|
|
1132
|
+
};
|
|
1133
|
+
});
|
|
1134
|
+
// Tool: Sync modules
|
|
1135
|
+
server.registerTool('sync_modules', {
|
|
1136
|
+
title: 'Sync Modules',
|
|
1137
|
+
description: 'Bulk upload multiple modules at once. Use after analyzing a monorepo.',
|
|
1138
|
+
inputSchema: z.object({
|
|
1139
|
+
modules: z.array(z.object({
|
|
1140
|
+
name: z.string().regex(/^[a-z][a-z0-9-]{0,49}$/).describe('Module name'),
|
|
1141
|
+
path: z.string().describe('Path to module'),
|
|
1142
|
+
port: z.number().nullable().optional().describe('Dev server port'),
|
|
1143
|
+
dependsOn: z.array(z.string()).optional().describe('Dependencies'),
|
|
1144
|
+
description: z.string().optional().describe('Description'),
|
|
1145
|
+
tags: z.array(z.string()).optional().describe('Tags'),
|
|
1146
|
+
})).describe('Array of modules to upload'),
|
|
1147
|
+
}),
|
|
1148
|
+
outputSchema: z.object({
|
|
1149
|
+
success: z.boolean(),
|
|
1150
|
+
modulesUpdated: z.number(),
|
|
1151
|
+
}),
|
|
1152
|
+
annotations: {
|
|
1153
|
+
readOnlyHint: false,
|
|
1154
|
+
destructiveHint: false,
|
|
1155
|
+
idempotentHint: true,
|
|
1156
|
+
openWorldHint: false,
|
|
1157
|
+
},
|
|
1158
|
+
}, async ({ modules }) => {
|
|
1159
|
+
const result = await api('POST', '/api/agent/modules/sync', { modules });
|
|
1160
|
+
return {
|
|
1161
|
+
content: [{ type: 'text', text: `📦 Synced ${result.modulesUpdated} modules` }],
|
|
1162
|
+
structuredContent: result,
|
|
1163
|
+
};
|
|
1164
|
+
});
|
|
824
1165
|
// Start
|
|
825
1166
|
async function main() {
|
|
826
1167
|
const transport = new StdioServerTransport();
|