@kongyo2/mcp-request-context 1.0.1
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/core/storage.d.ts +31 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core/types.d.ts +128 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/dashboard/public/index.html +625 -0
- package/dist/dashboard/server.d.ts +25 -0
- package/dist/dashboard/server.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/tools/get-context-response.d.ts +22 -0
- package/dist/tools/get-context-response.d.ts.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/request-context.d.ts +46 -0
- package/dist/tools/request-context.d.ts.map +1 -0
- package/package.json +64 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 kongyo2
|
|
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,31 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
import { Result } from 'neverthrow';
|
|
3
|
+
import { ContextRequest, CreateContextRequestInput, ContextResponseInput } from './types.js';
|
|
4
|
+
export declare class StorageError extends Error {
|
|
5
|
+
readonly code: StorageErrorCode;
|
|
6
|
+
constructor(message: string, code: StorageErrorCode);
|
|
7
|
+
}
|
|
8
|
+
export type StorageErrorCode = 'NOT_FOUND' | 'VALIDATION_ERROR' | 'IO_ERROR' | 'ALREADY_ANSWERED' | 'INVALID_STATUS';
|
|
9
|
+
export type StorageResult<T> = Result<T, StorageError>;
|
|
10
|
+
export declare class ContextStorage extends EventEmitter {
|
|
11
|
+
private storagePath;
|
|
12
|
+
private watcher?;
|
|
13
|
+
private pendingEmit;
|
|
14
|
+
private readonly DEBOUNCE_MS;
|
|
15
|
+
constructor(basePath: string);
|
|
16
|
+
initialize(): Promise<StorageResult<void>>;
|
|
17
|
+
start(): Promise<StorageResult<void>>;
|
|
18
|
+
stop(): Promise<void>;
|
|
19
|
+
private scheduleChangeEmit;
|
|
20
|
+
createRequest(input: CreateContextRequestInput): Promise<StorageResult<ContextRequest>>;
|
|
21
|
+
getRequest(id: string): Promise<StorageResult<ContextRequest>>;
|
|
22
|
+
answerRequest(input: ContextResponseInput): Promise<StorageResult<ContextRequest>>;
|
|
23
|
+
cancelRequest(id: string): Promise<StorageResult<ContextRequest>>;
|
|
24
|
+
getAllRequests(): Promise<StorageResult<ContextRequest[]>>;
|
|
25
|
+
getPendingRequests(): Promise<StorageResult<ContextRequest[]>>;
|
|
26
|
+
deleteRequest(id: string): Promise<StorageResult<void>>;
|
|
27
|
+
cleanupExpired(): Promise<StorageResult<number>>;
|
|
28
|
+
private updateStatus;
|
|
29
|
+
getStoragePath(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC,OAAO,EAAE,MAAM,EAAW,MAAM,YAAY,CAAC;AAE7C,OAAO,EACL,cAAc,EAEd,yBAAyB,EAEzB,oBAAoB,EAErB,MAAM,YAAY,CAAC;AAGpB,qBAAa,YAAa,SAAQ,KAAK;aAGnB,IAAI,EAAE,gBAAgB;gBADtC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,gBAAgB;CAKzC;AAED,MAAM,MAAM,gBAAgB,GACxB,WAAW,GACX,kBAAkB,GAClB,UAAU,GACV,kBAAkB,GAClB,gBAAgB,CAAC;AAErB,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;AAEvD,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAC,CAAqB;IACrC,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAO;gBAEvB,QAAQ,EAAE,MAAM;IAKtB,UAAU,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAY1C,KAAK,IAAI,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IA8BrC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAe3B,OAAO,CAAC,kBAAkB;IAUpB,aAAa,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAqDvF,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IA0B9D,aAAa,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAmClF,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAiCjE,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IAgC1D,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC,CAAC;IAU9D,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAgBvD,cAAc,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YAyBxC,YAAY;IA2B1B,cAAc,IAAI,MAAM;CAGzB"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const ContextTypeSchema: z.ZodEnum<["url_content", "documentation", "dependency_info", "code_snippet", "configuration", "api_response", "error_context", "custom"]>;
|
|
3
|
+
export type ContextType = z.infer<typeof ContextTypeSchema>;
|
|
4
|
+
export declare const ContextPrioritySchema: z.ZodEnum<["critical", "high", "normal", "low"]>;
|
|
5
|
+
export type ContextPriority = z.infer<typeof ContextPrioritySchema>;
|
|
6
|
+
export declare const ContextRequestStatusSchema: z.ZodEnum<["pending", "answered", "cancelled", "expired"]>;
|
|
7
|
+
export type ContextRequestStatus = z.infer<typeof ContextRequestStatusSchema>;
|
|
8
|
+
export declare const ContextRequestSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodString;
|
|
10
|
+
type: z.ZodEnum<["url_content", "documentation", "dependency_info", "code_snippet", "configuration", "api_response", "error_context", "custom"]>;
|
|
11
|
+
priority: z.ZodEnum<["critical", "high", "normal", "low"]>;
|
|
12
|
+
status: z.ZodEnum<["pending", "answered", "cancelled", "expired"]>;
|
|
13
|
+
title: z.ZodString;
|
|
14
|
+
description: z.ZodString;
|
|
15
|
+
url: z.ZodOptional<z.ZodString>;
|
|
16
|
+
hints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
expectedFormat: z.ZodOptional<z.ZodString>;
|
|
18
|
+
createdAt: z.ZodString;
|
|
19
|
+
answeredAt: z.ZodOptional<z.ZodString>;
|
|
20
|
+
expiresAt: z.ZodOptional<z.ZodString>;
|
|
21
|
+
response: z.ZodOptional<z.ZodString>;
|
|
22
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
25
|
+
status: "pending" | "answered" | "cancelled" | "expired";
|
|
26
|
+
id: string;
|
|
27
|
+
priority: "critical" | "high" | "normal" | "low";
|
|
28
|
+
title: string;
|
|
29
|
+
description: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
url?: string | undefined;
|
|
32
|
+
hints?: string[] | undefined;
|
|
33
|
+
expectedFormat?: string | undefined;
|
|
34
|
+
answeredAt?: string | undefined;
|
|
35
|
+
expiresAt?: string | undefined;
|
|
36
|
+
response?: string | undefined;
|
|
37
|
+
tags?: string[] | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
40
|
+
status: "pending" | "answered" | "cancelled" | "expired";
|
|
41
|
+
id: string;
|
|
42
|
+
priority: "critical" | "high" | "normal" | "low";
|
|
43
|
+
title: string;
|
|
44
|
+
description: string;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
url?: string | undefined;
|
|
47
|
+
hints?: string[] | undefined;
|
|
48
|
+
expectedFormat?: string | undefined;
|
|
49
|
+
answeredAt?: string | undefined;
|
|
50
|
+
expiresAt?: string | undefined;
|
|
51
|
+
response?: string | undefined;
|
|
52
|
+
tags?: string[] | undefined;
|
|
53
|
+
}>;
|
|
54
|
+
export type ContextRequest = z.infer<typeof ContextRequestSchema>;
|
|
55
|
+
export declare const CreateContextRequestSchema: z.ZodObject<{
|
|
56
|
+
type: z.ZodEnum<["url_content", "documentation", "dependency_info", "code_snippet", "configuration", "api_response", "error_context", "custom"]>;
|
|
57
|
+
priority: z.ZodDefault<z.ZodEnum<["critical", "high", "normal", "low"]>>;
|
|
58
|
+
title: z.ZodString;
|
|
59
|
+
description: z.ZodString;
|
|
60
|
+
url: z.ZodOptional<z.ZodString>;
|
|
61
|
+
hints: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
62
|
+
expectedFormat: z.ZodOptional<z.ZodString>;
|
|
63
|
+
expiresInMinutes: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
67
|
+
priority: "critical" | "high" | "normal" | "low";
|
|
68
|
+
title: string;
|
|
69
|
+
description: string;
|
|
70
|
+
url?: string | undefined;
|
|
71
|
+
hints?: string[] | undefined;
|
|
72
|
+
expectedFormat?: string | undefined;
|
|
73
|
+
tags?: string[] | undefined;
|
|
74
|
+
expiresInMinutes?: number | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
type: "url_content" | "documentation" | "dependency_info" | "code_snippet" | "configuration" | "api_response" | "error_context" | "custom";
|
|
77
|
+
title: string;
|
|
78
|
+
description: string;
|
|
79
|
+
priority?: "critical" | "high" | "normal" | "low" | undefined;
|
|
80
|
+
url?: string | undefined;
|
|
81
|
+
hints?: string[] | undefined;
|
|
82
|
+
expectedFormat?: string | undefined;
|
|
83
|
+
tags?: string[] | undefined;
|
|
84
|
+
expiresInMinutes?: number | undefined;
|
|
85
|
+
}>;
|
|
86
|
+
export type CreateContextRequestInput = z.infer<typeof CreateContextRequestSchema>;
|
|
87
|
+
export declare const ContextResponseSchema: z.ZodObject<{
|
|
88
|
+
requestId: z.ZodString;
|
|
89
|
+
response: z.ZodString;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
response: string;
|
|
92
|
+
requestId: string;
|
|
93
|
+
}, {
|
|
94
|
+
response: string;
|
|
95
|
+
requestId: string;
|
|
96
|
+
}>;
|
|
97
|
+
export type ContextResponseInput = z.infer<typeof ContextResponseSchema>;
|
|
98
|
+
export interface ToolResponse {
|
|
99
|
+
success: boolean;
|
|
100
|
+
message: string;
|
|
101
|
+
data?: unknown;
|
|
102
|
+
nextSteps?: string[];
|
|
103
|
+
}
|
|
104
|
+
export interface MCPToolResponse {
|
|
105
|
+
content: Array<{
|
|
106
|
+
type: 'text';
|
|
107
|
+
text: string;
|
|
108
|
+
}>;
|
|
109
|
+
isError?: boolean;
|
|
110
|
+
_meta?: Record<string, unknown>;
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
}
|
|
113
|
+
export interface DashboardSession {
|
|
114
|
+
url: string;
|
|
115
|
+
port: number;
|
|
116
|
+
pid: number;
|
|
117
|
+
startedAt: string;
|
|
118
|
+
}
|
|
119
|
+
export declare const WSMessageTypeSchema: z.ZodEnum<["initial", "request-created", "request-updated", "request-answered", "request-cancelled", "ping", "pong"]>;
|
|
120
|
+
export type WSMessageType = z.infer<typeof WSMessageTypeSchema>;
|
|
121
|
+
export interface WSMessage {
|
|
122
|
+
type: WSMessageType;
|
|
123
|
+
data?: unknown;
|
|
124
|
+
timestamp: string;
|
|
125
|
+
}
|
|
126
|
+
export declare function toMCPResponse(response: ToolResponse, isError?: boolean): MCPToolResponse;
|
|
127
|
+
export declare function generateId(prefix?: string): string;
|
|
128
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB,4IAS5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB,kDAKhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,0BAA0B,4DAKrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyB/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUrC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAGnF,eAAO,MAAM,qBAAqB;;;;;;;;;EAGhC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAGzE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAGD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAGD,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,eAAO,MAAM,mBAAmB,uHAQ9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,UAAQ,GAAG,eAAe,CAQtF;AAGD,wBAAgB,UAAU,CAAC,MAAM,SAAQ,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,625 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>MCP Request Context - Dashboard</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
--bg-primary: #0f0f0f;
|
|
10
|
+
--bg-secondary: #1a1a1a;
|
|
11
|
+
--bg-tertiary: #252525;
|
|
12
|
+
--text-primary: #ffffff;
|
|
13
|
+
--text-secondary: #a0a0a0;
|
|
14
|
+
--accent: #6366f1;
|
|
15
|
+
--accent-hover: #4f46e5;
|
|
16
|
+
--success: #22c55e;
|
|
17
|
+
--warning: #f59e0b;
|
|
18
|
+
--error: #ef4444;
|
|
19
|
+
--critical: #dc2626;
|
|
20
|
+
--border: #333333;
|
|
21
|
+
--radius: 8px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
* {
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
margin: 0;
|
|
27
|
+
padding: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
body {
|
|
31
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
32
|
+
background: var(--bg-primary);
|
|
33
|
+
color: var(--text-primary);
|
|
34
|
+
line-height: 1.6;
|
|
35
|
+
min-height: 100vh;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.container {
|
|
39
|
+
max-width: 1200px;
|
|
40
|
+
margin: 0 auto;
|
|
41
|
+
padding: 24px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
header {
|
|
45
|
+
display: flex;
|
|
46
|
+
justify-content: space-between;
|
|
47
|
+
align-items: center;
|
|
48
|
+
margin-bottom: 32px;
|
|
49
|
+
padding-bottom: 16px;
|
|
50
|
+
border-bottom: 1px solid var(--border);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
header h1 {
|
|
54
|
+
font-size: 24px;
|
|
55
|
+
font-weight: 600;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.status-badge {
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
gap: 8px;
|
|
62
|
+
padding: 6px 12px;
|
|
63
|
+
background: var(--bg-secondary);
|
|
64
|
+
border-radius: 20px;
|
|
65
|
+
font-size: 14px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.status-dot {
|
|
69
|
+
width: 8px;
|
|
70
|
+
height: 8px;
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
background: var(--success);
|
|
73
|
+
animation: pulse 2s infinite;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@keyframes pulse {
|
|
77
|
+
0%, 100% { opacity: 1; }
|
|
78
|
+
50% { opacity: 0.5; }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.section-title {
|
|
82
|
+
font-size: 18px;
|
|
83
|
+
font-weight: 500;
|
|
84
|
+
margin-bottom: 16px;
|
|
85
|
+
color: var(--text-secondary);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.request-list {
|
|
89
|
+
display: flex;
|
|
90
|
+
flex-direction: column;
|
|
91
|
+
gap: 16px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.request-card {
|
|
95
|
+
background: var(--bg-secondary);
|
|
96
|
+
border: 1px solid var(--border);
|
|
97
|
+
border-radius: var(--radius);
|
|
98
|
+
padding: 20px;
|
|
99
|
+
transition: border-color 0.2s;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.request-card:hover {
|
|
103
|
+
border-color: var(--accent);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.request-card.priority-critical {
|
|
107
|
+
border-left: 4px solid var(--critical);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.request-card.priority-high {
|
|
111
|
+
border-left: 4px solid var(--warning);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.request-card.priority-normal {
|
|
115
|
+
border-left: 4px solid var(--accent);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.request-card.priority-low {
|
|
119
|
+
border-left: 4px solid var(--text-secondary);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.request-header {
|
|
123
|
+
display: flex;
|
|
124
|
+
justify-content: space-between;
|
|
125
|
+
align-items: flex-start;
|
|
126
|
+
margin-bottom: 12px;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.request-title {
|
|
130
|
+
font-size: 16px;
|
|
131
|
+
font-weight: 500;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.request-meta {
|
|
135
|
+
display: flex;
|
|
136
|
+
gap: 8px;
|
|
137
|
+
flex-wrap: wrap;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.tag {
|
|
141
|
+
padding: 4px 8px;
|
|
142
|
+
border-radius: 4px;
|
|
143
|
+
font-size: 12px;
|
|
144
|
+
font-weight: 500;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.tag.type {
|
|
148
|
+
background: var(--bg-tertiary);
|
|
149
|
+
color: var(--text-secondary);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.tag.priority {
|
|
153
|
+
background: var(--accent);
|
|
154
|
+
color: white;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.tag.priority-critical {
|
|
158
|
+
background: var(--critical);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.tag.priority-high {
|
|
162
|
+
background: var(--warning);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.tag.status {
|
|
166
|
+
background: var(--success);
|
|
167
|
+
color: white;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.tag.status-pending {
|
|
171
|
+
background: var(--warning);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.tag.status-answered {
|
|
175
|
+
background: var(--success);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.tag.status-cancelled {
|
|
179
|
+
background: var(--text-secondary);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.request-description {
|
|
183
|
+
color: var(--text-secondary);
|
|
184
|
+
margin-bottom: 16px;
|
|
185
|
+
white-space: pre-wrap;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.request-url {
|
|
189
|
+
display: block;
|
|
190
|
+
color: var(--accent);
|
|
191
|
+
margin-bottom: 12px;
|
|
192
|
+
word-break: break-all;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.request-hints {
|
|
196
|
+
background: var(--bg-tertiary);
|
|
197
|
+
padding: 12px;
|
|
198
|
+
border-radius: var(--radius);
|
|
199
|
+
margin-bottom: 16px;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
.request-hints h4 {
|
|
203
|
+
font-size: 12px;
|
|
204
|
+
color: var(--text-secondary);
|
|
205
|
+
margin-bottom: 8px;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.request-hints ul {
|
|
209
|
+
list-style: disc;
|
|
210
|
+
padding-left: 20px;
|
|
211
|
+
font-size: 14px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.response-form {
|
|
215
|
+
display: flex;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: 12px;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.response-textarea {
|
|
221
|
+
width: 100%;
|
|
222
|
+
min-height: 150px;
|
|
223
|
+
padding: 12px;
|
|
224
|
+
background: var(--bg-tertiary);
|
|
225
|
+
border: 1px solid var(--border);
|
|
226
|
+
border-radius: var(--radius);
|
|
227
|
+
color: var(--text-primary);
|
|
228
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
229
|
+
font-size: 14px;
|
|
230
|
+
resize: vertical;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.response-textarea:focus {
|
|
234
|
+
outline: none;
|
|
235
|
+
border-color: var(--accent);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.response-actions {
|
|
239
|
+
display: flex;
|
|
240
|
+
gap: 12px;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
button {
|
|
244
|
+
padding: 10px 20px;
|
|
245
|
+
border: none;
|
|
246
|
+
border-radius: var(--radius);
|
|
247
|
+
font-size: 14px;
|
|
248
|
+
font-weight: 500;
|
|
249
|
+
cursor: pointer;
|
|
250
|
+
transition: all 0.2s;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.btn-primary {
|
|
254
|
+
background: var(--accent);
|
|
255
|
+
color: white;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.btn-primary:hover {
|
|
259
|
+
background: var(--accent-hover);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.btn-secondary {
|
|
263
|
+
background: var(--bg-tertiary);
|
|
264
|
+
color: var(--text-primary);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.btn-secondary:hover {
|
|
268
|
+
background: var(--border);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.btn-danger {
|
|
272
|
+
background: var(--error);
|
|
273
|
+
color: white;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.btn-danger:hover {
|
|
277
|
+
background: var(--critical);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.empty-state {
|
|
281
|
+
text-align: center;
|
|
282
|
+
padding: 60px 20px;
|
|
283
|
+
color: var(--text-secondary);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.empty-state h2 {
|
|
287
|
+
font-size: 20px;
|
|
288
|
+
margin-bottom: 8px;
|
|
289
|
+
color: var(--text-primary);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.request-time {
|
|
293
|
+
font-size: 12px;
|
|
294
|
+
color: var(--text-secondary);
|
|
295
|
+
margin-top: 12px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.answered-response {
|
|
299
|
+
background: var(--bg-tertiary);
|
|
300
|
+
padding: 12px;
|
|
301
|
+
border-radius: var(--radius);
|
|
302
|
+
margin-top: 12px;
|
|
303
|
+
font-family: 'Monaco', 'Menlo', monospace;
|
|
304
|
+
font-size: 14px;
|
|
305
|
+
white-space: pre-wrap;
|
|
306
|
+
word-break: break-word;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
.tabs {
|
|
310
|
+
display: flex;
|
|
311
|
+
gap: 4px;
|
|
312
|
+
margin-bottom: 24px;
|
|
313
|
+
background: var(--bg-secondary);
|
|
314
|
+
padding: 4px;
|
|
315
|
+
border-radius: var(--radius);
|
|
316
|
+
width: fit-content;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.tab {
|
|
320
|
+
padding: 8px 16px;
|
|
321
|
+
border: none;
|
|
322
|
+
background: transparent;
|
|
323
|
+
color: var(--text-secondary);
|
|
324
|
+
cursor: pointer;
|
|
325
|
+
border-radius: 6px;
|
|
326
|
+
font-size: 14px;
|
|
327
|
+
transition: all 0.2s;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.tab.active {
|
|
331
|
+
background: var(--accent);
|
|
332
|
+
color: white;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
.tab:hover:not(.active) {
|
|
336
|
+
background: var(--bg-tertiary);
|
|
337
|
+
color: var(--text-primary);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.notification {
|
|
341
|
+
position: fixed;
|
|
342
|
+
bottom: 24px;
|
|
343
|
+
right: 24px;
|
|
344
|
+
padding: 12px 20px;
|
|
345
|
+
background: var(--success);
|
|
346
|
+
color: white;
|
|
347
|
+
border-radius: var(--radius);
|
|
348
|
+
animation: slideIn 0.3s ease-out;
|
|
349
|
+
z-index: 1000;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
@keyframes slideIn {
|
|
353
|
+
from {
|
|
354
|
+
transform: translateX(100%);
|
|
355
|
+
opacity: 0;
|
|
356
|
+
}
|
|
357
|
+
to {
|
|
358
|
+
transform: translateX(0);
|
|
359
|
+
opacity: 1;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.notification.error {
|
|
364
|
+
background: var(--error);
|
|
365
|
+
}
|
|
366
|
+
</style>
|
|
367
|
+
</head>
|
|
368
|
+
<body>
|
|
369
|
+
<div class="container">
|
|
370
|
+
<header>
|
|
371
|
+
<h1>MCP Request Context</h1>
|
|
372
|
+
<div class="status-badge">
|
|
373
|
+
<div class="status-dot"></div>
|
|
374
|
+
<span>Connected</span>
|
|
375
|
+
</div>
|
|
376
|
+
</header>
|
|
377
|
+
|
|
378
|
+
<div class="tabs">
|
|
379
|
+
<button class="tab active" data-tab="pending">Pending</button>
|
|
380
|
+
<button class="tab" data-tab="all">All Requests</button>
|
|
381
|
+
</div>
|
|
382
|
+
|
|
383
|
+
<div id="pending-section">
|
|
384
|
+
<h2 class="section-title">Pending Requests</h2>
|
|
385
|
+
<div id="pending-requests" class="request-list">
|
|
386
|
+
<div class="empty-state">
|
|
387
|
+
<h2>No pending requests</h2>
|
|
388
|
+
<p>When an LLM agent requests context, it will appear here.</p>
|
|
389
|
+
</div>
|
|
390
|
+
</div>
|
|
391
|
+
</div>
|
|
392
|
+
|
|
393
|
+
<div id="all-section" style="display: none;">
|
|
394
|
+
<h2 class="section-title">All Requests</h2>
|
|
395
|
+
<div id="all-requests" class="request-list">
|
|
396
|
+
<div class="empty-state">
|
|
397
|
+
<h2>No requests yet</h2>
|
|
398
|
+
<p>Requests will appear here once created.</p>
|
|
399
|
+
</div>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
<script>
|
|
405
|
+
const ws = new WebSocket(`ws://${window.location.host}/ws`);
|
|
406
|
+
let requests = [];
|
|
407
|
+
|
|
408
|
+
ws.onopen = () => {
|
|
409
|
+
console.log('WebSocket connected');
|
|
410
|
+
updateConnectionStatus(true);
|
|
411
|
+
};
|
|
412
|
+
|
|
413
|
+
ws.onclose = () => {
|
|
414
|
+
console.log('WebSocket disconnected');
|
|
415
|
+
updateConnectionStatus(false);
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
ws.onmessage = (event) => {
|
|
419
|
+
const message = JSON.parse(event.data);
|
|
420
|
+
handleMessage(message);
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
function updateConnectionStatus(connected) {
|
|
424
|
+
const badge = document.querySelector('.status-badge');
|
|
425
|
+
const dot = document.querySelector('.status-dot');
|
|
426
|
+
if (connected) {
|
|
427
|
+
badge.querySelector('span').textContent = 'Connected';
|
|
428
|
+
dot.style.background = 'var(--success)';
|
|
429
|
+
} else {
|
|
430
|
+
badge.querySelector('span').textContent = 'Disconnected';
|
|
431
|
+
dot.style.background = 'var(--error)';
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function handleMessage(message) {
|
|
436
|
+
switch (message.type) {
|
|
437
|
+
case 'initial':
|
|
438
|
+
requests = message.data;
|
|
439
|
+
renderRequests();
|
|
440
|
+
break;
|
|
441
|
+
case 'request-created':
|
|
442
|
+
requests.unshift(message.data);
|
|
443
|
+
renderRequests();
|
|
444
|
+
showNotification('New context request received');
|
|
445
|
+
break;
|
|
446
|
+
case 'request-answered':
|
|
447
|
+
case 'request-cancelled':
|
|
448
|
+
case 'request-updated':
|
|
449
|
+
if (Array.isArray(message.data)) {
|
|
450
|
+
requests = message.data;
|
|
451
|
+
} else {
|
|
452
|
+
const index = requests.findIndex(r => r.id === message.data.id);
|
|
453
|
+
if (index !== -1) {
|
|
454
|
+
requests[index] = message.data;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
renderRequests();
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function renderRequests() {
|
|
463
|
+
const pendingContainer = document.getElementById('pending-requests');
|
|
464
|
+
const allContainer = document.getElementById('all-requests');
|
|
465
|
+
|
|
466
|
+
const pending = requests.filter(r => r.status === 'pending');
|
|
467
|
+
|
|
468
|
+
pendingContainer.innerHTML = pending.length === 0
|
|
469
|
+
? `<div class="empty-state">
|
|
470
|
+
<h2>No pending requests</h2>
|
|
471
|
+
<p>When an LLM agent requests context, it will appear here.</p>
|
|
472
|
+
</div>`
|
|
473
|
+
: pending.map(renderRequestCard).join('');
|
|
474
|
+
|
|
475
|
+
allContainer.innerHTML = requests.length === 0
|
|
476
|
+
? `<div class="empty-state">
|
|
477
|
+
<h2>No requests yet</h2>
|
|
478
|
+
<p>Requests will appear here once created.</p>
|
|
479
|
+
</div>`
|
|
480
|
+
: requests.map(r => renderRequestCard(r, true)).join('');
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
function renderRequestCard(request, showStatus = false) {
|
|
484
|
+
const isPending = request.status === 'pending';
|
|
485
|
+
const priorityClass = `priority-${request.priority}`;
|
|
486
|
+
|
|
487
|
+
return `
|
|
488
|
+
<div class="request-card ${priorityClass}">
|
|
489
|
+
<div class="request-header">
|
|
490
|
+
<h3 class="request-title">${escapeHtml(request.title)}</h3>
|
|
491
|
+
<div class="request-meta">
|
|
492
|
+
<span class="tag type">${request.type.replace('_', ' ')}</span>
|
|
493
|
+
<span class="tag priority ${priorityClass}">${request.priority}</span>
|
|
494
|
+
${showStatus ? `<span class="tag status status-${request.status}">${request.status}</span>` : ''}
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<p class="request-description">${escapeHtml(request.description)}</p>
|
|
499
|
+
|
|
500
|
+
${request.url ? `<a href="${escapeHtml(request.url)}" target="_blank" class="request-url">${escapeHtml(request.url)}</a>` : ''}
|
|
501
|
+
|
|
502
|
+
${request.hints && request.hints.length > 0 ? `
|
|
503
|
+
<div class="request-hints">
|
|
504
|
+
<h4>Hints</h4>
|
|
505
|
+
<ul>
|
|
506
|
+
${request.hints.map(h => `<li>${escapeHtml(h)}</li>`).join('')}
|
|
507
|
+
</ul>
|
|
508
|
+
</div>
|
|
509
|
+
` : ''}
|
|
510
|
+
|
|
511
|
+
${request.expectedFormat ? `
|
|
512
|
+
<div class="request-hints">
|
|
513
|
+
<h4>Expected Format</h4>
|
|
514
|
+
<p>${escapeHtml(request.expectedFormat)}</p>
|
|
515
|
+
</div>
|
|
516
|
+
` : ''}
|
|
517
|
+
|
|
518
|
+
${isPending ? `
|
|
519
|
+
<div class="response-form">
|
|
520
|
+
<textarea
|
|
521
|
+
class="response-textarea"
|
|
522
|
+
id="response-${request.id}"
|
|
523
|
+
placeholder="Enter your response here..."
|
|
524
|
+
></textarea>
|
|
525
|
+
<div class="response-actions">
|
|
526
|
+
<button class="btn-primary" onclick="submitResponse('${request.id}')">Submit Response</button>
|
|
527
|
+
<button class="btn-secondary" onclick="cancelRequest('${request.id}')">Cancel</button>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
` : ''}
|
|
531
|
+
|
|
532
|
+
${request.status === 'answered' && request.response ? `
|
|
533
|
+
<div class="answered-response">${escapeHtml(request.response)}</div>
|
|
534
|
+
` : ''}
|
|
535
|
+
|
|
536
|
+
<div class="request-time">
|
|
537
|
+
Created: ${formatDate(request.createdAt)}
|
|
538
|
+
${request.answeredAt ? ` | Answered: ${formatDate(request.answeredAt)}` : ''}
|
|
539
|
+
${request.expiresAt ? ` | Expires: ${formatDate(request.expiresAt)}` : ''}
|
|
540
|
+
</div>
|
|
541
|
+
</div>
|
|
542
|
+
`;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async function submitResponse(requestId) {
|
|
546
|
+
const textarea = document.getElementById(`response-${requestId}`);
|
|
547
|
+
const response = textarea.value.trim();
|
|
548
|
+
|
|
549
|
+
if (!response) {
|
|
550
|
+
showNotification('Please enter a response', true);
|
|
551
|
+
return;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
try {
|
|
555
|
+
const res = await fetch(`/api/requests/${requestId}/answer`, {
|
|
556
|
+
method: 'POST',
|
|
557
|
+
headers: { 'Content-Type': 'application/json' },
|
|
558
|
+
body: JSON.stringify({ response })
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
if (!res.ok) {
|
|
562
|
+
throw new Error('Failed to submit response');
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
showNotification('Response submitted successfully');
|
|
566
|
+
} catch (error) {
|
|
567
|
+
showNotification('Failed to submit response', true);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
async function cancelRequest(requestId) {
|
|
572
|
+
if (!confirm('Are you sure you want to cancel this request?')) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
try {
|
|
577
|
+
const res = await fetch(`/api/requests/${requestId}/cancel`, {
|
|
578
|
+
method: 'POST'
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
if (!res.ok) {
|
|
582
|
+
throw new Error('Failed to cancel request');
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
showNotification('Request cancelled');
|
|
586
|
+
} catch (error) {
|
|
587
|
+
showNotification('Failed to cancel request', true);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
function showNotification(message, isError = false) {
|
|
592
|
+
const notification = document.createElement('div');
|
|
593
|
+
notification.className = `notification ${isError ? 'error' : ''}`;
|
|
594
|
+
notification.textContent = message;
|
|
595
|
+
document.body.appendChild(notification);
|
|
596
|
+
|
|
597
|
+
setTimeout(() => {
|
|
598
|
+
notification.remove();
|
|
599
|
+
}, 3000);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function escapeHtml(text) {
|
|
603
|
+
const div = document.createElement('div');
|
|
604
|
+
div.textContent = text;
|
|
605
|
+
return div.innerHTML;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
function formatDate(dateStr) {
|
|
609
|
+
return new Date(dateStr).toLocaleString();
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Tab switching
|
|
613
|
+
document.querySelectorAll('.tab').forEach(tab => {
|
|
614
|
+
tab.addEventListener('click', () => {
|
|
615
|
+
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
|
|
616
|
+
tab.classList.add('active');
|
|
617
|
+
|
|
618
|
+
const tabName = tab.dataset.tab;
|
|
619
|
+
document.getElementById('pending-section').style.display = tabName === 'pending' ? 'block' : 'none';
|
|
620
|
+
document.getElementById('all-section').style.display = tabName === 'all' ? 'block' : 'none';
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
</script>
|
|
624
|
+
</body>
|
|
625
|
+
</html>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ContextStorage } from '../core/storage.js';
|
|
2
|
+
export interface DashboardOptions {
|
|
3
|
+
autoOpen?: boolean;
|
|
4
|
+
port?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class DashboardServer {
|
|
7
|
+
private app;
|
|
8
|
+
private storage;
|
|
9
|
+
private projectPath;
|
|
10
|
+
private options;
|
|
11
|
+
private clients;
|
|
12
|
+
private heartbeatInterval?;
|
|
13
|
+
private readonly HEARTBEAT_INTERVAL_MS;
|
|
14
|
+
constructor(projectPath: string, options?: DashboardOptions);
|
|
15
|
+
start(): Promise<string>;
|
|
16
|
+
private setupStorageEvents;
|
|
17
|
+
private sendInitialData;
|
|
18
|
+
private registerApiRoutes;
|
|
19
|
+
private broadcast;
|
|
20
|
+
private startHeartbeat;
|
|
21
|
+
private saveSession;
|
|
22
|
+
stop(): Promise<void>;
|
|
23
|
+
getStorage(): ContextStorage;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/dashboard/server.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAUpD,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,GAAG,CAAkB;IAC7B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,iBAAiB,CAAC,CAAiB;IAC3C,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAS;gBAEnC,WAAW,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;IAOzD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAuE9B,OAAO,CAAC,kBAAkB;YAqCZ,eAAe;IAY7B,OAAO,CAAC,iBAAiB;IAwFzB,OAAO,CAAC,SAAS;IAcjB,OAAO,CAAC,cAAc;YAcR,WAAW;IAiBnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B3B,UAAU,IAAI,cAAc;CAG7B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContextStorage } from './core/storage.js';
|
|
2
|
+
export declare class RequestContextMCPServer {
|
|
3
|
+
private server;
|
|
4
|
+
private storage;
|
|
5
|
+
private projectPath;
|
|
6
|
+
private dashboardUrl?;
|
|
7
|
+
constructor(projectPath: string);
|
|
8
|
+
initialize(): Promise<void>;
|
|
9
|
+
private registerTools;
|
|
10
|
+
stop(): Promise<void>;
|
|
11
|
+
getStorage(): ContextStorage;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA+BnD,qBAAa,uBAAuB;IAClC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,YAAY,CAAC,CAAS;gBAElB,WAAW,EAAE,MAAM;IAsBzB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IA2DjC,OAAO,CAAC,aAAa;IAwDf,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,UAAU,IAAI,cAAc;CAG7B"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ContextStorage } from '../core/storage.js';
|
|
3
|
+
import { MCPToolResponse } from '../core/types.js';
|
|
4
|
+
export declare const GetContextResponseInputSchema: z.ZodObject<{
|
|
5
|
+
requestId: z.ZodString;
|
|
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>;
|
|
22
|
+
//# sourceMappingURL=get-context-response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-context-response.d.ts","sourceRoot":"","sources":["../../src/tools/get-context-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAA+B,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGhF,eAAO,MAAM,6BAA6B;;;;;;EAI/B,CAAC;AAEZ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF,eAAO,MAAM,8BAA8B,yBAAyB,CAAC;AAErE,eAAO,MAAM,+BAA+B,yBAAyB,CAAC;AAEtE,eAAO,MAAM,qCAAqC,udAU4C,CAAC;AAE/F,eAAO,MAAM,gCAAgC;;;;;CAK5C,CAAC;AAEF,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,uBAAuB,EAC7B,OAAO,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,eAAe,CAAC,CAyD1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ContextStorage } from '../core/storage.js';
|
|
2
|
+
export { RequestContextInputSchema, RequestContextInput, REQUEST_CONTEXT_TOOL_NAME, REQUEST_CONTEXT_TOOL_TITLE, REQUEST_CONTEXT_TOOL_DESCRIPTION, REQUEST_CONTEXT_ANNOTATIONS, requestContextHandler } from './request-context.js';
|
|
3
|
+
export { GetContextResponseInputSchema, GetContextResponseInput, GET_CONTEXT_RESPONSE_TOOL_NAME, GET_CONTEXT_RESPONSE_TOOL_TITLE, GET_CONTEXT_RESPONSE_TOOL_DESCRIPTION, GET_CONTEXT_RESPONSE_ANNOTATIONS, getContextResponseHandler } from './get-context-response.js';
|
|
4
|
+
export interface ToolContext {
|
|
5
|
+
storage: ContextStorage;
|
|
6
|
+
dashboardUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD,OAAO,EACL,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,0BAA0B,EAC1B,gCAAgC,EAChC,2BAA2B,EAC3B,qBAAqB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,8BAA8B,EAC9B,+BAA+B,EAC/B,qCAAqC,EACrC,gCAAgC,EAChC,yBAAyB,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ContextStorage } from '../core/storage.js';
|
|
3
|
+
import { MCPToolResponse } from '../core/types.js';
|
|
4
|
+
export declare const RequestContextInputSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodEnum<["url_content", "documentation", "dependency_info", "code_snippet", "configuration", "api_response", "error_context", "custom"]>;
|
|
6
|
+
priority: z.ZodDefault<z.ZodEnum<["critical", "high", "normal", "low"]>>;
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
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>;
|
|
46
|
+
//# sourceMappingURL=request-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.d.ts","sourceRoot":"","sources":["../../src/tools/request-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAA+B,eAAe,EAA4C,MAAM,kBAAkB,CAAC;AAG1H,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B3B,CAAC;AAEZ,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,yBAAyB,oBAAoB,CAAC;AAE3D,eAAO,MAAM,0BAA0B,+BAA+B,CAAC;AAEvE,eAAO,MAAM,gCAAgC,oiCA0BgC,CAAC;AAE9E,eAAO,MAAM,2BAA2B;;;;;CAKvC,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,IAAI,EAAE,mBAAmB,EACzB,OAAO,EAAE,cAAc,EACvB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,eAAe,CAAC,CA8C1B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kongyo2/mcp-request-context",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "MCP server for LLM agents to request context from humans - treating humans as a token-efficient API",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/kongyo2/mcp-request-context.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/kongyo2/mcp-request-context#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/kongyo2/mcp-request-context/issues"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "dist/index.js",
|
|
15
|
+
"bin": {
|
|
16
|
+
"mcp-request-context": "dist/index.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**/*",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc && node scripts/copy-static.cjs",
|
|
24
|
+
"dev": "tsx src/index.ts",
|
|
25
|
+
"start": "node dist/index.js",
|
|
26
|
+
"lint": "oxlint --silent",
|
|
27
|
+
"lint:strict": "oxlint --deny-warnings",
|
|
28
|
+
"clean": "rimraf dist",
|
|
29
|
+
"prepublishOnly": "npm run build"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"mcp",
|
|
33
|
+
"model-context-protocol",
|
|
34
|
+
"context-request",
|
|
35
|
+
"ai-development",
|
|
36
|
+
"human-in-the-loop",
|
|
37
|
+
"llm-agent"
|
|
38
|
+
],
|
|
39
|
+
"author": "",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@fastify/cors": "^9.0.1",
|
|
43
|
+
"@fastify/static": "^7.0.4",
|
|
44
|
+
"@fastify/websocket": "^8.2.1",
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
46
|
+
"chokidar": "^3.5.3",
|
|
47
|
+
"fastify": "^4.24.3",
|
|
48
|
+
"neverthrow": "^8.1.1",
|
|
49
|
+
"open": "^8.4.2",
|
|
50
|
+
"ws": "^8.18.0",
|
|
51
|
+
"zod": "^3.24.1"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@types/node": "^22.18.1",
|
|
55
|
+
"@types/ws": "^8.5.13",
|
|
56
|
+
"oxlint": "^0.16.1",
|
|
57
|
+
"rimraf": "^6.0.1",
|
|
58
|
+
"tsx": "^4.7.0",
|
|
59
|
+
"typescript": "^5.7.2"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18.0.0"
|
|
63
|
+
}
|
|
64
|
+
}
|