@harness-engineering/mcp-server 0.1.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/LICENSE +21 -0
- package/dist/bin/harness-mcp.d.ts +2 -0
- package/dist/bin/harness-mcp.js +6 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/resources/learnings.d.ts +1 -0
- package/dist/src/resources/learnings.js +14 -0
- package/dist/src/resources/project.d.ts +1 -0
- package/dist/src/resources/project.js +9 -0
- package/dist/src/resources/rules.d.ts +1 -0
- package/dist/src/resources/rules.js +36 -0
- package/dist/src/resources/skills.d.ts +1 -0
- package/dist/src/resources/skills.js +33 -0
- package/dist/src/server.d.ts +17 -0
- package/dist/src/server.js +125 -0
- package/dist/src/tools/agent.d.ts +79 -0
- package/dist/src/tools/agent.js +96 -0
- package/dist/src/tools/architecture.d.ts +17 -0
- package/dist/src/tools/architecture.js +45 -0
- package/dist/src/tools/docs.d.ts +39 -0
- package/dist/src/tools/docs.js +65 -0
- package/dist/src/tools/entropy.d.ts +39 -0
- package/dist/src/tools/entropy.js +81 -0
- package/dist/src/tools/init.d.ts +33 -0
- package/dist/src/tools/init.js +55 -0
- package/dist/src/tools/linter.d.ts +63 -0
- package/dist/src/tools/linter.js +65 -0
- package/dist/src/tools/persona.d.ts +59 -0
- package/dist/src/tools/persona.js +106 -0
- package/dist/src/tools/skill.d.ts +38 -0
- package/dist/src/tools/skill.js +46 -0
- package/dist/src/tools/validate.d.ts +22 -0
- package/dist/src/tools/validate.js +85 -0
- package/dist/src/utils/config-resolver.d.ts +7 -0
- package/dist/src/utils/config-resolver.js +18 -0
- package/dist/src/utils/paths.d.ts +3 -0
- package/dist/src/utils/paths.js +33 -0
- package/dist/src/utils/result-adapter.d.ts +11 -0
- package/dist/src/utils/result-adapter.js +11 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Intense Visions, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getLearningsResource(projectRoot: string): Promise<string>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export async function getLearningsResource(projectRoot) {
|
|
4
|
+
const sections = [];
|
|
5
|
+
const reviewPath = path.join(projectRoot, '.harness', 'review-learnings.md');
|
|
6
|
+
if (fs.existsSync(reviewPath)) {
|
|
7
|
+
sections.push('## Review Learnings\n\n' + fs.readFileSync(reviewPath, 'utf-8'));
|
|
8
|
+
}
|
|
9
|
+
const antiPath = path.join(projectRoot, '.harness', 'anti-patterns.md');
|
|
10
|
+
if (fs.existsSync(antiPath)) {
|
|
11
|
+
sections.push('## Anti-Pattern Log\n\n' + fs.readFileSync(antiPath, 'utf-8'));
|
|
12
|
+
}
|
|
13
|
+
return sections.length > 0 ? sections.join('\n\n---\n\n') : 'No learnings files found.';
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getProjectResource(projectRoot: string): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export async function getProjectResource(projectRoot) {
|
|
4
|
+
const agentsPath = path.join(projectRoot, 'AGENTS.md');
|
|
5
|
+
if (fs.existsSync(agentsPath)) {
|
|
6
|
+
return fs.readFileSync(agentsPath, 'utf-8');
|
|
7
|
+
}
|
|
8
|
+
return '# No AGENTS.md found';
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRulesResource(projectRoot: string): Promise<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
export async function getRulesResource(projectRoot) {
|
|
4
|
+
const rules = [];
|
|
5
|
+
// Try to read harness config
|
|
6
|
+
const configPath = path.join(projectRoot, 'harness.config.json');
|
|
7
|
+
if (fs.existsSync(configPath)) {
|
|
8
|
+
try {
|
|
9
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
10
|
+
if (config.layers) {
|
|
11
|
+
rules.push({ type: 'layer-enforcement', config: config.layers });
|
|
12
|
+
}
|
|
13
|
+
if (config.phaseGates) {
|
|
14
|
+
rules.push({ type: 'phase-gates', config: config.phaseGates });
|
|
15
|
+
}
|
|
16
|
+
if (config.rules) {
|
|
17
|
+
rules.push({ type: 'custom-rules', config: config.rules });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
/* skip malformed config */
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// Try to read .harness/linter.json for linter rules
|
|
25
|
+
const linterPath = path.join(projectRoot, '.harness', 'linter.json');
|
|
26
|
+
if (fs.existsSync(linterPath)) {
|
|
27
|
+
try {
|
|
28
|
+
const linterConfig = JSON.parse(fs.readFileSync(linterPath, 'utf-8'));
|
|
29
|
+
rules.push({ type: 'linter', config: linterConfig });
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
/* skip malformed linter config */
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return JSON.stringify(rules, null, 2);
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSkillsResource(projectRoot: string): Promise<string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as yaml from 'yaml';
|
|
4
|
+
export async function getSkillsResource(projectRoot) {
|
|
5
|
+
const skillsDir = path.join(projectRoot, 'agents', 'skills', 'claude-code');
|
|
6
|
+
const skills = [];
|
|
7
|
+
if (!fs.existsSync(skillsDir)) {
|
|
8
|
+
return JSON.stringify(skills, null, 2);
|
|
9
|
+
}
|
|
10
|
+
const entries = fs.readdirSync(skillsDir, { withFileTypes: true });
|
|
11
|
+
for (const entry of entries) {
|
|
12
|
+
if (!entry.isDirectory())
|
|
13
|
+
continue;
|
|
14
|
+
const skillYamlPath = path.join(skillsDir, entry.name, 'skill.yaml');
|
|
15
|
+
if (!fs.existsSync(skillYamlPath))
|
|
16
|
+
continue;
|
|
17
|
+
try {
|
|
18
|
+
const content = fs.readFileSync(skillYamlPath, 'utf-8');
|
|
19
|
+
const parsed = yaml.parse(content);
|
|
20
|
+
skills.push({
|
|
21
|
+
name: parsed.name,
|
|
22
|
+
description: parsed.description,
|
|
23
|
+
cognitive_mode: parsed.cognitive_mode,
|
|
24
|
+
type: parsed.type,
|
|
25
|
+
triggers: parsed.triggers,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
/* skip malformed skill files */
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return JSON.stringify(skills, null, 2);
|
|
33
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
type ToolDefinition = {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
inputSchema: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
declare const RESOURCE_DEFINITIONS: {
|
|
8
|
+
uri: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
mimeType: string;
|
|
12
|
+
}[];
|
|
13
|
+
export declare function getToolDefinitions(): ToolDefinition[];
|
|
14
|
+
export declare function getResourceDefinitions(): typeof RESOURCE_DEFINITIONS;
|
|
15
|
+
export declare function createHarnessServer(projectRoot?: string): Server;
|
|
16
|
+
export declare function startServer(): Promise<void>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import { validateToolDefinition, handleValidateProject } from './tools/validate.js';
|
|
5
|
+
import { checkDependenciesDefinition, handleCheckDependencies } from './tools/architecture.js';
|
|
6
|
+
import { checkDocsDefinition, handleCheckDocs, validateKnowledgeMapDefinition, handleValidateKnowledgeMap, } from './tools/docs.js';
|
|
7
|
+
import { detectEntropyDefinition, handleDetectEntropy, applyFixesDefinition, handleApplyFixes, } from './tools/entropy.js';
|
|
8
|
+
import { generateLinterDefinition, handleGenerateLinter, validateLinterConfigDefinition, handleValidateLinterConfig, } from './tools/linter.js';
|
|
9
|
+
import { initProjectDefinition, handleInitProject } from './tools/init.js';
|
|
10
|
+
import { listPersonasDefinition, handleListPersonas, generatePersonaArtifactsDefinition, handleGeneratePersonaArtifacts, runPersonaDefinition, handleRunPersona, } from './tools/persona.js';
|
|
11
|
+
import { addComponentDefinition, handleAddComponent, runAgentTaskDefinition, handleRunAgentTask, } from './tools/agent.js';
|
|
12
|
+
import { runSkillDefinition, handleRunSkill } from './tools/skill.js';
|
|
13
|
+
import { getSkillsResource } from './resources/skills.js';
|
|
14
|
+
import { getRulesResource } from './resources/rules.js';
|
|
15
|
+
import { getProjectResource } from './resources/project.js';
|
|
16
|
+
import { getLearningsResource } from './resources/learnings.js';
|
|
17
|
+
const TOOL_DEFINITIONS = [
|
|
18
|
+
validateToolDefinition,
|
|
19
|
+
checkDependenciesDefinition,
|
|
20
|
+
checkDocsDefinition,
|
|
21
|
+
validateKnowledgeMapDefinition,
|
|
22
|
+
detectEntropyDefinition,
|
|
23
|
+
applyFixesDefinition,
|
|
24
|
+
generateLinterDefinition,
|
|
25
|
+
validateLinterConfigDefinition,
|
|
26
|
+
initProjectDefinition,
|
|
27
|
+
listPersonasDefinition,
|
|
28
|
+
generatePersonaArtifactsDefinition,
|
|
29
|
+
runPersonaDefinition,
|
|
30
|
+
addComponentDefinition,
|
|
31
|
+
runAgentTaskDefinition,
|
|
32
|
+
runSkillDefinition,
|
|
33
|
+
];
|
|
34
|
+
const TOOL_HANDLERS = {
|
|
35
|
+
validate_project: handleValidateProject,
|
|
36
|
+
check_dependencies: handleCheckDependencies,
|
|
37
|
+
check_docs: handleCheckDocs,
|
|
38
|
+
validate_knowledge_map: handleValidateKnowledgeMap,
|
|
39
|
+
detect_entropy: handleDetectEntropy,
|
|
40
|
+
apply_fixes: handleApplyFixes,
|
|
41
|
+
generate_linter: handleGenerateLinter,
|
|
42
|
+
validate_linter_config: handleValidateLinterConfig,
|
|
43
|
+
init_project: handleInitProject,
|
|
44
|
+
list_personas: handleListPersonas,
|
|
45
|
+
generate_persona_artifacts: handleGeneratePersonaArtifacts,
|
|
46
|
+
run_persona: handleRunPersona,
|
|
47
|
+
add_component: handleAddComponent,
|
|
48
|
+
run_agent_task: handleRunAgentTask,
|
|
49
|
+
run_skill: handleRunSkill,
|
|
50
|
+
};
|
|
51
|
+
const RESOURCE_DEFINITIONS = [
|
|
52
|
+
{
|
|
53
|
+
uri: 'harness://skills',
|
|
54
|
+
name: 'Harness Skills',
|
|
55
|
+
description: 'Available skills with metadata (name, description, cognitive_mode, type, triggers)',
|
|
56
|
+
mimeType: 'application/json',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
uri: 'harness://rules',
|
|
60
|
+
name: 'Harness Rules',
|
|
61
|
+
description: 'Active linter rules and constraints from harness config',
|
|
62
|
+
mimeType: 'application/json',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
uri: 'harness://project',
|
|
66
|
+
name: 'Project Context',
|
|
67
|
+
description: 'Project structure and agent instructions from AGENTS.md',
|
|
68
|
+
mimeType: 'text/markdown',
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
uri: 'harness://learnings',
|
|
72
|
+
name: 'Learnings',
|
|
73
|
+
description: 'Review learnings and anti-pattern log from .harness/',
|
|
74
|
+
mimeType: 'text/markdown',
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
const RESOURCE_HANDLERS = {
|
|
78
|
+
'harness://skills': getSkillsResource,
|
|
79
|
+
'harness://rules': getRulesResource,
|
|
80
|
+
'harness://project': getProjectResource,
|
|
81
|
+
'harness://learnings': getLearningsResource,
|
|
82
|
+
};
|
|
83
|
+
export function getToolDefinitions() {
|
|
84
|
+
return TOOL_DEFINITIONS;
|
|
85
|
+
}
|
|
86
|
+
export function getResourceDefinitions() {
|
|
87
|
+
return RESOURCE_DEFINITIONS;
|
|
88
|
+
}
|
|
89
|
+
export function createHarnessServer(projectRoot) {
|
|
90
|
+
const resolvedRoot = projectRoot ?? process.cwd();
|
|
91
|
+
const server = new Server({ name: 'harness-engineering', version: '0.1.0' }, { capabilities: { tools: {}, resources: {} } });
|
|
92
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
93
|
+
tools: TOOL_DEFINITIONS,
|
|
94
|
+
}));
|
|
95
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
96
|
+
const { name, arguments: args } = request.params;
|
|
97
|
+
const handler = TOOL_HANDLERS[name];
|
|
98
|
+
if (!handler) {
|
|
99
|
+
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|
|
100
|
+
}
|
|
101
|
+
return handler(args ?? {});
|
|
102
|
+
});
|
|
103
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
104
|
+
resources: RESOURCE_DEFINITIONS,
|
|
105
|
+
}));
|
|
106
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
107
|
+
const uri = request.params.uri;
|
|
108
|
+
const handler = RESOURCE_HANDLERS[uri];
|
|
109
|
+
if (!handler) {
|
|
110
|
+
throw new Error(`Unknown resource: ${uri}`);
|
|
111
|
+
}
|
|
112
|
+
const content = await handler(resolvedRoot);
|
|
113
|
+
const resourceDef = RESOURCE_DEFINITIONS.find((r) => r.uri === uri);
|
|
114
|
+
const mimeType = resourceDef?.mimeType ?? 'text/plain';
|
|
115
|
+
return {
|
|
116
|
+
contents: [{ uri, text: content, mimeType }],
|
|
117
|
+
};
|
|
118
|
+
});
|
|
119
|
+
return server;
|
|
120
|
+
}
|
|
121
|
+
export async function startServer() {
|
|
122
|
+
const server = createHarnessServer();
|
|
123
|
+
const transport = new StdioServerTransport();
|
|
124
|
+
await server.connect(transport);
|
|
125
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export declare const addComponentDefinition: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
path: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
type: {
|
|
12
|
+
type: string;
|
|
13
|
+
enum: string[];
|
|
14
|
+
description: string;
|
|
15
|
+
};
|
|
16
|
+
name: {
|
|
17
|
+
type: string;
|
|
18
|
+
description: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
required: string[];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
export declare function handleAddComponent(input: {
|
|
25
|
+
path: string;
|
|
26
|
+
type: 'layer' | 'doc' | 'component';
|
|
27
|
+
name: string;
|
|
28
|
+
}): Promise<{
|
|
29
|
+
content: {
|
|
30
|
+
type: "text";
|
|
31
|
+
text: string;
|
|
32
|
+
}[];
|
|
33
|
+
isError: boolean;
|
|
34
|
+
} | {
|
|
35
|
+
content: {
|
|
36
|
+
type: "text";
|
|
37
|
+
text: string;
|
|
38
|
+
}[];
|
|
39
|
+
isError?: undefined;
|
|
40
|
+
}>;
|
|
41
|
+
export declare const runAgentTaskDefinition: {
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
inputSchema: {
|
|
45
|
+
type: "object";
|
|
46
|
+
properties: {
|
|
47
|
+
task: {
|
|
48
|
+
type: string;
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
path: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
};
|
|
55
|
+
timeout: {
|
|
56
|
+
type: string;
|
|
57
|
+
description: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
required: string[];
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare function handleRunAgentTask(input: {
|
|
64
|
+
task: string;
|
|
65
|
+
path?: string;
|
|
66
|
+
timeout?: number;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
content: {
|
|
69
|
+
type: "text";
|
|
70
|
+
text: string;
|
|
71
|
+
}[];
|
|
72
|
+
isError?: undefined;
|
|
73
|
+
} | {
|
|
74
|
+
content: {
|
|
75
|
+
type: "text";
|
|
76
|
+
text: string;
|
|
77
|
+
}[];
|
|
78
|
+
isError: boolean;
|
|
79
|
+
}>;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
export const addComponentDefinition = {
|
|
3
|
+
name: 'add_component',
|
|
4
|
+
description: 'Add a component (layer, doc, or component type) to the project using the harness CLI',
|
|
5
|
+
inputSchema: {
|
|
6
|
+
type: 'object',
|
|
7
|
+
properties: {
|
|
8
|
+
path: { type: 'string', description: 'Path to project root directory' },
|
|
9
|
+
type: {
|
|
10
|
+
type: 'string',
|
|
11
|
+
enum: ['layer', 'doc', 'component'],
|
|
12
|
+
description: 'Type of component to add',
|
|
13
|
+
},
|
|
14
|
+
name: { type: 'string', description: 'Name of the component to add' },
|
|
15
|
+
},
|
|
16
|
+
required: ['path', 'type', 'name'],
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export async function handleAddComponent(input) {
|
|
20
|
+
const projectPath = path.resolve(input.path);
|
|
21
|
+
const ALLOWED_TYPES = new Set(['layer', 'doc', 'component']);
|
|
22
|
+
if (!ALLOWED_TYPES.has(input.type)) {
|
|
23
|
+
return {
|
|
24
|
+
content: [
|
|
25
|
+
{
|
|
26
|
+
type: 'text',
|
|
27
|
+
text: JSON.stringify({ error: `Invalid component type: ${input.type}` }),
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
isError: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
const { execFileSync } = await import('node:child_process');
|
|
35
|
+
const output = execFileSync('npx', ['harness', 'add', input.type, input.name], {
|
|
36
|
+
cwd: projectPath,
|
|
37
|
+
stdio: 'pipe',
|
|
38
|
+
});
|
|
39
|
+
return {
|
|
40
|
+
content: [{ type: 'text', text: output.toString() }],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return {
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
text: JSON.stringify({
|
|
49
|
+
error: `add_component failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
50
|
+
}),
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
isError: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export const runAgentTaskDefinition = {
|
|
58
|
+
name: 'run_agent_task',
|
|
59
|
+
description: 'Run an agent task using the harness CLI',
|
|
60
|
+
inputSchema: {
|
|
61
|
+
type: 'object',
|
|
62
|
+
properties: {
|
|
63
|
+
task: { type: 'string', description: 'Task to run' },
|
|
64
|
+
path: { type: 'string', description: 'Path to project root directory' },
|
|
65
|
+
timeout: { type: 'number', description: 'Timeout in milliseconds' },
|
|
66
|
+
},
|
|
67
|
+
required: ['task'],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
export async function handleRunAgentTask(input) {
|
|
71
|
+
const projectPath = input.path ? path.resolve(input.path) : process.cwd();
|
|
72
|
+
try {
|
|
73
|
+
const { execFileSync } = await import('node:child_process');
|
|
74
|
+
const output = execFileSync('npx', ['harness', 'agent', 'run', input.task], {
|
|
75
|
+
cwd: projectPath,
|
|
76
|
+
stdio: 'pipe',
|
|
77
|
+
timeout: input.timeout,
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
content: [{ type: 'text', text: output.toString() }],
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
return {
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'text',
|
|
88
|
+
text: JSON.stringify({
|
|
89
|
+
error: `run_agent_task failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
isError: true,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const checkDependenciesDefinition: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
path: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
required: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export declare function handleCheckDependencies(input: {
|
|
16
|
+
path: string;
|
|
17
|
+
}): Promise<import("../utils/result-adapter.js").McpToolResponse>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { resultToMcpResponse } from '../utils/result-adapter.js';
|
|
3
|
+
import { resolveProjectConfig } from '../utils/config-resolver.js';
|
|
4
|
+
export const checkDependenciesDefinition = {
|
|
5
|
+
name: 'check_dependencies',
|
|
6
|
+
description: 'Validate layer boundaries and detect circular dependencies',
|
|
7
|
+
inputSchema: {
|
|
8
|
+
type: 'object',
|
|
9
|
+
properties: {
|
|
10
|
+
path: { type: 'string', description: 'Path to project root' },
|
|
11
|
+
},
|
|
12
|
+
required: ['path'],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export async function handleCheckDependencies(input) {
|
|
16
|
+
const projectPath = path.resolve(input.path);
|
|
17
|
+
const configResult = resolveProjectConfig(projectPath);
|
|
18
|
+
if (!configResult.ok)
|
|
19
|
+
return resultToMcpResponse(configResult);
|
|
20
|
+
// Delegate to core library
|
|
21
|
+
try {
|
|
22
|
+
const { validateDependencies, TypeScriptParser } = await import('@harness-engineering/core');
|
|
23
|
+
const config = configResult.value;
|
|
24
|
+
const rawLayers = config.layers ?? [];
|
|
25
|
+
const layers = rawLayers.map((l) => ({
|
|
26
|
+
name: l.name,
|
|
27
|
+
patterns: [l.pattern],
|
|
28
|
+
allowedDependencies: l.allowedDependencies,
|
|
29
|
+
}));
|
|
30
|
+
const parser = new TypeScriptParser();
|
|
31
|
+
const result = await validateDependencies({ layers, rootDir: projectPath, parser });
|
|
32
|
+
return resultToMcpResponse(result);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
return {
|
|
36
|
+
content: [
|
|
37
|
+
{
|
|
38
|
+
type: 'text',
|
|
39
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
isError: true,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare const checkDocsDefinition: {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: "object";
|
|
6
|
+
properties: {
|
|
7
|
+
path: {
|
|
8
|
+
type: string;
|
|
9
|
+
description: string;
|
|
10
|
+
};
|
|
11
|
+
domain: {
|
|
12
|
+
type: string;
|
|
13
|
+
description: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
required: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export declare function handleCheckDocs(input: {
|
|
20
|
+
path: string;
|
|
21
|
+
domain?: string;
|
|
22
|
+
}): Promise<import("../utils/result-adapter.js").McpToolResponse>;
|
|
23
|
+
export declare const validateKnowledgeMapDefinition: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
inputSchema: {
|
|
27
|
+
type: "object";
|
|
28
|
+
properties: {
|
|
29
|
+
path: {
|
|
30
|
+
type: string;
|
|
31
|
+
description: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
required: string[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export declare function handleValidateKnowledgeMap(input: {
|
|
38
|
+
path: string;
|
|
39
|
+
}): Promise<import("../utils/result-adapter.js").McpToolResponse>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import { resultToMcpResponse } from '../utils/result-adapter.js';
|
|
3
|
+
export const checkDocsDefinition = {
|
|
4
|
+
name: 'check_docs',
|
|
5
|
+
description: 'Analyze documentation coverage',
|
|
6
|
+
inputSchema: {
|
|
7
|
+
type: 'object',
|
|
8
|
+
properties: {
|
|
9
|
+
path: { type: 'string', description: 'Path to project root' },
|
|
10
|
+
domain: { type: 'string', description: 'Domain/module to check' },
|
|
11
|
+
},
|
|
12
|
+
required: ['path'],
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export async function handleCheckDocs(input) {
|
|
16
|
+
try {
|
|
17
|
+
const { checkDocCoverage } = await import('@harness-engineering/core');
|
|
18
|
+
const domain = input.domain ?? 'src';
|
|
19
|
+
const result = await checkDocCoverage(domain, {
|
|
20
|
+
sourceDir: path.resolve(input.path, 'src'),
|
|
21
|
+
docsDir: path.resolve(input.path, 'docs'),
|
|
22
|
+
});
|
|
23
|
+
return resultToMcpResponse(result);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return {
|
|
27
|
+
content: [
|
|
28
|
+
{
|
|
29
|
+
type: 'text',
|
|
30
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
isError: true,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export const validateKnowledgeMapDefinition = {
|
|
38
|
+
name: 'validate_knowledge_map',
|
|
39
|
+
description: 'Validate AGENTS.md knowledge map structure and links',
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
path: { type: 'string', description: 'Path to project root' },
|
|
44
|
+
},
|
|
45
|
+
required: ['path'],
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
export async function handleValidateKnowledgeMap(input) {
|
|
49
|
+
try {
|
|
50
|
+
const { validateKnowledgeMap } = await import('@harness-engineering/core');
|
|
51
|
+
const result = await validateKnowledgeMap(path.resolve(input.path));
|
|
52
|
+
return resultToMcpResponse(result);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return {
|
|
56
|
+
content: [
|
|
57
|
+
{
|
|
58
|
+
type: 'text',
|
|
59
|
+
text: `Error: ${error instanceof Error ? error.message : String(error)}`,
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
isError: true,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|