@kongyo2/mcp-request-context 1.0.2 → 1.0.3
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/core/storage.d.ts +47 -20
- package/dist/core/storage.d.ts.map +1 -1
- package/dist/core/storage.js +90 -195
- package/dist/core/storage.js.map +1 -1
- package/dist/dashboard/server.d.ts +3 -3
- package/dist/dashboard/server.d.ts.map +1 -1
- package/dist/dashboard/server.js +33 -80
- package/dist/dashboard/server.js.map +1 -1
- package/dist/index.js +25 -57
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +8 -3
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +59 -68
- package/dist/server.js.map +1 -1
- package/dist/tools/get-context-response.d.ts +5 -21
- package/dist/tools/get-context-response.d.ts.map +1 -1
- package/dist/tools/get-context-response.js +30 -26
- package/dist/tools/get-context-response.js.map +1 -1
- package/dist/tools/index.d.ts +6 -7
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +38 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/request-context.d.ts +5 -45
- package/dist/tools/request-context.d.ts.map +1 -1
- package/dist/tools/request-context.js +77 -64
- package/dist/tools/request-context.js.map +1 -1
- package/dist/tools/types.d.ts +7 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +1 -2
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
-
}, "strict", z.ZodTypeAny, {
|
|
7
|
-
requestId: string;
|
|
8
|
-
}, {
|
|
9
|
-
requestId: string;
|
|
10
|
-
}>;
|
|
11
|
-
export type GetContextResponseInput = z.infer<typeof GetContextResponseInputSchema>;
|
|
12
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_NAME = "get_context_response";
|
|
13
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_TITLE = "Get Context Response";
|
|
14
|
-
export declare const GET_CONTEXT_RESPONSE_TOOL_DESCRIPTION = "Check the status of a context request and retrieve the human's response.\n\nUse this tool to poll for responses after creating a context request with 'request_context'.\n\n## Status Values\n- pending: Human has not yet responded\n- answered: Human has provided the requested information\n- cancelled: Request was cancelled\n- expired: Request expired without a response\n\nWhen status is 'answered', the response field contains the information provided by the human.";
|
|
15
|
-
export declare const GET_CONTEXT_RESPONSE_ANNOTATIONS: {
|
|
16
|
-
readOnlyHint: boolean;
|
|
17
|
-
destructiveHint: boolean;
|
|
18
|
-
idempotentHint: boolean;
|
|
19
|
-
openWorldHint: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function getContextResponseHandler(args: GetContextResponseInput, storage: ContextStorage, dashboardUrl?: string): Promise<MCPToolResponse>;
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export declare const getContextResponseTool: Tool;
|
|
5
|
+
export declare function getContextResponseHandler(args: Record<string, unknown>, context: ToolContext): ToolResponse;
|
|
22
6
|
//# sourceMappingURL=get-context-response.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-context-response.d.ts","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"get-context-response.d.ts","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,eAAO,MAAM,sBAAsB,EAAE,IAuBpC,CAAC;AAOF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,YAAY,CAgEd"}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
requestId: z.string()
|
|
6
|
-
.min(1, 'Request ID is required')
|
|
7
|
-
.describe('The ID of the context request to check')
|
|
8
|
-
}).strict();
|
|
9
|
-
export const GET_CONTEXT_RESPONSE_TOOL_NAME = 'get_context_response';
|
|
10
|
-
export const GET_CONTEXT_RESPONSE_TOOL_TITLE = 'Get Context Response';
|
|
11
|
-
export const GET_CONTEXT_RESPONSE_TOOL_DESCRIPTION = `Check the status of a context request and retrieve the human's response.
|
|
1
|
+
// Tool definition using MCP Tool format with JSON Schema
|
|
2
|
+
export const getContextResponseTool = {
|
|
3
|
+
name: 'get_context_response',
|
|
4
|
+
description: `Check the status of a context request and retrieve the human's response.
|
|
12
5
|
|
|
13
6
|
Use this tool to poll for responses after creating a context request with 'request_context'.
|
|
14
7
|
|
|
@@ -18,21 +11,33 @@ Use this tool to poll for responses after creating a context request with 'reque
|
|
|
18
11
|
- cancelled: Request was cancelled
|
|
19
12
|
- expired: Request expired without a response
|
|
20
13
|
|
|
21
|
-
When status is 'answered', the response field contains the information provided by the human
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
When status is 'answered', the response field contains the information provided by the human.`,
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: {
|
|
18
|
+
requestId: {
|
|
19
|
+
type: 'string',
|
|
20
|
+
description: 'The ID of the context request to check'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
required: ['requestId']
|
|
24
|
+
}
|
|
27
25
|
};
|
|
28
|
-
export
|
|
29
|
-
const
|
|
26
|
+
export function getContextResponseHandler(args, context) {
|
|
27
|
+
const input = args;
|
|
28
|
+
// Validate required fields
|
|
29
|
+
if (!input.requestId) {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
message: 'Missing required field: requestId is required'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const result = context.storage.getRequest(input.requestId);
|
|
30
36
|
if (result.isErr()) {
|
|
31
|
-
|
|
37
|
+
return {
|
|
32
38
|
success: false,
|
|
33
39
|
message: `Failed to get context request: ${result.error.message}`
|
|
34
40
|
};
|
|
35
|
-
return toMCPResponse(response, true);
|
|
36
41
|
}
|
|
37
42
|
const request = result.value;
|
|
38
43
|
const isAnswered = request.status === 'answered';
|
|
@@ -41,9 +46,9 @@ export async function getContextResponseHandler(args, storage, dashboardUrl) {
|
|
|
41
46
|
const nextSteps = [];
|
|
42
47
|
if (isPending) {
|
|
43
48
|
nextSteps.push('BLOCKED - Human has not yet responded');
|
|
44
|
-
nextSteps.push('Continue polling with
|
|
45
|
-
if (dashboardUrl) {
|
|
46
|
-
nextSteps.push(`Human should respond at: ${dashboardUrl}`);
|
|
49
|
+
nextSteps.push('Continue polling with get_context_response');
|
|
50
|
+
if (context.dashboardUrl) {
|
|
51
|
+
nextSteps.push(`Human should respond at: ${context.dashboardUrl}`);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
54
|
else if (isAnswered) {
|
|
@@ -58,7 +63,7 @@ export async function getContextResponseHandler(args, storage, dashboardUrl) {
|
|
|
58
63
|
nextSteps.push('Request expired without response');
|
|
59
64
|
nextSteps.push('Create a new request if still needed');
|
|
60
65
|
}
|
|
61
|
-
|
|
66
|
+
return {
|
|
62
67
|
success: true,
|
|
63
68
|
message: isAnswered
|
|
64
69
|
? 'Context response received from human'
|
|
@@ -78,6 +83,5 @@ export async function getContextResponseHandler(args, storage, dashboardUrl) {
|
|
|
78
83
|
},
|
|
79
84
|
nextSteps
|
|
80
85
|
};
|
|
81
|
-
return toMCPResponse(response);
|
|
82
86
|
}
|
|
83
87
|
//# sourceMappingURL=get-context-response.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-context-response.js","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-context-response.js","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,MAAM,CAAC,MAAM,sBAAsB,GAAS;IAC1C,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE;;;;;;;;;;8FAU+E;IAC5F,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,SAAS,EAAE;gBACT,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,wCAAwC;aACtD;SACF;QACD,QAAQ,EAAE,CAAC,WAAW,CAAC;KACxB;CACF,CAAC;AAOF,MAAM,UAAU,yBAAyB,CACvC,IAA6B,EAC7B,OAAoB;IAEpB,MAAM,KAAK,GAAG,IAA0C,CAAC;IAEzD,2BAA2B;IAC3B,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACrB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,+CAA+C;SACzD,CAAC;IACJ,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAE3D,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,CAAC;QACnB,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,kCAAkC,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE;SAClE,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC;IAC7B,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,KAAK,UAAU,CAAC;IACjD,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC;IAC/C,MAAM,UAAU,GAAG,UAAU,CAAC;IAE9B,MAAM,SAAS,GAAa,EAAE,CAAC;IAE/B,IAAI,SAAS,E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V,QAAQ,EAAE,SAAS;SACpB;QACD,SAAS;KACV,CAAC;AACJ,CAAC"}
|
package/dist/tools/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { MCPToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export { ToolContext } from './types.js';
|
|
5
|
+
export declare function registerTools(): Tool[];
|
|
6
|
+
export declare function handleToolCall(name: string, args: Record<string, unknown>, context: ToolContext): MCPToolResponse;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAgB,eAAe,EAAiB,MAAM,kBAAkB,CAAC;AAGhF,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,wBAAgB,aAAa,IAAI,IAAI,EAAE,CAKtC;AAGD,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,eAAe,CA6BjB"}
|
package/dist/tools/index.js
CHANGED
|
@@ -1,4 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { toMCPResponse } from '../core/types.js';
|
|
2
|
+
import { requestContextTool, requestContextHandler } from './request-context.js';
|
|
3
|
+
import { getContextResponseTool, getContextResponseHandler } from './get-context-response.js';
|
|
4
|
+
// Export all registered tools as Tool[] for ListToolsRequestSchema
|
|
5
|
+
export function registerTools() {
|
|
6
|
+
return [
|
|
7
|
+
requestContextTool,
|
|
8
|
+
getContextResponseTool
|
|
9
|
+
];
|
|
10
|
+
}
|
|
11
|
+
// Handle tool calls - central dispatcher
|
|
12
|
+
export function handleToolCall(name, args, context) {
|
|
13
|
+
let response;
|
|
14
|
+
let isError = false;
|
|
15
|
+
try {
|
|
16
|
+
switch (name) {
|
|
17
|
+
case 'request_context':
|
|
18
|
+
response = requestContextHandler(args, context);
|
|
19
|
+
break;
|
|
20
|
+
case 'get_context_response':
|
|
21
|
+
response = getContextResponseHandler(args, context);
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
// Check if the response indicates an error
|
|
27
|
+
isError = !response.success;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
31
|
+
response = {
|
|
32
|
+
success: false,
|
|
33
|
+
message: `Tool execution failed: ${errorMessage}`
|
|
34
|
+
};
|
|
35
|
+
isError = true;
|
|
36
|
+
}
|
|
37
|
+
return toMCPResponse(response, isError);
|
|
38
|
+
}
|
|
4
39
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAE,yBA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
|
-
description: z.ZodString;
|
|
9
|
-
url: z.ZodOptional<z.ZodString>;
|
|
10
|
-
hints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
11
|
-
expectedFormat: z.ZodOptional<z.ZodString>;
|
|
12
|
-
expiresInMinutes: z.ZodOptional<z.ZodNumber>;
|
|
13
|
-
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
14
|
-
}, "strict", z.ZodTypeAny, {
|
|
15
|
-
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
16
|
-
priority: "critical" | "high" | "normal" | "low";
|
|
17
|
-
title: string;
|
|
18
|
-
description: string;
|
|
19
|
-
url?: string | undefined;
|
|
20
|
-
hints?: string[] | undefined;
|
|
21
|
-
expectedFormat?: string | undefined;
|
|
22
|
-
tags?: string[] | undefined;
|
|
23
|
-
expiresInMinutes?: number | undefined;
|
|
24
|
-
}, {
|
|
25
|
-
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
26
|
-
title: string;
|
|
27
|
-
description: string;
|
|
28
|
-
priority?: "critical" | "high" | "normal" | "low" | undefined;
|
|
29
|
-
url?: string | undefined;
|
|
30
|
-
hints?: string[] | undefined;
|
|
31
|
-
expectedFormat?: string | undefined;
|
|
32
|
-
tags?: string[] | undefined;
|
|
33
|
-
expiresInMinutes?: number | undefined;
|
|
34
|
-
}>;
|
|
35
|
-
export type RequestContextInput = z.infer<typeof RequestContextInputSchema>;
|
|
36
|
-
export declare const REQUEST_CONTEXT_TOOL_NAME = "request_context";
|
|
37
|
-
export declare const REQUEST_CONTEXT_TOOL_TITLE = "Request Context from Human";
|
|
38
|
-
export declare const REQUEST_CONTEXT_TOOL_DESCRIPTION = "Request context/information from a human operator.\n\nUse this tool when you need information that:\n- Is behind a URL you cannot access\n- Requires reading documentation that is difficult to parse\n- Involves dependency/API information the human can provide faster\n- Would take multiple turns to gather but the human can provide directly\n\nThe human will see your request in a dashboard UI and can respond with the needed information.\n\n## Context Types\n- url_content: Content from a URL you cannot access\n- documentation: API/library documentation content\n- dependency_info: Package/dependency information\n- code_snippet: Specific code snippets\n- configuration: Configuration file contents\n- api_response: Example API responses\n- error_context: Additional error context\n- custom: Any other type of context\n\n## Priority Levels\n- critical: Blocking - cannot proceed without this\n- high: Important - needed soon\n- normal: Standard priority\n- low: Nice to have\n\nAfter creating a request, poll the status using 'get_context_response' tool.";
|
|
39
|
-
export declare const REQUEST_CONTEXT_ANNOTATIONS: {
|
|
40
|
-
readOnlyHint: boolean;
|
|
41
|
-
destructiveHint: boolean;
|
|
42
|
-
idempotentHint: boolean;
|
|
43
|
-
openWorldHint: boolean;
|
|
44
|
-
};
|
|
45
|
-
export declare function requestContextHandler(args: RequestContextInput, storage: ContextStorage, dashboardUrl?: string): Promise<MCPToolResponse>;
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { ToolResponse } from '../core/types.js';
|
|
3
|
+
import { ToolContext } from './types.js';
|
|
4
|
+
export declare const requestContextTool: Tool;
|
|
5
|
+
export declare function requestContextHandler(args: Record<string, unknown>, context: ToolContext): ToolResponse;
|
|
46
6
|
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAGzC,eAAO,MAAM,kBAAkB,EAAE,IA2EhC,CAAC;AAeF,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,YAAY,CAqDd"}
|
|
@@ -1,41 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
type: ContextTypeSchema
|
|
6
|
-
.describe('The type of context being requested'),
|
|
7
|
-
priority: ContextPrioritySchema
|
|
8
|
-
.default('normal')
|
|
9
|
-
.describe('Priority level of the request'),
|
|
10
|
-
title: z.string()
|
|
11
|
-
.min(1, 'Title is required')
|
|
12
|
-
.max(200, 'Title must not exceed 200 characters')
|
|
13
|
-
.describe('Brief title describing what information is needed'),
|
|
14
|
-
description: z.string()
|
|
15
|
-
.min(1, 'Description is required')
|
|
16
|
-
.max(2000, 'Description must not exceed 2000 characters')
|
|
17
|
-
.describe('Detailed description of what information is needed and why'),
|
|
18
|
-
url: z.string()
|
|
19
|
-
.url('Must be a valid URL')
|
|
20
|
-
.optional()
|
|
21
|
-
.describe('URL to fetch content from (for url_content type)'),
|
|
22
|
-
hints: z.array(z.string())
|
|
23
|
-
.optional()
|
|
24
|
-
.describe('Hints to help the human provide the right information'),
|
|
25
|
-
expectedFormat: z.string()
|
|
26
|
-
.optional()
|
|
27
|
-
.describe('Description of the expected response format'),
|
|
28
|
-
expiresInMinutes: z.number()
|
|
29
|
-
.positive('Must be a positive number')
|
|
30
|
-
.optional()
|
|
31
|
-
.describe('Request expiration time in minutes'),
|
|
32
|
-
tags: z.array(z.string())
|
|
33
|
-
.optional()
|
|
34
|
-
.describe('Tags to categorize the request')
|
|
35
|
-
}).strict();
|
|
36
|
-
export const REQUEST_CONTEXT_TOOL_NAME = 'request_context';
|
|
37
|
-
export const REQUEST_CONTEXT_TOOL_TITLE = 'Request Context from Human';
|
|
38
|
-
export const REQUEST_CONTEXT_TOOL_DESCRIPTION = `Request context/information from a human operator.
|
|
1
|
+
// Tool definition using MCP Tool format with JSON Schema
|
|
2
|
+
export const requestContextTool = {
|
|
3
|
+
name: 'request_context',
|
|
4
|
+
description: `Request context/information from a human operator.
|
|
39
5
|
|
|
40
6
|
Use this tool when you need information that:
|
|
41
7
|
- Is behind a URL you cannot access
|
|
@@ -61,34 +27,82 @@ The human will see your request in a dashboard UI and can respond with the neede
|
|
|
61
27
|
- normal: Standard priority
|
|
62
28
|
- low: Nice to have
|
|
63
29
|
|
|
64
|
-
After creating a request, poll the status using 'get_context_response' tool
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
30
|
+
After creating a request, poll the status using 'get_context_response' tool.`,
|
|
31
|
+
inputSchema: {
|
|
32
|
+
type: 'object',
|
|
33
|
+
properties: {
|
|
34
|
+
type: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: ['url_content', 'documentation', 'dependency_info', 'code_snippet', 'configuration', 'api_response', 'error_context', 'custom'],
|
|
37
|
+
description: 'The type of context being requested'
|
|
38
|
+
},
|
|
39
|
+
priority: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
enum: ['critical', 'high', 'normal', 'low'],
|
|
42
|
+
description: 'Priority level of the request (default: normal)'
|
|
43
|
+
},
|
|
44
|
+
title: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'Brief title describing what information is needed (max 200 chars)'
|
|
47
|
+
},
|
|
48
|
+
description: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Detailed description of what information is needed and why (max 2000 chars)'
|
|
51
|
+
},
|
|
52
|
+
url: {
|
|
53
|
+
type: 'string',
|
|
54
|
+
description: 'URL to fetch content from (for url_content type)'
|
|
55
|
+
},
|
|
56
|
+
hints: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: { type: 'string' },
|
|
59
|
+
description: 'Hints to help the human provide the right information'
|
|
60
|
+
},
|
|
61
|
+
expectedFormat: {
|
|
62
|
+
type: 'string',
|
|
63
|
+
description: 'Description of the expected response format'
|
|
64
|
+
},
|
|
65
|
+
expiresInMinutes: {
|
|
66
|
+
type: 'number',
|
|
67
|
+
description: 'Request expiration time in minutes'
|
|
68
|
+
},
|
|
69
|
+
tags: {
|
|
70
|
+
type: 'array',
|
|
71
|
+
items: { type: 'string' },
|
|
72
|
+
description: 'Tags to categorize the request'
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
required: ['type', 'title', 'description']
|
|
76
|
+
}
|
|
70
77
|
};
|
|
71
|
-
export
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
export function requestContextHandler(args, context) {
|
|
79
|
+
const input = args;
|
|
80
|
+
// Validate required fields
|
|
81
|
+
if (!input.type || !input.title || !input.description) {
|
|
82
|
+
return {
|
|
83
|
+
success: false,
|
|
84
|
+
message: 'Missing required fields: type, title, and description are required'
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const result = context.storage.createRequest({
|
|
88
|
+
type: input.type,
|
|
89
|
+
priority: input.priority ?? 'normal',
|
|
90
|
+
title: input.title,
|
|
91
|
+
description: input.description,
|
|
92
|
+
url: input.url,
|
|
93
|
+
hints: input.hints,
|
|
94
|
+
expectedFormat: input.expectedFormat,
|
|
95
|
+
expiresInMinutes: input.expiresInMinutes,
|
|
96
|
+
tags: input.tags
|
|
82
97
|
});
|
|
83
98
|
if (result.isErr()) {
|
|
84
|
-
|
|
99
|
+
return {
|
|
85
100
|
success: false,
|
|
86
101
|
message: `Failed to create context request: ${result.error.message}`
|
|
87
102
|
};
|
|
88
|
-
return toMCPResponse(response, true);
|
|
89
103
|
}
|
|
90
104
|
const request = result.value;
|
|
91
|
-
|
|
105
|
+
return {
|
|
92
106
|
success: true,
|
|
93
107
|
message: `Context request created successfully. Human will respond via dashboard.`,
|
|
94
108
|
data: {
|
|
@@ -99,17 +113,16 @@ export async function requestContextHandler(args, storage, dashboardUrl) {
|
|
|
99
113
|
status: request.status,
|
|
100
114
|
createdAt: request.createdAt,
|
|
101
115
|
expiresAt: request.expiresAt,
|
|
102
|
-
dashboardUrl
|
|
116
|
+
dashboardUrl: context.dashboardUrl
|
|
103
117
|
},
|
|
104
118
|
nextSteps: [
|
|
105
119
|
'BLOCKING - Wait for human response',
|
|
106
|
-
dashboardUrl
|
|
107
|
-
? `Human should respond at: ${dashboardUrl}`
|
|
108
|
-
: '
|
|
109
|
-
`Poll status with:
|
|
120
|
+
context.dashboardUrl
|
|
121
|
+
? `Human should respond at: ${context.dashboardUrl}`
|
|
122
|
+
: 'Dashboard is starting...',
|
|
123
|
+
`Poll status with: get_context_response requestId:"${request.id}"`,
|
|
110
124
|
'Do NOT proceed until response is received'
|
|
111
125
|
]
|
|
112
126
|
};
|
|
113
|
-
return toMCPResponse(response);
|
|
114
127
|
}
|
|
115
128
|
//# sourceMappingURL=request-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAIA,yDAAyD;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAS;IACtC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;6EA0B8D;IAC3E,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,IAAI,EAAE;gBACJ,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,CAAC;gBACrI,WAAW,EAAE,qCAAqC;aACnD;YACD,QAAQ,EAAE;gBACR,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;gBAC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C1B,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kongyo2/mcp-request-context",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "MCP server for LLM agents to request context from humans - treating humans as a token-efficient API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"@fastify/static": "^7.0.4",
|
|
44
44
|
"@fastify/websocket": "^8.2.1",
|
|
45
45
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
46
|
-
"chokidar": "^3.5.3",
|
|
47
46
|
"fastify": "^4.24.3",
|
|
48
47
|
"neverthrow": "^8.1.1",
|
|
49
48
|
"open": "^8.4.2",
|