@achieveai/hitl-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/dist/index.js ADDED
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env node
2
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
+ import { CallToolRequestSchema, ListToolsRequestSchema, ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';
5
+ import { DialogManager } from './dialog-manager.js';
6
+ import { v4 as uuidv4 } from 'uuid';
7
+ const TOOL_NAME = 'ask_human';
8
+ const SERVER_NAME = 'hitl-mcp-server';
9
+ const SERVER_VERSION = '1.0.0';
10
+ class HumanInTheLoopServer {
11
+ server;
12
+ dialogManager;
13
+ constructor() {
14
+ this.server = new Server({
15
+ name: SERVER_NAME,
16
+ version: SERVER_VERSION,
17
+ }, {
18
+ capabilities: {
19
+ tools: {},
20
+ },
21
+ });
22
+ this.dialogManager = new DialogManager();
23
+ this.setupHandlers();
24
+ }
25
+ setupHandlers() {
26
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
27
+ tools: [
28
+ {
29
+ name: TOOL_NAME,
30
+ description: `CRITICAL: Use this tool when you need human guidance or decision-making. This tool is ESSENTIAL for:
31
+ • Resolving ambiguities or unclear requirements
32
+ • Making subjective decisions that require human judgment
33
+ • Choosing between multiple valid approaches
34
+ • Confirming critical actions before execution
35
+ • Getting additional context or clarification
36
+ • Handling edge cases not covered by your instructions
37
+
38
+ This tool opens an interactive dialog box for the human to respond, ensuring you get the guidance needed to proceed correctly. The human can select from provided options or enter a custom response.
39
+
40
+ IMPORTANT: Prefer using this tool over making assumptions or returning incomplete results. Getting human input ensures accuracy and alignment with user expectations.`,
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {
44
+ question: {
45
+ type: 'string',
46
+ description: 'The question or decision you need help with. Be clear and specific.'
47
+ },
48
+ options: {
49
+ type: 'array',
50
+ description: 'Array of possible choices for the human to select from',
51
+ items: {
52
+ type: 'object',
53
+ properties: {
54
+ label: {
55
+ type: 'string',
56
+ description: 'Display label for this option'
57
+ },
58
+ value: {
59
+ type: 'string',
60
+ description: 'Value to return if this option is selected'
61
+ },
62
+ description: {
63
+ type: 'string',
64
+ description: 'Optional detailed description of what this option means'
65
+ }
66
+ },
67
+ required: ['label', 'value']
68
+ },
69
+ minItems: 1
70
+ },
71
+ allowMultiple: {
72
+ type: 'boolean',
73
+ description: 'Whether to allow selecting multiple options (checkbox vs radio)',
74
+ default: false
75
+ },
76
+ allowOther: {
77
+ type: 'boolean',
78
+ description: 'Whether to show an "Other" text field for custom input',
79
+ default: true
80
+ },
81
+ context: {
82
+ type: 'string',
83
+ description: 'Additional context to help the human understand the situation'
84
+ },
85
+ timeout: {
86
+ type: 'number',
87
+ description: 'Timeout in milliseconds (default: no timeout)',
88
+ minimum: 1000,
89
+ maximum: 3600000
90
+ }
91
+ },
92
+ required: ['question', 'options']
93
+ }
94
+ }
95
+ ]
96
+ }));
97
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
98
+ if (request.params.name !== TOOL_NAME) {
99
+ throw new McpError(ErrorCode.MethodNotFound, `Tool not found: ${request.params.name}`);
100
+ }
101
+ const args = request.params.arguments;
102
+ if (!args.question || !Array.isArray(args.options) || args.options.length === 0) {
103
+ throw new McpError(ErrorCode.InvalidParams, 'Missing required parameters: question and options array');
104
+ }
105
+ try {
106
+ const dialogOptions = args.options.map((opt) => ({
107
+ label: opt.label || opt.value,
108
+ value: opt.value,
109
+ description: opt.description
110
+ }));
111
+ const response = await this.dialogManager.showDialog({
112
+ id: uuidv4(),
113
+ question: args.question,
114
+ options: dialogOptions,
115
+ allowMultiple: args.allowMultiple || false,
116
+ allowOther: args.allowOther !== false,
117
+ context: args.context,
118
+ timeout: args.timeout
119
+ });
120
+ let result = {
121
+ success: true,
122
+ timestamp: response.timestamp
123
+ };
124
+ if (response.otherText === 'SKIPPED') {
125
+ result.skipped = true;
126
+ result.response = 'User skipped this question';
127
+ }
128
+ else if (response.otherText && response.otherText !== '') {
129
+ result.response = response.otherText;
130
+ result.responseType = 'custom';
131
+ }
132
+ else if (response.selectedValues.length > 0) {
133
+ result.response = args.allowMultiple
134
+ ? response.selectedValues
135
+ : response.selectedValues[0];
136
+ result.responseType = 'selection';
137
+ }
138
+ else {
139
+ result.response = null;
140
+ result.responseType = 'none';
141
+ }
142
+ return {
143
+ content: [
144
+ {
145
+ type: 'text',
146
+ text: JSON.stringify(result, null, 2)
147
+ }
148
+ ]
149
+ };
150
+ }
151
+ catch (error) {
152
+ console.error('Dialog error:', error);
153
+ if (error instanceof Error && error.message === 'Dialog timeout') {
154
+ return {
155
+ content: [
156
+ {
157
+ type: 'text',
158
+ text: JSON.stringify({
159
+ success: false,
160
+ error: 'timeout',
161
+ message: 'The user did not respond within the timeout period'
162
+ }, null, 2)
163
+ }
164
+ ]
165
+ };
166
+ }
167
+ throw new McpError(ErrorCode.InternalError, `Failed to show dialog: ${error instanceof Error ? error.message : 'Unknown error'}`);
168
+ }
169
+ });
170
+ }
171
+ async run() {
172
+ const transport = new StdioServerTransport();
173
+ await this.dialogManager.initialize();
174
+ await this.server.connect(transport);
175
+ console.error(`${SERVER_NAME} v${SERVER_VERSION} running on stdio`);
176
+ process.on('SIGINT', async () => {
177
+ await this.cleanup();
178
+ process.exit(0);
179
+ });
180
+ process.on('SIGTERM', async () => {
181
+ await this.cleanup();
182
+ process.exit(0);
183
+ });
184
+ }
185
+ async cleanup() {
186
+ console.error('Shutting down...');
187
+ await this.dialogManager.close();
188
+ }
189
+ }
190
+ const server = new HumanInTheLoopServer();
191
+ server.run().catch((error) => {
192
+ console.error('Server error:', error);
193
+ process.exit(1);
194
+ });
195
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,M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,KAAK,CAAC,GAAG;QACP,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;QAC7C,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;QACtC,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAErC,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,KAAK,cAAc,mBAAmB,CAAC,CAAC;QAEpE,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YAC9B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;QAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;YAC/B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAClC,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;CACF;AAED,MAAM,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAC1C,MAAM,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IAC3B,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=test-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-client.d.ts","sourceRoot":"","sources":["../src/test-client.ts"],"names":[],"mappings":""}
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ import { DialogManager } from './dialog-manager.js';
3
+ async function testDialogManager() {
4
+ console.log('Starting Dialog Manager Test...\n');
5
+ const manager = new DialogManager();
6
+ await manager.initialize();
7
+ const testCases = [
8
+ {
9
+ name: 'Single Choice Question',
10
+ request: {
11
+ id: 'test-1',
12
+ question: 'Which approach should I use for implementing the authentication system?',
13
+ options: [
14
+ {
15
+ label: 'JWT Tokens',
16
+ value: 'jwt',
17
+ description: 'Stateless authentication using JSON Web Tokens'
18
+ },
19
+ {
20
+ label: 'Session-based',
21
+ value: 'session',
22
+ description: 'Traditional server-side session management'
23
+ },
24
+ {
25
+ label: 'OAuth 2.0',
26
+ value: 'oauth',
27
+ description: 'Delegated authentication using OAuth providers'
28
+ }
29
+ ],
30
+ allowMultiple: false,
31
+ allowOther: true,
32
+ context: 'This is for a new web application with expected 10k daily active users'
33
+ }
34
+ },
35
+ {
36
+ name: 'Multiple Choice Question',
37
+ request: {
38
+ id: 'test-2',
39
+ question: 'Which files should I include in the commit?',
40
+ options: [
41
+ {
42
+ label: 'src/auth.ts',
43
+ value: 'auth.ts',
44
+ description: 'Main authentication module'
45
+ },
46
+ {
47
+ label: 'src/middleware.ts',
48
+ value: 'middleware.ts',
49
+ description: 'Authentication middleware'
50
+ },
51
+ {
52
+ label: 'tests/auth.test.ts',
53
+ value: 'auth.test.ts',
54
+ description: 'Unit tests for authentication'
55
+ },
56
+ {
57
+ label: 'README.md',
58
+ value: 'readme',
59
+ description: 'Updated documentation'
60
+ }
61
+ ],
62
+ allowMultiple: true,
63
+ allowOther: false,
64
+ context: 'Several files have been modified in the working directory'
65
+ }
66
+ },
67
+ {
68
+ name: 'Timeout Test',
69
+ request: {
70
+ id: 'test-3',
71
+ question: 'This dialog will timeout in 10 seconds. Do you want to proceed?',
72
+ options: [
73
+ {
74
+ label: 'Yes',
75
+ value: 'yes'
76
+ },
77
+ {
78
+ label: 'No',
79
+ value: 'no'
80
+ }
81
+ ],
82
+ allowMultiple: false,
83
+ allowOther: false,
84
+ timeout: 10000
85
+ }
86
+ }
87
+ ];
88
+ for (const testCase of testCases) {
89
+ console.log(`\\n=== ${testCase.name} ===`);
90
+ console.log(`Question: ${testCase.request.question}`);
91
+ console.log('Waiting for user response...');
92
+ try {
93
+ const response = await manager.showDialog(testCase.request);
94
+ console.log('Response received:', JSON.stringify(response, null, 2));
95
+ }
96
+ catch (error) {
97
+ console.error('Error:', error instanceof Error ? error.message : error);
98
+ }
99
+ // Wait a bit between tests
100
+ await new Promise(resolve => setTimeout(resolve, 2000));
101
+ }
102
+ console.log('\\nAll tests completed. Closing dialog manager...');
103
+ await manager.close();
104
+ process.exit(0);
105
+ }
106
+ // Run the test
107
+ testDialogManager().catch(error => {
108
+ console.error('Test failed:', error);
109
+ process.exit(1);
110
+ });
111
+ //# sourceMappingURL=test-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-client.js","sourceRoot":"","sources":["../src/test-client.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,KAAK,UAAU,iBAAiB;IAC9B,OAAO,CAAC,GAAG,CAAC,mCAAmC,CAAC,CAAC;IAEjD,MAAM,OAAO,GAAG,IAAI,aAAa,EAAE,CAAC;IACpC,MAAM,OAAO,CAAC,UAAU,EAAE,CAAC;IAE3B,MAAM,SAAS,GAAG;QAChB;YACE,IAAI,EAAE,wBAAwB;YAC9B,OAAO,EAAE;gBACP,EAAE,EAAE,QAAQ;gBACZ,QAAQ,EAAE,yEAAyE;gBACnF,OAAO,EAAE;oBACP;wBACE,KAAK,EAAE,YAAY;wBACnB,KAAK,EAAE,KAAK;wBACZ,WAAW,EAAE,gDAAgD;qBAC9D;oBACD;wBACE,KAAK,EAAE,eAAe;wBACtB,KAAK,EAAE,SAAS;wBAChB,WAAW,EAAE,4CAA4C;qBAC1D;oBACD;wBACE,KAAK,EAAE,WAAW;wBAClB,KAAK,EAAE,OAAO;wBACd,WAAW,EAAE,gDAAgD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CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAE5C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC5D,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACvE,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC1E,CAAC;QAED,2BAA2B;QAC3B,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;IACjE,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;IACtB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,eAAe;AACf,iBAAiB,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;IAChC,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,223 @@
1
+ # Example Usage Scenarios
2
+
3
+ ## 1. Ambiguous File Selection
4
+
5
+ ```json
6
+ {
7
+ "tool": "ask_human",
8
+ "arguments": {
9
+ "question": "I found multiple index files. Which one should I modify?",
10
+ "options": [
11
+ {
12
+ "label": "src/index.ts",
13
+ "value": "src/index.ts",
14
+ "description": "Main TypeScript entry point"
15
+ },
16
+ {
17
+ "label": "public/index.html",
18
+ "value": "public/index.html",
19
+ "description": "HTML template file"
20
+ },
21
+ {
22
+ "label": "dist/index.js",
23
+ "value": "dist/index.js",
24
+ "description": "Compiled JavaScript (build output)"
25
+ }
26
+ ],
27
+ "allowMultiple": false,
28
+ "allowOther": true,
29
+ "context": "User asked to 'update the index file' but didn't specify which one"
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## 2. Deployment Confirmation
35
+
36
+ ```json
37
+ {
38
+ "tool": "ask_human",
39
+ "arguments": {
40
+ "question": "Ready to deploy to production. Should I proceed?",
41
+ "options": [
42
+ {
43
+ "label": "Yes, deploy now",
44
+ "value": "deploy",
45
+ "description": "Deploy immediately to production"
46
+ },
47
+ {
48
+ "label": "Run tests first",
49
+ "value": "test-first",
50
+ "description": "Run the test suite before deploying"
51
+ },
52
+ {
53
+ "label": "Deploy to staging",
54
+ "value": "staging",
55
+ "description": "Deploy to staging environment instead"
56
+ },
57
+ {
58
+ "label": "Cancel deployment",
59
+ "value": "cancel",
60
+ "description": "Do not deploy at this time"
61
+ }
62
+ ],
63
+ "allowMultiple": false,
64
+ "allowOther": false,
65
+ "context": "All tests passed, build successful, last deployment was 3 days ago",
66
+ "timeout": 60000
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## 3. Code Style Preference
72
+
73
+ ```json
74
+ {
75
+ "tool": "ask_human",
76
+ "arguments": {
77
+ "question": "Which naming convention should I use for the new API endpoints?",
78
+ "options": [
79
+ {
80
+ "label": "camelCase",
81
+ "value": "camelCase",
82
+ "description": "getUserData, createNewPost"
83
+ },
84
+ {
85
+ "label": "kebab-case",
86
+ "value": "kebab-case",
87
+ "description": "get-user-data, create-new-post"
88
+ },
89
+ {
90
+ "label": "snake_case",
91
+ "value": "snake_case",
92
+ "description": "get_user_data, create_new_post"
93
+ }
94
+ ],
95
+ "allowMultiple": false,
96
+ "allowOther": true,
97
+ "context": "Creating REST API endpoints for the user service"
98
+ }
99
+ }
100
+ ```
101
+
102
+ ## 4. Multiple File Selection
103
+
104
+ ```json
105
+ {
106
+ "tool": "ask_human",
107
+ "arguments": {
108
+ "question": "Which test files should I run?",
109
+ "options": [
110
+ {
111
+ "label": "Unit tests",
112
+ "value": "unit",
113
+ "description": "src/__tests__/*.test.ts"
114
+ },
115
+ {
116
+ "label": "Integration tests",
117
+ "value": "integration",
118
+ "description": "tests/integration/*.spec.ts"
119
+ },
120
+ {
121
+ "label": "E2E tests",
122
+ "value": "e2e",
123
+ "description": "tests/e2e/*.test.ts"
124
+ },
125
+ {
126
+ "label": "Performance tests",
127
+ "value": "performance",
128
+ "description": "tests/performance/*.bench.ts"
129
+ }
130
+ ],
131
+ "allowMultiple": true,
132
+ "allowOther": false,
133
+ "context": "Preparing for release, multiple test suites available"
134
+ }
135
+ }
136
+ ```
137
+
138
+ ## 5. Error Resolution Strategy
139
+
140
+ ```json
141
+ {
142
+ "tool": "ask_human",
143
+ "arguments": {
144
+ "question": "TypeScript compilation failed with 15 errors. How should I proceed?",
145
+ "options": [
146
+ {
147
+ "label": "Fix all errors now",
148
+ "value": "fix-all",
149
+ "description": "Attempt to fix all TypeScript errors"
150
+ },
151
+ {
152
+ "label": "Fix critical errors only",
153
+ "value": "fix-critical",
154
+ "description": "Fix only errors that prevent compilation"
155
+ },
156
+ {
157
+ "label": "Add @ts-ignore comments",
158
+ "value": "ignore",
159
+ "description": "Suppress errors with ignore comments"
160
+ },
161
+ {
162
+ "label": "Show me the errors",
163
+ "value": "show",
164
+ "description": "Display all errors for review"
165
+ }
166
+ ],
167
+ "allowMultiple": false,
168
+ "allowOther": true,
169
+ "context": "Errors are mostly related to type mismatches and missing type definitions"
170
+ }
171
+ }
172
+ ```
173
+
174
+ ## Response Examples
175
+
176
+ ### Successful Selection Response
177
+ ```json
178
+ {
179
+ "success": true,
180
+ "timestamp": 1703001234567,
181
+ "response": "src/index.ts",
182
+ "responseType": "selection"
183
+ }
184
+ ```
185
+
186
+ ### Multiple Selection Response
187
+ ```json
188
+ {
189
+ "success": true,
190
+ "timestamp": 1703001234567,
191
+ "response": ["unit", "integration"],
192
+ "responseType": "selection"
193
+ }
194
+ ```
195
+
196
+ ### Custom Input Response
197
+ ```json
198
+ {
199
+ "success": true,
200
+ "timestamp": 1703001234567,
201
+ "response": "Use PascalCase for classes and camelCase for methods",
202
+ "responseType": "custom"
203
+ }
204
+ ```
205
+
206
+ ### Skipped Response
207
+ ```json
208
+ {
209
+ "success": true,
210
+ "timestamp": 1703001234567,
211
+ "skipped": true,
212
+ "response": "User skipped this question"
213
+ }
214
+ ```
215
+
216
+ ### Timeout Response
217
+ ```json
218
+ {
219
+ "success": false,
220
+ "error": "timeout",
221
+ "message": "The user did not respond within the timeout period"
222
+ }
223
+ ```